Cancelling Workflows
Cancelling workflows allows you to stop a running workflow to prevents it from continuing to send messages to recipients. This is crucial in cases like reminder workflows, where notifications should cease once a user has taken the desired action.
Only workflows with steps that can pause the run can be stopped mid-execution. Otherwise, Engagespot will immediately send out notifications. The steps that can pause a workflow include:
-
Delay: This function pauses the workflow for a set duration before moving to the next step.
-
Batch:Helps you to combine multiple notifications that are triggered in a short interval of time into one.
-
Wait for Input: This function pauses the workflow until specific input is received, facilitating interactive workflows that respond to user actions or system events.
-
Fetch: This step makes API requests to retrieve additional data necessary for the workflow, enhancing the workflow's ability to dynamically adapt based on real-time information.
Canceling a triggered workflow
To cancel a workflow, you must first include a cancellationKey
in the workflow trigger request. Engagespot uses this key to uniquely identify the specific workflow instance that should be canceled.
- Node
- cURL
const { EngagespotClient } = require('@engagespot/node');
const client = EngagespotClient({
apiKey: 'YOUR_ENGAGESPOT_API_KEY',
apiSecret: 'YOUR_ENGAGESPOT_API_SECRET',
});
client.workflows.cancelRun('yourWorkflowIdentifier', {
cancellationKey: 'YourUniqueCancellationKey',
cancelFor: {
recipients: ['user_one_identifier'],
},
});
curl --location --request POST 'https://api.engagespot.com/v4/workflows/:identifier/cancel-run' \
--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 '{
"cancellationKey": "yourUniqueCancellationKey",
"cancelFor": {
"recipients": [
"<your-users-unique-identifier>"
]
}
}'