Ready to send some cool messages?
The following example uses the API JSON format, feel free to checkout the API to integrate it easily in your project.
The API endpoint messages.send accepts an array of messages like this:
{
"messages": [{
"notification": "welcome",
"channel": "postmark-myproject",
"channelOptions": {
"openTracking": false
},
"template": "english-v1",
"templateData": {
"_verificationToken": "xxxxxx"
},
"contact": "123",
"contactProfile": {
"$set": {
"firstName": "John",
"lastName": "Doe",
"signupAt": "2016-06-17T04:42:25.922Z"
}
},
"contactCreatedAt": "2015-10-05T07:36:36.345Z",
"sendAt": "2016-06-20T05:36:59.285Z"
}]
}
As you can see on the above example, we are sending a notification welcome with the template english-v1, to the contact 123 on the channel postmark-myproject.
We store some data in the contactProfile, set the creation date of the contact with contactCreatedAt and schedule the message to be sent in the future with sendAt.
We also give a _verificationToken field to the templateData.
There is also a channelOptions field in the example, that takes an object to overwrite some settings. Feel free to check the available options from the channels documentation (in a channel doc: find the Available in column, with a "message" value).
Some of your templateData variables are very sensitive (resert password tokens...), and should never be accessible from the Notifuse API and UI. That's why you can prepend all sensitive template data with an undescore like this: _verificationToken.
This way, only channels can view the sensitive data when they receive the message.
It can be useful to create 2 versions of the same notification to compare the open/click rates and improve your messages.
When you send a message, you can append a * at the end of your templates key, and Notifuse will randomly choose a template that starts with the provided key.
Example: you have 2 templates "english-v1" & "english-v2", you can set the template key to english*