Skip to main content

How to Automatically Add Zoho Leads as Contacts in Wati

Updated this week

Summary

Want to add new leads from Zoho into Wati instantly? This guide will walk you through setting up automation in Zoho using Workflow Rules and a custom function. Once set up, any lead coming from sources like Facebook Leads or Instagram Ads will be automatically added as a contact in your Wati account.

Instructions

Prerequisites

  • You must have the Zoho Professional Plan (or higher).

  • You need access to your Wati API Endpoint and Bearer Token.

Steps to Set Up Zoho Workflow Automation

Follow these steps to create a workflow that sends new leads from Zoho to Wati automatically.

1. Navigate to Workflow Rules in Zoho

  • In your Zoho account, go to Settings > Workflow Rules.

  • Click Create Rule.

2. Configure the Workflow Rule

  • Select Lead as the module.

  • Name your rule (for example: Add Lead to Wati).

  • Set the Trigger and Conditions based on your preference (e.g., On Lead Creation).

3. Add an Instant Action - Function

  • Under Instant Actions, choose Function.

  • Click + New Function and select Write your own.

4. Define the Function Details

  • Fill in the details for your new function (such as function name and description).

  • Click Edit Arguments.

Add the following arguments exactly as shown:

Argument Name

Data Type

number

Text

LeadName

Text

Note:

  • Type # to select parameter values when mapping Zoho fields.

  • Do not change the argument names. They must be exactly the number and LeadName.

  • You only need the lead's phone number and name to add them as a contact in Wati.

5. Add the Function Code

Copy and paste the code below into the function body:

headerValue = Map(); headerValue.put("Authorization","####{{your-access-token}}");

raw_data = {"name": ""+ LeadName +"","customParams": []};

number = number.remove(" "); number = number.remove("+"); number = number.remove("("); number = number.remove(")"); number = number.remove("-");

resp = invokeurl
[
url :"####{{your-wati-api-endpoint}}/api/v1/addContact/91" + number + "?SourceType=ZOHO" type :POST parameters:raw_data.toText() headers:headerValue detailed:true content-type:"application/json"
];

info resp;

Important:

  • Replace {{your-access-token}} with your Wati Bearer Token.

  • Replace {{your-wati-api-endpoint}} with your Wati API Endpoint.

  • Update the country code (91 in the example) to your desired country code in this line:

url :"{{your-wati-api-endpoint}}/api/v1/addContact/91" + number + "?SourceType=ZOHO"

6. Save Everything

  • Save the function.

  • Save the workflow rule.

Frequently Asked Questions (FAQs)

General Questions

1. What is the purpose of setting up this Zoho Workflow?

→ This workflow automatically adds new leads from your Zoho account into Wati as contacts. It helps you sync leads coming from sources like Facebook Leads or Instagram Ads directly into Wati without manual effort.

2. What Zoho plan do I need to use this feature?

→ You need to have the Zoho Professional Plan or a higher plan to create Workflow Rules and use custom functions.

3. Where can I find my Wati API Endpoint and Bearer Token?

→ You can find detailed instructions on how to get your API Endpoint and Bearer Token in our guide: [How to find your API Endpoint and Bearer Token in Wati].

Setup and Configuration

4. Which Zoho module should I select when creating the workflow rule?

→ You should select the Lead module when creating the Workflow Rule.

5. What arguments do I need to add when defining the function?

→ You must add these arguments exactly:

  • number (Data Type: Text)

  • LeadName (Data Type: Text)

Do not change the names of these arguments.

6. How do I map Zoho lead fields to the function arguments?

→ When setting up arguments, type # to select the corresponding Zoho lead fields for phone number and lead name.

7. Why is the phone number being modified in the function code?

→ The function removes spaces, special characters, and symbols like +, (, ) and - from the phone number to ensure it is formatted correctly before sending it to Wati.

Function Code and API Usage

8. What do I need to replace in the function code?

→ You must replace the following placeholders in the code:

  • ####{{your-access-token}} → Replace with your Wati Bearer Token.

  • ####{{your-wati-api-endpoint}} → Replace with your Wati API Endpoint.

  • 91 (Country Code) → Update with your desired country code.

9. Can I add custom parameters while adding contacts to Wati?

→ Yes, but in this guide, the customParams array is left empty. You can customize it as needed by adding key-value pairs within the array.

10. What happens after the function runs?

→ Once the function runs successfully, the lead's name and phone number are sent to Wati and added as a new contact. The response is captured using info resp; for logging and troubleshooting purposes.

Troubleshooting

11. What should I do if new leads are not getting added to Wati?

→ Check the following:

  • Ensure your Zoho Professional Plan is active.

  • Verify that the Bearer Token and API Endpoint in your function code are correct.

  • Confirm that the country code is properly set in the API URL.

  • Ensure the lead has a valid phone number.

Did this answer your question?