Send WhatsApp messages using Zoho CRM Webhooks

Send WhatsApp messages using Zoho CRM Webhooks

In Zoho CRM we can generate Webhooks to execute an API. In addition, these Webhooks can be used together with Workflow Rules to automate actions. In this article, we are going to see how to use Zoho CRM Webhooks and WOZTELL API to send WhatsApp messages. To do this we can follow these steps:

  1. Generate an Access Token
  2. Configure a Webhook
    1. Send Text message
    2. Send Template message

Generate an Access Token

The WOZTELL API needs an Access Token to verify the user's identity. Therefore, before starting to use our API we must generate a token. To do this we can use the platform documentation to generate a token.

Remember that the API for sending messages uses the Scopes: bot:sendResponses, bot:admin
Note that for the webhooks in Zoho CRM you must generate a SHORT Access Token

Click HERE to go directly to the article to generate the tokens.

Configure a Webhook

In Zoho CRM we can create a Webhook by following these steps:

1. Log in to your Zoho CRM account
2. Go to Settings

3. In the section AUTOMATION, click on ACTIONS

4. Click on the Webhooks tab.


5. Click on the Configure Webhook button

6. Give a name and a description to the Webhook

7. URLSelect as Method the value POST

8. In the URL to Notify we must put the URL of the API and the Access Token. It would look like this:


Remember to change {woztell-access-token} to the value of your token.


9. In the Authorization Type section, choose General

10. We must select the CRM module where we will configure this Webhook. In this example, Leads.


11. In the Header section we will not configure anything.


12. In the Body section, we will choose Raw as Type and JSON as Format.

13. After that, we will be able to paste the JSON file with the info we want to send on the textbox that appeared.

{
  "channelId": "{woztell-platform-channel-id}",
  "recipientId": "{whatsapp-phone}",
  "response": [
    {response-message-type}
  ]
}

Where the parameters will be the following ones:

channelId
The Channel ID is used to identify from which phone number will the message be sent. We can get the Channel ID following the steps explained in this ARTICLE.
recipientId
The recipientID refers to the phone number we want to send the message to. If we need to use a Zoho CRM field on the Webhook, we can type # so available fields are displayed. (I.e.: if we choose Mobile field on Leads module, Zoho CRM will add the text ${Leads.Mobile} and it will use the Mobile value when Webhook gets triggered).
response
On response we can add the message we want to send. As it is shown on Woztell's official documentation, there are some types of messages that can be sent out.



Sending text messages

After previous steps, to send text messages we must add the response parameter on a JSON with the format specified on the API documentation. In this case, the Webhook's RAW would be:

{
  "channelId": "{woztell-platform-channel-id}",
  "recipientId": "{whatsapp-phone}",
  "response": [
    {
      "type": "TEXT",
      "text": "Hello World!"
    }
  ]
}
The response parameter would be a JSON with the following values:

type
This value will always be TEXT
text
The message content we want to send out.





Sending template messages

After previous steps, to send template messages we must add the response parameter on a JSON with the format specified on the API documentation. In this case, the Webhook's RAW would be:

{
    "channelId": "{woztell-platform-channel-id}",
    "recipientId": "{whatsapp-phone}",
    "response": [
        {
            "type": "TEMPLATE",
            "elementName": "{whatsapp-template-name}",
            "languageCode": "{whatsapp-template-language}",
            "components": [
                {components-json-value}
            ]
        }
    ]
}

The response parameter would be a JSON with the following values:


type
This value will always be TEMPLATE
elementName
This is the unique name generated when the template is created. We can get this value from the channel in the platform or from the WhatsApp Manager on Facebook Business Manager.
languageCode
This is the template language. We can check the template languages from the channel in the Woztell platform or from the WhatsApp Manager on Facebook Business Manager. In addition, you can check the available languages in this article.
components
The template parameters will vary depending on whether the template has a header, images, audio, video, parameters, footer, and/or buttons. To do this, below we have prepared some steps to generate the JSON of the components field.

Generating template's JSON

You can easily get the JSON of a template from the platform to send it by API. To do this, just follow these steps:

1. Join Woztell platform.
2. Look for Resources and click on Responses.


3. Click on New Response to generate a new one.


4. As we want to create a new WhatsApp template, on the window displayed we can choose the different channel options available by clicking the tab on the left.


5. In this menu we will choose a WhatsApp Cloud platform using the Platform button.




6. Now, in the type of message we can select WhatsApp Template.


7. Then, in the template we choose the Integration which is the WABA in which we have the phone number and then we click on the Update Message Template button.


8. When pressing the button we must select the template (Message Template)


9. After choosing it, we leave the Language Policy option as Deterministic and select the desired language (Language).


10. Depending on the template, it will show the parameters that we must select. In our case, we have a parameter in the body and two buttons. We fill them with the desired values.


11. Once all the template data has been filled in, click on the Confirm button.
12. Now that the template has been filled, we can obtain the JSON parameters by clicking on Advanced.


13. In this new section we can see the complete JSON of the template, but we are only interested in the value of components, elementName and languageCode. We can copy the value of these parameters and paste them into our Zoho CRM Webhook. It would look like this with all the data:



{
  "channelId": "{woztell-platform-channel-id}",
  "recipientId": "{whatsapp-phone}",
  "response": [
    {
      "type": "TEMPLATE",
      "elementName": "{whatsapp-template-name}",
      "languageCode": "{whatsapp-template-language}",
      "components": [
        {
          "type": "body",
          "parameters": [
            {
              "type": "text",
              "text": "NAME"
            }
          ]
        },
        {
          "type": "button",
          "sub_type": "quick_reply",
          "index": "0",
          "parameters": [
            {
              "type": "payload",
              "payload": "YES"
            }
          ]
        },
        {
          "type": "button",
          "sub_type": "quick_reply",
          "index": "1",
          "parameters": [
            {
              "type": "payload",
              "payload": "NO"
            }
          ]
        }
      ]
    }
  ]
}

14. Finally, we can add the variables that we want in the components in the Zoho CRM's Webhook.


Once this is done, we can apply this webhook to a Workflow Rule on Zoho CRM.