Prerequisites
You can use the OneSignal API to send emails and other messages to your users. To do so, you need to gather the following information:
OneSignal API Key
For added security, when creating a key, add the following addresses to the IP allow list:34.76.99.39
34.78.60.61
34.79.38.46
35.195.102.66
Example: Sending an email using a template
To send an email using a template, you will need the Template ID form OneSignal. Once you have that, do the following steps:
In Coho AI, edit the Playbook you want to send the email from.
Create a new HTTP Action.
Fill in the following details (reference):
Method:
POST
URL:
https://api.onesignal.com/notifications
Headers:
{
"Authorization": "Key YOUR_API_KEY",
"Accept": "application/json",
"Content-Type": "application/json"
}JSON Payload:
{
"app_id": "YOUR_APP_ID",
"target_channel": "email",
"email_subject": "Welcome to Cat Facts!",
"template_id": "YOUR_TEMPLATE_ID",
"include_aliases": {
"external_id": [ "{{userId}}" ]
}
}