Skip to content

Workflows and events ​

Workflows send messages on a schedule or in response to what happens in your system. Build them on the canvas in the dashboard or as JSON (see Building workflows); start them from your code with the SDK.

Send an event ​

An event starts every published workflow whose trigger listens for that name. Name the contact with phone or contactId so the workflow knows who it is about.

ts
await msgine.events.send({
  name: 'order.shipped',
  phone: '+256701234567',
  payload: { orderId: 'A-1042', courier: 'SafeBoda' },
});
python
msgine.events.send(
    name="order.shipped",
    phone="+256701234567",
    payload={"orderId": "A-1042", "courier": "SafeBoda"},
)
go
client.Events.Send(ctx, msgine.SendEventParams{
	Name:    "order.shipped",
	Phone:   "+256701234567",
	Payload: map[string]any{"orderId": "A-1042", "courier": "SafeBoda"},
})

payload becomes trigger inside the workflow, so a message can say {{ trigger.orderId }}. A phone number that matches none of your contacts fails with not_found.

Start one workflow ​

ts
const run = await msgine.workflows.runs.start(workflowId, {
  phone: '+256701234567',
  input: { name: 'Amina', amount: 85000 },
});

const latest = await msgine.workflows.runs.get(run.id);
python
run = msgine.workflows.runs.start(workflow_id, phone="+256701234567", input={"name": "Amina", "amount": 85000})

latest = msgine.workflows.runs.get(run["id"])
go
run, err := client.Workflows.Runs.Start(ctx, workflowID, msgine.StartRunParams{
	Phone: "+256701234567",
	Input: map[string]any{"name": "Amina", "amount": 85000},
})

latest, err := client.Workflows.Runs.Get(ctx, run.ID)

Set sandbox to run the workflow without sending or charging anything.

Send to groups ​

A workflow with an audience trigger is sent by a launch, now or at a set time.

ts
const launch = await msgine.workflows.launches.create(workflowId, { at: '2026-12-24T08:00:00+03:00' });
await msgine.workflows.launches.cancel(launch.id);
python
launch = msgine.workflows.launches.create(workflow_id, at="2026-12-24T08:00:00+03:00")
msgine.workflows.launches.cancel(launch["id"])
go
launch, err := client.Workflows.Launches.Create(ctx, workflowID, msgine.LaunchParams{At: "2026-12-24T08:00:00+03:00"})
_, err = client.Workflows.Launches.Cancel(ctx, launch.ID)

Build and publish ​

workflows.create and workflows.update save a draft; drafts may be incomplete. workflows.validate lists problems without changing anything, and workflows.publish freezes the draft as a new version. Runs stay on the version they started with. pause, resume and archive change the workflow's state.

Workflows can call your own APIs with an HTTP step. Keep the tokens those calls need in workflows.secrets: values are encrypted, write-only, and readable only by the HTTP step as {{ secrets.NAME }}.

workflows.messagingPolicy holds your timezone, quiet hours and the daily cap of marketing messages per contact.

Released under the MIT License.