Triggered (Drip) Campaigns
Triggered (drip) Message Campaigns
Triggered campaigns aims to group similar messages sharing the same message template so that aggregated statistics for campaign can be tracked without overflow in message history.
Triggered campaigns works in 2 steps, first a triggered campaign should be created, then triggered campaign is sent by adding recipients.
To setup a triggered campaign one should make a post call to
POST https://api.cm.com/messages/v1/accounts/{accountId}/messages
Example request body is like follows;
{
"body": "Hi {{1}} this is a triggered campaign",
"channels": [
"SMS"
],
"ignoreUnsubscribes": true,
"name": "Trigger test",
"senders": [
"Trigger"
],
"status": "triggered"
}
You will get a response like follows
{
"id": "67606cee-b8a9-4d28-988b-db6e73b21c81", // => this is the triggered campaign id to use when adding recipients
"isStatsComplete": false,
"body": "Hi {{1}} this is a triggered campaign",
"channels": [
"SMS"
],
"ignoreUnsubscribes": false,
"name": " Trigger test ",
"recipients": [],
"senders": [
"Trigger"
],
"status": "triggered",
"createdAtUtc": "2019-10-15T07:27:04.3594636Z",
"createdBy": "87067157-09e6-4a8e-b2da-06bfc126a8cd",
"updatedAtUtc": "2019-10-15T07:27:02.0369763Z"
}
To add recipients we have to use our created campaigns trigger endpoint, we need to do a POST call to below endpoint with an array of recipients
https://api.cm.com/messages/v1/accounts/\{accountId\}/messages/\{triggeredCampaignId\}/trigger
Request should look like following
[
{
"msisdn": "+31627142592",
"data": {
"1": "John Doe"
}
}
]
You will get a HTTP 200 status with the number of added recipients
By default, if any recipient in the request is invalid, the whole request fails with a HTTP 400 (Exception.InvalidRecipient, "Message recipient is invalid") and nothing is sent. The response does not say which recipient is invalid.
To send to the valid recipients and skip the invalid ones instead, add the optional query parameter dropInvalidRecipients (boolean, default false):
https://api.cm.com/messages/v1/accounts/\{accountId\}/messages/\{triggeredCampaignId\}/trigger?dropInvalidRecipients=true
The response does not say which recipients were dropped. If none of the recipients is valid, the request fails with a HTTP 400 ("Message has no valid recipients").