Automate Speckle

Hi, I am trying to develop an automatic answer to a commit.
Example of flow:
1/ One user push a query (line/text) from grasshopper
2/ The query is processed automatically. (python/flask api)
3/ An “answer” is sent back to the user (say a another line/shape/number)
This is basically similar to a rest API but embedded in the Speckle flow.

Is this possible in Speckle? What would be the best approach?
thanks

2 Likes

Hey there @Designer_London! :wave:t3:

Welcome to the community! If you haven’t already, feel free to Introduce yourself 🙆 (or not… no pressure :wink:)

As I understand it, you want to be able to create a “service” that listens to specific actions and executes a task accordingly. This is certainly possible, although I would say it’s going to get waaay better (hopefully) very soon.

The core functionality of the script

This can be done by our C# and Python SDKs, basically you’d need to:

  • Run a script that would start listening to the desired event (in your case, it would be every time a commit is created in a specific stream)
  • Whenever the event gets raised:
    • Get the latest information from that stream.
    • Process that information in any way you need
    • Upload the new objects
    • Create a new commit.

Currently, the python SDK has limited capability for listening to events, but the C# SDK (aka Speckle.Core) does. We’ll update python soon with the missing ones.

As for listening to events…

2 Ways of listening to events

GraphQL Subscriptions

Currently, interacting with the server is done using our graphql API. The api includes subscriptions, events that you can listen to and get notified whenever something happens (like a commit creation).

This is how we are displaying branch and stream creation notifications in the Speckle Web App.

It works great on end user scenarios, where you can keep a connection open and listening actively, but it’s not ideal when you want a “service” that works 24/7.

Webhooks

This is an upcoming feature and is not yet available (but will be very soon :crossed_fingers:t3:).

We’re currently adding the capability to set up webhooks, which would allow you to “tell” the server to execute a call to a specific url (wherever your service lives). This way you don’t have to keep a live connection to “listen” to the events.

We’ll announce when this feature gets released.

2 Likes

Thanks Alan for this long answer!
Webhooks sounds exactly what we need. Ideally it would pass the commit json to the API url.
Keep us posted when it is ready.

2 Likes