user.created or invoice.paid. Your app emits it, and Nelkap does two things with it:
- It starts a run of every workflow that listens for the event.
- It wakes every run waiting on the event’s key.
user.created, without touching the sign-up code.
Listen for an event
List the events a workflow listens for when you register it:Emit an event
onboardUser and one of addToNewsletter, both with the payload user_42. emit returns their IDs, or an empty list if no workflow listens for the event.
An event takes:
event, its name, up to 256 characters.payload, if you want, any JSON value, passed to every run it starts.tags, if you want, up to 10 labels, given to every run it starts.wakeOn, if you want, the key of the runs it wakes.
order.shipped. A name says what happened, never which workflow should run, so the list of listeners can grow freely.
Wake waiting runs
A run can pause until an event arrives with a given key, usingstep.wait. To wake it, emit an event with wakeOn set to that key:
refund_ord_42 goes on, and its step.wait returns the event’s payload. The same event also starts the workflows listening for refund.reviewed, like any event.
An event only wakes the runs already waiting when it arrives. See Wait for an event for how to make sure the run is waiting first.
Emit from a workflow
A workflow can emit events too, for example to let other workflows know that an order shipped. Emit in a step, so the event goes out once, even when the run picks up again later:Events from other services
Services like a payment provider can’t callemit, but they can call a URL. A webhook gives you that URL, and turns each call into an event. See Webhooks.