Sending Messages
The api/cascade/schedule
method is used to send messages to WhatsApp and Viber channels.
If you have two WhatsApp templates registered with the same content, differing only in the Track clicks on link buttons parameter, we don’t recommend sending messages with such content via the API. Use your edna Pulse account to send.
Otherwise, we cannot guarantee the correct display of link button click statistics.
You cannot send a duplicate message within 20 minutes. Duplicate messages will be canceled.
Messages are sent through a cascade, a sequential distribution scenario in several channels. When registering a channel, a cascade is created automatically for it.
You can create a cascade of several channels in your personal edna Pulse account.
Cascade Operation Principles How to Create a CascadeYou can test sending messages to a test phone number using edna API for the WhatsApp channel without having to register your channel.
Testing WhatsApp Channel APICalling api/cascade/schedule
To call theapi/cascade/schedule
method, send a POST request to the URL https://app.edna.io/api/cascade/schedule
. The request is executed through the public API with API key authorization.
After executing the request, the program receives a task to send a message via cascade according to the parameters in the request body.
If the request is accepted, the server returns a response with the code 200
containing a JSON object with the request ID. In case of unsuccessful verification of the request, a response with an error code is returned.
Information about the result of sending a message is sent to the installed webhook.
Receiving Message StatusesIf the message is successfully sent, the status is returned as sent
, followed by delivered
, read
or undelivered
(depending on the channel). The status of the message failed
means that the message was processed with an error and not sent.
If the server doesn't return the status of the message, send a request to edna support.
Request Format
The request body contains a set of cascade parameters for which you want to send a message.
{
"requestId": "string",
"cascadeId": 0,
"subscriberFilter": {
"address": "string",
"type": "EDNA_ID"
},
"startTime": "2023-09-27T12:06:29Z",
"ttl": "PT1M",
"content": {
"whatsappContent": {
"contentType": "TEXT",
"text": "string",
"attachment": {
"url": "string",
"name": "string"
},
"location": {
"longitude": 0,
"latitude": 0,
"address": "string",
"name": "string"
},
"comment": "string",
"caption": "string",
"action": "string",
"header": {
"text": "string",
"imageUrl": "string",
"documentUrl": "string",
"documentName": "string",
"videoUrl": "string",
"videoName": "string"
},
"footer": {
"text": "string"
},
"keyboard": {
"rows": [
{
"buttons": [
{
"text": "string",
"url": "string",
"urlPostfix": "string",
"phone": "string",
"payload": "string",
"type": "PHONE",
"otpType": "COPY_CODE",
"color": "string",
"requestContact": true,
"requestLocation": true,
"autofillText": "string",
"packageName": "string",
"hash": "string",
"appId": 0,
"ownerId": 0
}
]
}
]
},
"listPicker": {
"button": "string",
"sections": [
{
"title": "string",
"items": [
{
"identifier": "string",
"title": "string",
"subtitle": "string"
}
]
}
]
},
"catalog": {
"id": "string",
"product": {
"id": "string"
},
"sections": [
{
"title": "string",
"products": [
{
"id": "string"
}
]
}
]
},
"order": {
"catalogId": "string",
"products": [
{
"id": "string",
"quantity": 0,
"price": 0,
"currency": "USD"
}
]
},
"messageMatcherId": 0
},
"viberContent": {
"contentType": "TEXT",
"text": "string",
"attachment": {
"url": "string",
"name": "string"
},
"location": {
"longitude": 0,
"latitude": 0,
"address": "string"
},
"comment": "string",
"caption": "string",
"action": "string",
"header": {
"text": "string",
"imageUrl": "string",
"documentUrl": "string",
"documentName": "string",
"videoUrl": "string",
"videoName": "string"
},
"footer": {
"text": "string"
},
"keyboard": {
"rows": [
{
"buttons": [
{
"text": "string",
"url": "string",
"urlPostfix": "string",
"phone": "string",
"payload": "string",
"type": "PHONE",
"otpType": "COPY_CODE",
"color": "string",
"requestContact": true,
"requestLocation": true,
"autofillText": "string",
"packageName": "string",
"hash": "string",
"appId": 0,
"ownerId": 0
}
]
}
]
}
}
}
}
Request Parameters
General Parameters
Parameter | Data type | Character | Description |
---|---|---|---|
requestId | string | Required | The message ID. It is generated by your system, after which the value must be passed to the request. The maximum string length is 256 characters. |
comment | string | Optional | The text comment in the message. The parameter value is displayed in the detailed report. |
cascadeId | string | Required | The cascade ID. When creating a channel, a cascade is automatically created to send messages through this channel. To find out the cascade ID, use the API method to get information about cascades (the id field). Receiving Cascade Information |
subscriberFilter | object | Required | The recipient of the message: ID in edna Pulse, the client's phone number, as well as other IDs for push messages. subscriberFilter includes the following parameters: - address — a value that depends on type ; - type — see the type parameter If type is PHONE , then address is the customer's phone number. |
address | string | Required | The value of the identifier of the specified type is type . |
type | string | Required | The type of the client's ID. Possible values are indicated in uppercase: - INSTAGRAM_ID — The customer's identifier in Instagram of 16 numeric characters. Facebook instantiates this identifier* when the customer interacts with the business' Instagram account for the first time. This value may be different and vary for the same Instagramclient. - FACEBOOK_ID is the ID of the client in Facebook. - DEVICE_APP_ID is the ID of the client's push device. - EDNA_ID is the client ID in the edna database, which is created automatically when creating a client in edna. It is displayed on the User edit page in the URL bar, for example: > 3314 in the https://app.edna.io/audience/3314/edit . - PHONE — The client's phone number in the format 37500000000 . - EMAIL - UTM - COOKIE_ID - TELEGRAM_ID - GOOGLE_ID - APPLE_ID - YANDEX_ID - EXT_USER_ID |
startTime | string | Optional | The date and time in ISO 8601 format (for example, `2024-07-01T00:00:00Z'), before which the message will not be sent. Used for delayed delivery. ISO 8601 - Convention |
content | object | Required | Contains the whatsappContent object. |
ttl | string | Optional | The time after which you need to proceed to the described step if the message was not delivered in the previous step. The time period is specified in the ISO 8601 format (for example, `PT1M'). ISO 8601 - Convention |
errorIfNotMatched | boolean | Optional | A deprecated parameter. It is used to enable the verification of the message template. If there are no matches, an error is returned. |
priority | string | Optional | Is used to indicate the priority of messages. Possible values: - DEFAULT — standard priority, equivalent to no additional priority settings; - LOW — low priority; - NORMAL — medium priority; - HIGH — high priority; - REALTIME — real-time delivery. |
whatsappContent
Parameters
Parameter | Data type | Character | Description |
---|---|---|---|
contentType | string | Required | The type of message content. Possible values are indicated in uppercase:- TEXT — text message;- IMAGE — image;- DOCUMENT — document attached to the message;- VIDEO — message containing a video;- AUDIO — a message containing sound;- LOCATION — a message with coordinates, address and description of the place. The coordinates are converted into a Google maps snapshot;- LIST_PICKER — WhatsApp interactive menu buttons;- AUTHENTICATION — a message with a one-time password and a copy button;- FLOW — a message containing WhatsApp Flows. WhatsApp Flows |
text | string | Required if contentType = TEXT , AUTHENTICATION or FLOW | - The text of the message if contentType = TEXT . - The text of the message in which Flow will be embedded if ContentType = FLOW . - One-time password if ContentType = AUTHENTICATION . |
flowId | integer | Required if ContentType = FLOW | The Flow ID that is assigned in WhatsApp Manager at the time Flow is created. |
screen | string | Optional | The ID of the screen that will be displayed first in Flow. |
caption | string | Required if ContentType = FLOW | The text of the button that starts Flow after clicking on it. |
action | string | Optional | The Flow interaction type.Possible values:- navigate — Flow does not make a request to the endpoint. The default value. - data_exchange — Flow makes a request to the endpoint. developers.facebook.com |
attachment | object | Required | Contains information about the attachment. If the attachment field is specified when sending a WhatsApp chat message, the text field is ignored and only the attachment is sent. |
attachment.url | string | Required if the attachment object is not empty | The link to the attachment is an image, file, video, or audio. |
attachment.name | string | Required | The name of the image, file, video or audio. The maximum length is 70 characters. |
header | object | Required | The message title. You can select one of the following header options: text, image, document. For the text header, you need to specify the header text itself, the header can contain one variable. The title itself is displayed in bold text before the message. For a multimedia header, you can specify a link to a document or an image. |
footer | string | Required | The signature. It is displayed under the message in a muted text color. |
location | object | Required | Contains geolocation information. Sending a geolocation message is only available as part of a 24-hour dialog. |
location.longitude | string | Required | Coordinates (longitude). The range of values is from -180 to 180. |
location.latitude | string | Required | Coordinates (latitude). The range of values is from -90 to 90. |
location.address | string | Optional | The address on the map. |
location.name | string | Optional | The name of the object whose address is being transmitted. |
header.text | string | Required for the text header | The header text. |
header.imageUrl | string | Required for the title is the image | A link to the image in the title. |
header.documentURL | string | Required for the document header | A link to the document in the header. |
header.documentName | string | Required for the document header | The document name in the header. It will be displayed to the recipient of the message. |
header.videoUrl | string | Required for the title is the video | A link to the video in the title. |
header.videoName | string | Required for the title is the video | The video title in the title. It will be displayed to the recipient of the message. |
buttons | object | Required | An array of objects, each of which defines a button. |
buttons.text | string | Required | The button text. The maximum length is 20 characters. |
buttons.url | string | Required for the button is the link | The URL that opens when the button is clicked. |
buttons.urlPostfix | string | Required if there is a dynamic link in the template or it is a non-zero | The dynamic part of the link of the button URL. |
buttons.phone | string | Required for the call button | The phone number that is dialed when the button is pressed. |
buttons.type | string | Required | The button type:- URL — opens the specified link;- PHONE — dials the specified phone number;- QUICK_REPLY — sends a ready response;- OTP — copies the one-time password. There can be either no more than three QUICK_REPLY buttons in one message, or no more than one for each of the URL and PHONE buttons. The QUICK_REPLY buttons cannot be in communication with other buttons. Possible options:- QUICK_REPLY - QUICK_REPLY QUICK_REPLY - QUICK_REPLY QUICK_REPLY QUICK_REPLY - URL - PHONE - URL of the PHONE button. |
buttons.otpType | boolean | Optional | The button type in the WhatsApp authorization message. Only for the WhatsApp authorization template message.Possible values:- COPY_CODE — copy the code; - ONE_TAP — auto-fill button. |
buttons.autofillText | string | Optional | The Auto-fill button text. Only for the auto-fill buttons in the WhatsApp authorization template message. The maximum number of characters is 25. |
buttons.packageName | string | Optional | The Android application package name in the WhatsApp authorization message. Only for the auto-fill buttons in the WhatsApp authorization template message. |
listPicker | object | Required | The item list object. It contains the button parameter and the sections object, which contains the section objects. |
listPicker.button | string | Required if the ListPicker object is not empty | The name of the button for the interactive list. |
listPicker.sections.title | string | Required if the ListPicker object is not empty | The header of the section with elements that is displayed to the user. |
listPicker.sections.items | array of objects | Optional | The list of item objects. |
listPicker.sections.items.title | string | Required if the ListPicker object is not empty | The end-to-end element ID for the entire message will be returned in the user's reply message. |
listPicker.sections.items.subtitle | string | Required if the ListPicker object is not empty | The subtitle of the element. The maximum length is 24 characters, including spaces. |
messageMatcherId | integer | Required if ContentType = AUTHENTICATION | The ID of the template for this authorization message. |
viberContent
Parameters
Parameter | Data type | Character | Description |
---|---|---|---|
contentType | string | Required | The type of message content. Possible values are indicated in uppercase:- TEXT — text message;- IMAGE — image;- DOCUMENT — document attached to the message;- VIDEO — message containing a video;- AUDIO — a message containing sound;- BUTTON — a button;- LIST_PICKER — buttons of the WhatsApp interactive menu;- LOCATION — a message with coordinates, address, and description of the location. The coordinates are converted to a Google maps snapshot. |
footer | object | Optional | The signature. It is displayed under the message in a muted text color. |
text | string | Optional | The message text. |
header | object | Optional | The message title. You can select one of the following header options: text, image, document. For the text header, you need to specify the header text itself, the header can contain one variable. The title itself is displayed in bold text before the message. For a multimedia header, you can specify a link to a document or an image. |
attachment | object | Optional | Contains information about the attachment. |
attachment.url | string | Required | A link to attachment: image, file, video or audio. |
attachment.name | string | Optional | The name of the image, file, video, or audio. The maximum length is 25 characters. |
location | object | Optional | Contains location information. |
location.longitude | string | Required | Coordinates (longitude). |
location.latitude | string | Required | Coordinates (latitude). |
location.address | string | Optional | The address on the map. |
caption | string | Optional | The button name. |
action | string | Optional | A link for the button. |
Quotation Marks in the Text
The quotation marks “
or ‘
must be separated by a \
in the message being sent.
An example of the correct formatting
"text": "Pablo! We are inviting you to our workshop \“Cooking with Tefal\” 11/25/2021 at 1 p.m. Don\'t miss this event! Give us a call: +7 (495) 100-00-00"
"text": "Pablo! We are inviting you to our workshop «Cooking with Tefal» on 11/25/2021 at 1 p.m. Don\'t miss this event! Give us a call: +7 (495) 100-00-00"
An example of the incorrect formatting
"text": "Pablo! We are inviting you to our workshop “Cooking with Tefal” on 11/25/2021 at 1 p.m. Don't miss this event! Give us a call: +7 (495) 100-80-00"
Formatting Text in WhatsApp
The option for formatting text in WhatsApp messages is enabled by default without the option to disable it.
Text selection | Example |
---|---|
_cursive_ | Italics |
*Bold* | Bold |
~Crossed out~ | |
`Monospaced` | Monospaced |
Response Format
In response to the request, a JSON object is returned containing the ID of the sent message and the status of its processing.
Parameter | Data type | Description |
---|---|---|
requestId | string | The ID of the message. This number was generated on your side. |
Types of Attachments
The sent attachments must meet the following requirements:
Attachment type | Supported format | Acceptable size |
---|---|---|
document | Any valid MIME type. | 100 MB |
image | image/jpeg, image/png. | 5 MB |
audio | audio/aac, audio/mp4, audio/amr, audio/mpeg, audio/ogg. Codec=opus (NWB) and ACC. | 16 MB |
video | video/mp4, video/3gpp. Only MPEG 4 and 3GPP formats with the H.264 codec (MPEG-4 Part 10) and AAC for audio are supported. | 16 MB |