Apart from sending messages to users, workflows can be used to call webhooks and pass the list of profiles that have reached a given workflow step. This functionaliy makes it possible to leverage Releva’s powerful analytics and segmentation capabilities to trigger your own custom business logic.
Request Structure #
Releva will call your webhook for all profiles that have arrived at a given workflow step in batches of 50 profiles using the curl equivalent below. Releva will pass the shared secret key in an authorization header, and you can check the value of this header to authorize the request. If you return an HTTP status other than 2xx, we will retry the request up to 10 times with an exponential back-off.
curl -H 'Content-Type: application/json' -H 'Authorization: Bearer <secretKey>' -XPOST https://your-webhook-url -d'{
"source": {
"campaign": {
"id": 123,
"name": "<workflow name as seen in Releva admin panel>"
},
"segment": {
"id": 234,
"name": "<segment name as seen in Releva admin panel>"
},
"segmentRunId": "...",
"flowStepId": "...",
"batchNumber": 1
},
"profiles": [
{
"firstName": "John",
"lastName": "Smith",
"email": "john@example.com",
"phoneNumber": "+123456",
"tags": ["t1", "t2"],
"subscriptions": ["sub1", "sub2"],
"registeredAt": "2023-09-15T00:20:21.000Z",
"subscribedAt": "2023-09-15T00:20:21.000Z",
"webhookClick": <URL endpoint to generate webhook click event for this profile>,
"webhookOpen" <URL endpoint to generate webhook open event for this profile>
"custom": { "string": [{ "key": "foo", "values": ["bar"] }] }
}
],
"triggerEvent": {
"action": "yourCustomAction",
"actionClass": "yourCustomActionClass",
"custom": { "string": [{ "key": "foo", "values": ["bar"] }] },
"timestamp": "2023-09-15T00:20:21.000Z"
}
}'
Request Body #
Field | Type | Description |
---|---|---|
source | Object | This field contains information about the source of the webhook |
source.campaign.name | String | This is the name of the workflow which triggered this request (as seen in the Releva admin panel) |
source.campaign.id | Integer | This is the id of the workflow which triggered this request (as seen in the URL of the releva admin when you open the details page – <id>/details) |
source.segment.name | String | This is the id of the segment which is currenctly associated with the workflow which triggered this request (as seen in the Releva admin panel) |
source.segment.id | Integer | This is the id of the segment which is currenctly associated with the workflow which triggered this request (as seen in the URL of the releva admin when you open the details page – <id>/details) |
source.segmentRunId | String | This identifies a unique execution of the workflow and the corresponding cohort of profiles which entered the workflow during this execution. |
source.flowStepId | String | This identifies the step within the workflow where this execution was triggered. |
source.batchNumber | Integer | This is the batch number (zero-indexed) of this request in relation to all profiles that have reached the given workflow step as part of the given workflow execution. |
profiles[].firstName | String | NULL | First name |
profiles[].lastName | String | NULL | Last name |
profiles[].email | String | NULL | Email address |
profiles[].phoneNumber | String | NULL | Phone number (including country code) |
profiles[].tags | Array[String] | Tags associated with the profile |
profiles[].subscriptions | Array[String] | Subscriptions associated with the user |
profiles[].registeredAt | ISO-8601 String | NULL | Date of registration of the profile |
profiles[].subscribedAt | ISO-8601 String | NULL | Date of subscription for marketing |
profiles[].webhookOpen | String | This field is a URL endpoint used to generate and send analytics data for webhook open events associated with the profile. |
profiles[].webhookClick | String | This field is a URL endpoint used to generate and send analytics data for webhook click events associated with the profile. |
profiles[].custom | Object | Profile custom fields |
triggerEvent | Object | NULL | The event which triggered the workflow execution (if the webhook source was a triggered workflow, null otherwise) |
triggerEvent.action | String | Name of the trigger event |
triggerEvent.actionClass | String | NULL | Action class of the trigger event |
triggerEvent.custom | Object | Custom fields associated with the trigger event |
triggerEvent.timestamp | ISO-8601 String | The time when the trigger event occurred |