Table of Contents

How to send template message using Zoho CRM Workflow?

Helpdesk Updated by Helpdesk

Sending Messages automatically using Zoho CRM workflow

To use the Workflow feature, you need the Zoho Professional Plan or higher

In this guide, we will talk about how you can send WhatsApp Messages/Notifications automatically from Zoho CRM Workflow

​ In order to automate the process where a newly created lead will get a welcome template message from WATI:

  1. Navigate to Settings -> Workflow Rules
  2. Click Create Rule
  3. Choose Lead as a module and name your Webhook Rule.
  4. Set the when and condition fields as shown below
  1. Click "instant actions" and choose "webhook"
  2. Click "Function"
  3. On the next page, choose ‘Write your own function’
  1. Fill in details for creating a new function
  1. Edit Arguments of the function as follows

Note:

  • Type # to choose the param value
  • template_name will be the WATI template name
  1. Copy the below code into the function body
headerValue = Map();
headerValue.put("Authorization","{{your-bearer-token}}");
raw_data = {"template_name":"" + template_name + "","broadcast_name":"zoho_auto_" + template_name + "","parameters":"[{'name':'name', 'value': '" + name + "'}]"};
number = number.remove(" ");
number = number.remove("+");
number = number.remove("(");
number = number.remove(")");
number = number.remove("-");
resp = invokeurl
[
url :"{{your-wati-api-endpoint}}/api/v1/sendTemplateMessage/91" + number + "?SourceType=ZOHO"
type :POST
parameters:raw_data.toText()
headers:headerValue
detailed:true
content-type:"application/json"
];
info resp;
Important
You must replace {{your-bearer-token}} in line 2 and {{your-wati-api-endpoint}} in line 11 with your Bearer token and API Endpoints. Ref: Where can I find the API Endpoint URL and Bearer Token?
Please ensure updating the country code in line 11 after /api/v1/sendTemplateMessage/

In line 3, you must pass the values for all the variables used in the template in JSON format. For example, in the following newenquiry template we have two variables: {{customer_name}} and {{phone_number}}.

The values for these two variables must be passed in JSON format to line 3 as shown at the end of the below snippet:


raw_data = {"template_name":"" + template_name + "","broadcast_name":"zoho_auto_" + template_name + "","parameters":"[{'name':'customer_name', 'value': '" + name + "'},{'name':'phone_number', 'value': '" + number + "'};

If you're using Zoho Creator, the deluge script may have to be modified. Below is an example of a Zoho Creator Deluge Script -

void sendWhatsApp(string template_name, string phone, string name)
{
headerValue = Map();
headerValue.put("Authorization","{{your-api-token}}");
headerValue.put("Content-Type","application/json");
raw_data = {"template_name":template_name,"broadcast_name":template_name + "","parameters":"[{'name':'name', 'value': '" + name + "'},{'name':'shop_name', 'value': 'ABC'}]"};
resp = invokeurl
[
url :"{{your-wati-api-endpoint}}/api/v1/sendTemplateMessage/91" + phone + "?SourceType=ZOHO"
type :POST
parameters:raw_data.toString()
headers:headerValue
detailed:true
];
info resp;
}

(Optional) Function code snippet to update Contact Attribute in WATI from Zoho Deluge

raw_data_update_contact_attribute = {"customParams":{{'name':'email','value':email},{'name':'zoho_lead_id','value':lead_id}}};

resp = invokeurl
[
url :"{{your-wati-api-endpoint}}/api/v1/updateContactAttributes/" + number
type :POST
parameters:raw_data_update_contact_attribute.toText()
headers:headerValue
detailed:true
content-type:"application/json-patch+json"
];
  1. Save the function
  2. Save the workflow

How did we do?

Get Notifications for new messages on WATI on Zoho CRM

How to get Contact Attributes from WATI into Zoho CRM Leads/Contacts?

Contact