This article covers an API method for creating operator templates.
message-matchers Method
An operator template is created as a result of a completed request using the method-matchers
method. If the request is completed successfully, the server returns code 200
. If the request fails, the server returns a response with an error code.
URL
To create an operator template, send a POST request to the following URL address: https://app.edna.io/api/message-matchers
Request Format
A JSON object is passed in the request body with the following parameters.
{ "messageMatcher": { "name": "new_matcher", "channelType": "WHATSAPP", "language": "EN", "content": { "text": "Hello, thank you for choosing us." }, "category": "MARKETING", "type": "OPERATOR" }, "subjectIds": [ 2234 ] }
Parameter | Data type | Description |
messageMatcher | object | Object with the template data |
name | string | Template name |
channelType | string | Interaction channel type. Possible values: WHATSAPP , VIBER , SMS |
language | string | Template language |
content | object | Object with the template contents |
category | string | Template category. Compulsory field for WhatsApp templates. Should be one of the following: MARKETING, AUTHENTICATION, UTILITY. |
type | string | Template type. Possible values are: • OPERATOR – Operator template (a template that was registered with a service provider)• USER – User template (a template that was created by a user based on an operator template)Important! Currently, only the OPERATOR type is supported. |
subjectIds | integer | Array of identifiers of the subjects of the channels for which the template is being created. To retrieve the IDs, use the channel-profile method. |
textExampleParams | array of strings | Sample of values of parameters within the template text. |
headerExampleTextParam | string | Sample of parameter value in the temple header text (only 1 parameter allowed). |
headerExampleMediaUrl | string | Sample of media header (URL). |
urlTextExample | string | Sample of a link within the CTA-button (full URL). |
Template Examples
- WhatsApp HSM with parameters within text body
{ "messageMatcher": { "name": "new_matcher", "channelType": "WHATSAPP", "language": "EN", "content": { "header": { "text": "Your company {{1}}", "headerExampleTextParam": "edna" }, "text": "Hello, {{1}}! Thanks for choosing {{2}}", "textExampleParams": [ "David", "glory" ], "keyboard": { "rows": [ { "buttons": [ { "text": "Website", "buttonType": "URL", "url": "https://edna.io/{{1}}", "urlTextExample": "https://edna.io/test" }, { "text": "Call us", "buttonType": "PHONE", "phone": "+1900000000" } ] } ] }, "footer": { "text": "Thanks for interest" } }, "category": "MARKETING", "type": "OPERATOR" }, "subjectIds": [ 20526 ]
- WhatsApp HSM with buttons
{ "messageMatcher": { "name": "new_matcher", "channelType": "WHATSAPP", "language": "EN", "content": { "header": { "text": "your edna" }, "text": "Hello! Thanks for choosing us.", "keyboard": { "rows": [ { "buttons": [ { "text": "Yes", "buttonType": "QUICK_REPLY", "payload": "1" }, { "text": "No", "buttonType": "QUICK_REPLY", "payload": "2" }, { "text": "Do not know", "buttonType": "QUICK_REPLY", "payload": "3" } ] } ] } }, "category": "MARKETING", "type": "OPERATOR" }, "subjectIds": [ 20526 ] }
- Viber
{ "messageMatcher": { "name": "new_matcher", "channelType": "VIBER", "language": "EN", "content": { "text": "Hello, [\s\w]+, thank you for choosing us." }, "category": "MARKETING", "type": "OPERATOR" }, "subjectIds": [ 2234 ] }
- SMS
{ "messageMatcher": { "name": "new_matcher", "channelType": "SMS", "language": "EN", "content": { "text": "Hello, %w{1,10}, thank you for choosing us." }, "category": "MARKETING", "type": "OPERATOR", "createdAt": "2022-05-05T11:34:34.844Z", "updatedAt": "2022-05-05T11:34:34.844Z" }, "subjectIds": [ 2234 ] }
{{1}}
, [\s\w]+
, and %w{1,10}
are regular expressions, strings of characters instead of which you can use any value. Each service provider has their own rules and standards for using regular expressions. You can read more about them in the corresponding articles – SMS, Viber, WhatsApp.
Possible examples of messages that can be sent via API see here.
Response Format
A JSON object with the request execution code is returned as a response to the request.
Response Codes
- ok – The request has been completed successfully.
- must not be nul — missing category of WhatsApp template.
- message-matcher-category-invalid — invalid category for WhatsApp template. Should be one of the following: MARKETING, AUTHENTICATION, UTILITY.
- message-matcher.saving.bad-request – missing or invalid sample of dynamic button url.
- message-matcher-name-already-exists – template with the same name of content already exists.