Triggers start a new session with the flow engine. They describe why the session is being started and provide parameters which can be accessed in expressions.
Is used when a session was triggered by a campaign event
{
"type": "campaign",
"flow": {
"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7",
"name": "Registration"
},
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"status": "active",
"created_on": "2018-01-01T12:00:00Z"
},
"triggered_on": "2000-01-01T00:00:00Z",
"event": {
"uuid": "34d16dbd-476d-4b77-bac3-9f3d597848cc",
"campaign": {
"uuid": "58e9b092-fe42-4173-876c-ff45a14a24fe",
"name": "New Mothers"
}
}
}
Is used when a session was triggered by a channel event
{
"type": "channel",
"flow": {
"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7",
"name": "Registration"
},
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"status": "active",
"created_on": "2018-01-01T12:00:00Z"
},
"triggered_on": "2000-01-01T00:00:00Z",
"event": {
"type": "new_conversation",
"channel": {
"uuid": "58e9b092-fe42-4173-876c-ff45a14a24fe",
"name": "Facebook"
}
}
}
Is used when another session triggered this run using a trigger_flow action.
{
"type": "flow_action",
"flow": {
"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
"name": "Collect Age"
},
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"status": "active",
"created_on": "2018-01-01T12:00:00Z"
},
"history": {
"parent_uuid": "a5b25fb0-75fd-4898-a34f-5ff14fc19078",
"ancestors": 3,
"ancestors_since_input": 1
},
"triggered_on": "2000-01-01T00:00:00Z",
"run_summary": {
"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
"flow": {
"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7",
"name": "Registration"
},
"contact": {
"uuid": "c59b0033-e748-4240-9d4c-e85eb6800151",
"name": "Bob",
"fields": {
"gender": {
"text": "Male"
}
},
"created_on": "2018-01-01T12:00:00.000000000-00:00"
},
"status": "active",
"results": {
"age": {
"result_name": "Age",
"value": "33",
"node": "cd2be8c4-59bc-453c-8777-dec9a80043b8",
"created_on": "2018-01-01T12:00:00.000000000-00:00"
}
}
}
}
Is used when a session was triggered manually by a user
{
"type": "manual",
"flow": {
"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7",
"name": "Registration"
},
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"status": "active",
"created_on": "2018-01-01T12:00:00Z"
},
"triggered_on": "2000-01-01T00:00:00Z",
"user": {
"email": "bob@nyaruka.com",
"name": "Bob"
},
"origin": "ui"
}
Is used when a session was triggered by a message being received by the caller
{
"type": "msg",
"flow": {
"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7",
"name": "Registration"
},
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"status": "active",
"created_on": "2018-01-01T12:00:00Z"
},
"triggered_on": "2000-01-01T00:00:00Z",
"msg": {
"uuid": "2d611e17-fb22-457f-b802-b8f7ec5cda5b",
"urn": "tel:+12065551212",
"channel": {
"uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf",
"name": "Twilio"
},
"text": "hi there",
"attachments": [
"https://s3.amazon.com/mybucket/attachment.jpg"
]
},
"keyword_match": {
"type": "first_word",
"keyword": "start"
}
}
Is used when a session was triggered by an optin or optout.
{
"type": "optin",
"flow": {
"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7",
"name": "Registration"
},
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"status": "active",
"created_on": "2018-01-01T12:00:00Z"
},
"triggered_on": "2000-01-01T00:00:00Z",
"event": {
"type": "started",
"optin": {
"uuid": "248be71d-78e9-4d71-a6c4-9981d369e5cb",
"name": "Joke Of The Day"
}
}
}
Is used when a session was triggered by a ticket event
{
"type": "ticket",
"flow": {
"uuid": "50c3706e-fedb-42c0-8eab-dda3335714b7",
"name": "Registration"
},
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"status": "active",
"created_on": "2018-01-01T12:00:00Z"
},
"triggered_on": "2000-01-01T00:00:00Z",
"event": {
"type": "closed",
"ticket": {
"uuid": "58e9b092-fe42-4173-876c-ff45a14a24fe",
"topic": {
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4",
"name": "Weather"
}
}
}
}
Resumes resume an existing session with the flow engine and describe why the session is being resumed.
Is used when a session is resumed after a number was dialed.
{
"type": "dial",
"resumed_on": "2021-01-20T12:18:30Z",
"dial": {
"status": "answered",
"duration": 15
}
}
Is used when a session is resumed with a new message from the contact
{
"type": "msg",
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"language": "fra",
"status": "active",
"created_on": "2018-01-01T12:00:00Z",
"fields": {
"gender": {
"text": "Male"
}
}
},
"resumed_on": "2000-01-01T00:00:00Z",
"msg": {
"uuid": "2d611e17-fb22-457f-b802-b8f7ec5cda5b",
"urn": "tel:+12065551212",
"channel": {
"uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf",
"name": "Twilio"
},
"text": "hi there",
"attachments": [
"https://s3.amazon.com/mybucket/attachment.jpg"
]
}
}
Is used when a session is resumed because the waiting run has expired
{
"type": "run_expiration",
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"language": "fra",
"status": "active",
"created_on": "2018-01-01T12:00:00Z",
"fields": {
"gender": {
"text": "Male"
}
}
},
"resumed_on": "2000-01-01T00:00:00Z"
}
Is used when a session is resumed because a wait has timed out
{
"type": "wait_timeout",
"contact": {
"uuid": "9f7ede93-4b16-4692-80ad-b7dc54a1cd81",
"name": "Bob",
"language": "fra",
"status": "active",
"created_on": "2018-01-01T12:00:00Z",
"fields": {
"gender": {
"text": "Male"
}
}
},
"resumed_on": "2000-01-01T00:00:00Z"
}
Events are the output of a flow run and represent instructions to the engine container on what actions should be taken due to the flow execution. All templates in events have been evaluated and can be used to create concrete messages, contact updates, emails etc by the container.
Events are created when airtime has been transferred to the contact.
{
"type": "airtime_transferred",
"created_on": "2006-01-02T15:04:05Z",
"transfer_uuid": "552cd7ee-ccba-404d-9692-c1fe3b8d57c5",
"external_id": "12345678",
"sender": "tel:4748",
"recipient": "tel:+1242563637",
"currency": "RWF",
"amount": 100,
"http_logs": [
{
"url": "https://dvs-api.dtone.com/v1/sync/transactions",
"request": "POST /v1/sync/transactions HTTP/1.1\r\n\r\n{}",
"response": "HTTP/1.1 200 OK\r\n\r\n{}",
"elapsed_ms": 123,
"retries": 0,
"status": "success",
"created_on": "2006-01-02T15:04:05Z"
}
]
}
Events are created when an action wants to send a message to other contacts.
{
"type": "broadcast_created",
"created_on": "2006-01-02T15:04:05Z",
"translations": {
"eng": {
"text": "hi, what's up",
"quick_replies": [
{
"text": "All good"
},
{
"text": "Got 99 problems"
}
]
},
"spa": {
"text": "Que pasa",
"quick_replies": [
{
"text": "Todo bien"
},
{
"text": "Tengo 99 problemas"
}
]
}
},
"base_language": "eng",
"contacts": [
{
"uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a",
"name": "Bob"
}
],
"urns": [
"tel:+12065551212"
]
}
Events are created when a custom field value of the contact has been changed. A null values indicates that the field value has been cleared.
{
"type": "contact_field_changed",
"created_on": "2006-01-02T15:04:05Z",
"field": {
"key": "gender",
"name": "Gender"
},
"value": {
"text": "Male"
}
}
Events are created when a contact is added or removed to/from one or more groups.
{
"type": "contact_groups_changed",
"created_on": "2006-01-02T15:04:05Z",
"groups_added": [
{
"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
"name": "Reporters"
}
],
"groups_removed": [
{
"uuid": "1e1ce1e1-9288-4504-869e-022d1003c72a",
"name": "Customers"
}
]
}
Events are created when the language of the contact has been changed.
{
"type": "contact_language_changed",
"created_on": "2006-01-02T15:04:05Z",
"language": "eng"
}
Events are created when the name of the contact has been changed.
{
"type": "contact_name_changed",
"created_on": "2006-01-02T15:04:05Z",
"name": "Bob Smith"
}
Events are generated when the resume has a contact with differences to the current session contact.
{
"type": "contact_refreshed",
"created_on": "2006-01-02T15:04:05Z",
"contact": {
"uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a",
"name": "Bob",
"urns": [
"tel:+11231234567"
]
}
}
Events are created when the status of the contact has been changed.
{
"type": "contact_timezone_changed",
"created_on": "2006-01-02T15:04:05Z",
"timezone": ""
}
Events are created when the timezone of the contact has been changed.
{
"type": "contact_timezone_changed",
"created_on": "2006-01-02T15:04:05Z",
"timezone": "Africa/Kigali"
}
Events are created when a contact’s URNs have changed.
{
"type": "contact_urns_changed",
"created_on": "2006-01-02T15:04:05Z",
"urns": [
"tel:+12345678900",
"twitter:bob"
]
}
Events are created when a session is resumed after waiting for a dial.
{
"type": "dial_ended",
"created_on": "2019-01-02T15:04:05Z",
"dial": {
"status": "answered",
"duration": 10
}
}
Events are created when a flow pauses waiting for an IVR dial to complete.
{
"type": "dial_wait",
"created_on": "2019-01-02T15:04:05Z",
"urn": "tel:+593979123456",
"dial_limit_seconds": 60,
"call_limit_seconds": 120,
"expires_on": "2022-02-02T13:27:30Z"
}
Events are created when an action has sent an email.
{
"type": "email_sent",
"created_on": "2006-01-02T15:04:05Z",
"to": [
"foo@bar.com"
],
"subject": "Your activation token",
"body": "Your activation token is AAFFKKEE"
}
Events are sent by the caller to tell the engine to update the session environment.
{
"type": "environment_refreshed",
"created_on": "2006-01-02T15:04:05Z",
"environment": {
"date_format": "YYYY-MM-DD",
"time_format": "hh:mm",
"timezone": "Africa/Kigali",
"allowed_languages": [
"eng",
"fra"
]
}
}
Events are created when an error occurs during flow execution.
{
"type": "error",
"created_on": "2006-01-02T15:04:05Z",
"text": "invalid date format: '12th of October'"
}
Events are created when an error occurs during flow execution which prevents continuation of the session.
{
"type": "failure",
"created_on": "2006-01-02T15:04:05Z",
"text": "unable to read flow"
}
Events are created when an action has entered a sub-flow.
{
"type": "flow_entered",
"created_on": "2006-01-02T15:04:05Z",
"flow": {
"uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a",
"name": "Registration"
},
"parent_run_uuid": "95eb96df-461b-4668-b168-727f8ceb13dd",
"terminal": false
}
Events are created when an action wants to add labels to the current input.
{
"type": "input_labels_added",
"created_on": "2006-01-02T15:04:05Z",
"input_uuid": "4aef4050-1895-4c80-999a-70368317a4f5",
"labels": [
{
"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
"name": "Spam"
}
]
}
Events are created when an action wants to send an IVR response to the current contact.
{
"type": "ivr_created",
"created_on": "2006-01-02T15:04:05Z",
"msg": {
"uuid": "2d611e17-fb22-457f-b802-b8f7ec5cda5b",
"urn": "tel:+12065551212",
"channel": {
"uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf",
"name": "Twilio"
},
"text": "hi there",
"attachments": [
"audio:https://s3.amazon.com/mybucket/attachment.m4a"
],
"locale": "eng-US"
}
}
Events are created when an LLM is called.
{
"type": "llm_called",
"created_on": "2006-01-02T15:04:05Z",
"llm": {
"uuid": "14115c03-b4c5-49e2-b9ac-390c43e9d7ce",
"name": "GPT-4"
},
"instructions": "Categorize the following text as Positive or Negative",
"input": "Please stop messaging me",
"output": "Positive",
"tokens_used": 567,
"elapsed_ms": 123
}
Events are created when an action wants to send a reply to the current contact.
{
"type": "msg_created",
"created_on": "2006-01-02T15:04:05Z",
"msg": {
"uuid": "2d611e17-fb22-457f-b802-b8f7ec5cda5b",
"urn": "tel:+12065551212",
"channel": {
"uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf",
"name": "Twilio"
},
"text": "hi there",
"attachments": [
"image/jpeg:https://s3.amazon.com/mybucket/attachment.jpg"
]
}
}
Events are sent by the caller to tell the engine that a message was received from the contact and that it should try to resume the session.
{
"type": "msg_received",
"created_on": "2006-01-02T15:04:05Z",
"msg": {
"uuid": "2d611e17-fb22-457f-b802-b8f7ec5cda5b",
"urn": "tel:+12065551212",
"channel": {
"uuid": "61602f3e-f603-4c70-8a8f-c477505bf4bf",
"name": "Twilio"
},
"text": "hi there",
"attachments": [
"https://s3.amazon.com/mybucket/attachment.jpg"
]
}
}
Events are created when a flow pauses waiting for a response from a contact. If a timeout is set, then the caller should resume the flow after the number of seconds in the timeout to resume it.
{
"type": "msg_wait",
"created_on": "2022-01-03T13:27:30Z",
"timeout_seconds": 300,
"expires_on": "2022-02-02T13:27:30Z",
"hint": {
"type": "image"
}
}
Events are created when an action has created an optin to be sent.
{
"type": "optin_requested",
"created_on": "2006-01-02T15:04:05Z",
"optin": {
"uuid": "248be71d-78e9-4d71-a6c4-9981d369e5cb",
"name": "Joke Of The Day"
},
"channel": {
"uuid": "4bb288a0-7fca-4da1-abe8-59a593aff648",
"name": "Facebook"
},
"urn": "tel:+12065551212"
}
Events are created when a resthook is called. The event contains the payload that will be sent to any subscribers of that resthook. Note that this event is created regardless of whether there any subscriberes for that resthook.
{
"type": "resthook_called",
"created_on": "2006-01-02T15:04:05Z",
"resthook": "success",
"payload": {
"contact:": {
"name": "Bob"
}
}
}
Events are sent by the caller to tell the engine that a run has expired.
{
"type": "run_expired",
"created_on": "2006-01-02T15:04:05Z",
"run_uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a"
}
Events are created when a run result is changed.
{
"type": "run_result_changed",
"created_on": "2006-01-02T15:04:05Z",
"name": "Gender",
"value": "m",
"category": "Male"
}
Events are created when an engine service is called.
{
"type": "service_called",
"created_on": "2006-01-02T15:04:05Z",
"service": "classifier",
"classifier": {
"uuid": "1c06c884-39dd-4ce4-ad9f-9a01cbe6c000",
"name": "Booking"
},
"http_logs": [
{
"url": "https://api.wit.ai/message?v=20200513&q=hello",
"request": "GET /message?v=20200513&q=hello HTTP/1.1",
"response": "HTTP/1.1 200 OK\r\n\r\n{\"intents\":[]}",
"elapsed_ms": 123,
"retries": 0,
"status": "success",
"created_on": "2006-01-02T15:04:05Z"
}
]
}
Events are created when an action wants to start other people in a flow.
{
"type": "session_triggered",
"created_on": "2006-01-02T15:04:05Z",
"flow": {
"uuid": "0e06f977-cbb7-475f-9d0b-a0c4aaec7f6a",
"name": "Registration"
},
"groups": [
{
"uuid": "8f8e2cae-3c8d-4dce-9c4b-19514437e427",
"name": "New contacts"
}
],
"exclusions": {},
"run_summary": {
"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d",
"flow": {
"uuid": "93c554a1-b90d-4892-b029-a2a87dec9b87",
"name": "Other Flow"
},
"contact": {
"uuid": "c59b0033-e748-4240-9d4c-e85eb6800151",
"name": "Bob",
"fields": {
"state": {
"value": "Azuay",
"created_on": "2000-01-01T00:00:00.000000000-00:00"
}
}
},
"results": {
"age": {
"name": "Age",
"value": "33",
"node_uuid": "cd2be8c4-59bc-453c-8777-dec9a80043b8",
"created_on": "2000-01-01T00:00:00.000000000-00:00"
}
}
},
"history": {
"parent_uuid": "55105da5-abb5-4690-b1f6-ec2e5762a561",
"ancestors": 3,
"ancestors_since_input": 1
}
}
Events are created when a new ticket is opened.
{
"type": "ticket_opened",
"created_on": "2006-01-02T15:04:05Z",
"ticket": {
"uuid": "2e677ae6-9b57-423c-b022-7950503eef35",
"topic": {
"uuid": "add17edf-0b6e-4311-bcd7-a64b2a459157",
"name": "Weather"
},
"assignee": {
"email": "bob@nyaruka.com",
"name": "Bob"
}
},
"note": "this is weird"
}
Events are sent by the caller when a wait has timed out - i.e. they are sent instead of the item that the wait was waiting for.
{
"type": "wait_timed_out",
"created_on": "2006-01-02T15:04:05Z"
}
Events are created for things like accessing deprecated context values.
{
"type": "warning",
"created_on": "2006-01-02T15:04:05Z",
"text": "deprecated context value accessed: legacy_extra"
}
Events are created when a webhook is called. The event contains the URL and the status of the response, as well as a full dump of the request and response.
{
"type": "webhook_called",
"created_on": "2006-01-02T15:04:05Z",
"url": "http://localhost:49998/?cmd=success",
"status_code": 200,
"request": "GET /?format=json HTTP/1.1",
"response": "HTTP/1.1 200 OK\r\n\r\n{\"ip\":\"190.154.48.130\"}",
"elapsed_ms": 123,
"retries": 0,
"status": "success"
}