Creating Operator Templates

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
    ]
}
ParameterData typeDescription
messageMatcherobjectObject with the template data
namestringTemplate name
channelTypestringInteraction channel type. Possible values: WHATSAPPVIBERSMS
languagestringTemplate language
contentobjectObject with the template contents
categorystringTemplate category. Compulsory field for WhatsApp templates. Should be one of the following: MARKETING, AUTHENTICATION, UTILITY.
typestringTemplate 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.
subjectIdsintegerArray of identifiers of the subjects of the channels for which the template is being created. To retrieve the IDs, use the channel-profile method.
textExampleParamsarray of stringsSample of values of parameters within the template text.
headerExampleTextParamstringSample of parameter value in the temple header text (only 1 parameter allowed).
headerExampleMediaUrlstringSample of media header (URL).
urlTextExamplestringSample 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 – SMSViberWhatsApp.

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.
Next Article Receiving Template Registration Status