Morph.ai Help Center

            WhatsApp API

            Send WhatsApp Template Message

            WhatsApp provides their own templated message mechanism. Message templates are plain text messages that are individually approved by the WhatsApp team to ensure they do not violate the WhatsApp policies. Businesses must use templated messages when first reaching out to users or when sending a message 24hours after the last message from the user. This type of message is paid.

            Here’s an example:

            "Your order {{1}} for a total of {{2}} is confirmed. The expected delivery is {{3}}."

            Notice the {{1}} parameter that allows you to personalise the message being sent.

            Method POST

            Header

            Authorization: ACCESS TOKEN  
            Content-Type: application/json

            Body

            {
                "widgetId"           : "WIDGET_ID",
            "templateId"         : "TEMPLATE_ID",     "userId"             : "USER_ID
            "phoneNumber"        : "PHONE_NUMBER" "localizableParams"  : [ARRAY OF STRING PARAMETERS THAT YOU WANT TO REPLACE IN MESSAGE] }
            Both userId and phoneNumber should not be present at the same time. Either userId or phoneNumber should be sent.


            Property
            Description
            Required
            widgetId
            The widget id representing the id of the deployed webhook integration.
            Received from the Morph.ai platform.
            Y
            templateId
            Pre-approved message ID
            Y
            userId or phoneNumber
            Refer the customer via userId or his Phone Number
            Any one is required
            localizableParams
            Array of string parameters that you want to replace in message
            Optional


            Send or receive message by your own

            If you want to send or receive messages from your own platform without using Morph automation, you can do that by enabling the APIs. To enable the APIs, you can contact support.

            Send and Receive details are as below:

            Receive

            This endpoint can be used to send messages to a particular WhatsApp user. Create an API which should accept calls in the below format. Register the APIs with Support. Whenever a message is received from the customer, it will automatically be passed to your platform.

            Example payload that you'll receive

            Header : application/json

            Body

            {
                "userId": "USER_ID",
                "widgetId": "WIDGET_ID",
                "messages": [
                    {
                        "type": "statement",
                        "text": "Here is a sample response to user"
                    }
                ]
            }
                        
            Property
            Description
            Required
            widgetId
            The widget id representing the id of the deployed webhook integration.
            Y
            userId
            Customer ID or user's phone number
            Y


            Send

            This endpoint can be used to send messages to a particular WhatsApp user.

            Request

            URL: https://open-api.morph.ai/v1/message/send

            MethodPOST

            Header

            Authorization: ACCESS TOKEN  
            Content-Type: application/json
            
            Body

            {
                "userId": "USER_ID",
                "widgetId": "WIDGET_ID_HERE",
                "messages": [
                    {
                        "type": "statement",
                        "text": "Here is a sample response to user"
                    }
                ]
            }
            Property
            Description
            Required
            userId
            The user id of the user to whom you want to send the message to.
            This is also received along with the message to the webhook.
            Y
            widgetIdThe widget id representing the id of the deployed webhook integration.
            Received along with the message to the webhook
            Y
            messagesAn array containing message objectY

            Updated: 09 Jun 2019 11:47 PM
            Helpful?  
            Help us to make this article better
            0 0