Template campaigns are created using the UI on the platform but triggered later via the external API.
You can find API Triggered Campaigns on the Create Campaign page:
You can build these campaigns like any regular campaign:
Use the double curly braces syntax to add variables - {{variable_name}}:
Put the campaign live with the Review & Launch button like any other campaign. Then you will go to live campaigns where you will see your campaign listed:
The campaign ID is appended to the campaign and will be used when executing the campaign via API.
Triggering a Campaign Template via API
The execute API method is used to trigger template campaigns details below:
Execute
Used to trigger a template campaign, targeting it at specific users and adding variables if needed.
URL
/api/external/execute/campaign
Parameters
Parameter | Description |
---|---|
apptoken | Your App token |
id | Campaign id can be found appended to title in live campaigns section |
target | The list of targeted user ids: ["user1", "user2"] |
target_with_params | An alternative to 'target' parameter if you want to pass the values of any personalized params you have in your campaign template message: {"user1": {"fname":"Alex","balance":"100 EUR"}, "user2": {"fname":"John", "balance": "80 EUR"}} |
target_by | An optional parameter to specify the type of user identifier used in 'target' or 'target_with_params' fields. Available values are: - id (xtremepush device id - default value) - external_id (id set by client, typically CRM user id) - token (push token) |
time | An optional parameter to specify when to execute the campaign. It will be executed immediately if this param is omitted. You can use both date string and unix timestamp as a value. |
Other campaign params | Set any of the other campaign params as found here |
Example
Executing a campaign, targeting a single user by external ID and setting a number a variables in the campaign text.
curl -X POST -d '{"apptoken": "YOURAPPTOKEN", "id": "CAMPAIGNID", "target_with_params": {"crm-user-1": {"fname": "Alex", "balance": "100 EUR"}, "crm-user-2": {"fname": "John", "balance": "80 EUR"}}, "target_by": "external_id"}' https://external-api.xtremepush.com/api/external/execute/campaign
Example response from a successfully executed campaign:
{ "success":true, "code":200, }
Executing a campaign on a specific time:
curl -X POST -d '{"apptoken": "YOURAPPTOKEN", "id": "CAMPAIGNID", "target": ["user1", "user2"], "target_by": "external_id", "time": "2017-01-01 12:00 UTC"}' https://external-api.xtremepush.com/api/external/execute/campaign
You can use any of the regular campaign params to add content, segment users etc., for example you could add a payload like a deeplink to be used when the notification is opened:
curl -X POST -d '{"apptoken": "YOURAPPTOKEN", "id": "CAMPAIGNID", "target": [123456], "payload_add": [{"key": "URL_KEY", "value": "https://m.example.com/deeplink/123456"}]}' https://external-api.xtremepush.com/api/external/execute/campaign
Comments
0 comments
Article is closed for comments.