Triggering Workflow
Once you've published the workflow using your Engagespot Console, it can be trigger using the send notification API itself.
You just need to specify the workflow identifier
(which you can see on your dashboard).
- Node
- cURL
- Python
- PHP
- Ruby
const { EngagespotClient } = require('@engagespot/node');
const client = EngagespotClient({
apiKey: 'YOUR_ENGAGESPOT_API_KEY',
apiSecret: 'YOUR_ENGAGESPOT_API_SECRET',
dataRegion: 'us', // us or eu based on your workspace.
});
client.send({
notification: {
workflow: {
identifier: 'workflowIdentifier',
cancellationKey: 'yourUniqueCancellationKey',
},
},
data: {
key: 'value',
},
sendTo: {
recipients: ['your-users-unique-identifier'],
},
});
# API URL will change based on your workspace data region.
curl --location --request POST 'https://api.engagespot.co/v3/notifications' \
--header 'X-ENGAGESPOT-API-KEY: YOUR_ENGAGESPOT_API_KEY' \
--header 'X-ENGAGESPOT-API-SECRET: YOUR_ENGAGESPOT_API_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"notification": {
"workflow": {
"identifier": "workflowIdentifier",
"cancellationKey": "yourUniqueCancellationKey"
}
},
"data":{
"key": "value"
},
"sendTo": {
"recipients": [
"your-users-unique-identifier"
]
}
}'
from engagespot import Engagespot
client = Engagespot(api_key='YOUR_ENGAGESPOT_API_KEY', api_secret='YOUR_ENGAGESPOT_API_SECRET', data_region='us')
send_request = {
"notification": {
"workflow":{
"identifier": "workflowIdentifier",
"cancellationKey": "yourUniqueCancellationKey"
}
},
"data":{
"key": "value"
},
"sendTo":{
"recipients": ["your-users-unique-identifier"]
}
}
client.send(send_request)
use Engagespot\\EngagespotClient;
$engagespot = new EngagespotClient('ENGAGESPOT_API_KEY', 'ENGAGESPOT_SECRET_KEY');
$notificationData = [
'notification' => [
'workflow' => [
'identifier' =>'workflowIdentifier',
'cancellationKey': 'yourUniqueCancellationKey'
],
],
'data' => [
'key' => 'value'
],
'sendTo' => [
'recipients' => ['your-users-unique-identifier'],
],
];
$engagespot->send($notificationData);
engagespot = Engagespot.new(api_key: 'ENGAGESPOT_API_KEY', api_secret: 'ENGAGESPOT_SECRET_KEY')
send_request = {
notification:{
workflow: {
identifier: 'workflowIdentifier',
cancellationKey: 'yourUniqueCancellationKey'
},
},
data:{
key: 'value',
},
sendTo:{
recipients: ['your-users-unique-identifier']
}
}
engagespot.send(send_request)
info
You can pass data
payload along with workflow trigger to replace your template variables.
Inline identification of users
It is possible to create the users inline during a workflow trigger. Thus you can avoid creating the user beforehand. Read guide
Scheduling a workflow
You can schedule a workflow to be sent at a later time using the sendAt
field. Just make sure that the sendAt
field is a valid ISO 8601 date string.
const client = EngagespotClient({ apiKey, apiSecret, dataRegion: 'eu' });
const result = client.send({
notification: {
workflow: {
identifier: 'workflow_identifier',
},
},
sendTo: {
recipients: ['user-id'],
},
sendAt: new Date().toISOString(),
});