How To Capture New Contacts On ZOHO CRM From WATI

How To Capture New Contacts On ZOHO CRM From WATI

This article will outline how to use Zoho CRM to capture new contacts from WATI. You can now use existing workflows on Zoho CRM for all new leads from WATI as well.

 

Heads up – this could take more than 30 minutes to complete.

 

Capture all new contacts on Zoho CRM for Free

Step 1: Create the following accounts/ files:

  • Zoho CRM (Free Edition)
  • Autocode (Free Edition) – we will use Autocode as an intermediary between WATI and Zoho
  • Get started with a Blank project
  • Make a copy of this Google Spreadsheet, in your google account

Step 2: Create an app within Zoho Desk.

  • Go to Zoho API Console
  • Click on ADD CLIENT

    n9jizQOKBeHMQ1TCEzkLneHu248nTtOlNnvo59fWTljigqFNvEbgLV5

  • Click on Self Client
  • Enter Scope as ZohoCRM.modules.ALL
  • Select a limit of 10 minutes (the default is 3 minutes)
  • Type anything under Description
  • Select your Production account
  • Press Create
  • From the pop-up that appears, copy the code

You have now created a Zoho App, and you have the following details:

  • Code
  • Client ID
  • Client Secret

Step 3: Go to this Postman link and create a fork

Note: You may need to create a Postman account before getting started.

  • Under Collections, click on Get tokens, and select the post request below.
  • In the window (on the right), select Params, and fill in the details that you received in Step 2.Te ia4kYNdUKW61SWMPYXQJXBp00ZQpYVgJARnSiwsaUioqTDdEp9UeSduP lm7lmD4DXlM1ns3Ys6uzI7NBfUShA7wWYd9LCdTUSJonfSVBklxZY wdkeFs7AnMC0DI11fSTEbY
  • Fill all 3 – client_id, client_secret and code.
  • Click on Send.

You will receive two tokens in the response – an authorization token and a refresh token.

  • Open up the Google Spreadsheet (the copy) and save the tokens as follows:
  • Authorisation token in cell H2, and refresh token in cell I2.

Step 4: Now, onto Autocode:

  • Gather data from Zoho Desk.
  • Organization ID: Settings > API > OrgId
  • Department ID: Settings > Departments > Choose the Department.
  • The ID is the number in the browser URL.

Open your Blank project on Autocode.

(sample window is added below)

  •  Delete all the code that is present in the windownyc6p SUa4pAKVGE2Z6Nz5ZqqJ L8sMEAVNxybfOtX8YaMmn7y2ol3DxnJ JHSnZQpC6jj0I Z6HInke0nvN4WEo1zJjL7uLB25qhWzTlRj dpTkYshh2wggEknlsfK4nCv9CdXL
  • Copy and paste the code below (add necessary data gathered above.

				
					 
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
 
let tokencheck = await lib.googlesheets.query['@0.3.0'].select({
   range: `H1:I2`, // required
   bounds: 'FIRST_EMPTY_ROW',
});
console.log(tokencheck)
 
let token = tokencheck.rows[0].fields.Token
console.log(token)
 
if(tokencheck.rows[0].fields.Token=="")
{
  let newtoken = await lib.http.request['@1.1.6']
  ({
       method: 'POST',
       url: `https://accounts.zoho.in/oauth/v2/token`,
       queryParams:
       {
         'refresh_token':tokencheck.rows[0].fields.Refresh,
         'client_id': `<client ID>`,
         'client_secret': `<client secret>`,
         'grant_type':`refresh_token`
       }
  });
  console.log(newtoken)
  
  token = JSON.parse(newtoken.body.toString()).access_token
  
  let tokenreplace = await lib.googlesheets.query['@0.3.0'].update
  ({
       range: `H1:H2`,
       bounds: 'FULL_RANGE',
       limit: {
         'count': 1,
         'offset': 0
       },
       fields: {
         'Token':token}
  });
  console.log(tokenreplace)
}
 
let zohoresult = await lib.http.request['@1.1.6'].post
({
   url: `https://www.zohoapis.in/crm/v2/leads`,
   headers: {
   "scope": "ZohoCRM.modules.ALL",
   "authorization": "Zoho-oauthtoken "+token
   },
   params:
   {
       "data": [
           {
               "Last_Name": context.params.senderName,
               "Phone": context.params.waId
           }
       ]
   }
});
 
console.log(zohoresult)

				
			

After you do this, the window will prompt you to connect a resource.

Learn More: How To Capture WATI Chats As Tickets On Zoho Desk

Now, connect your Google Spreadsheet created in Step 1. Ensure you select the right sheet (within the spreadsheet).

 

Nh1KlX8YFjogPezzVFYmwUsDrw4P5TLH7FNsBUQAHqhn Uib Lcp2TJVtHIvVniUjGxR Bcd5gXmEh4L

Save the code. Now, copy the URL at the bottom of the window (as shown below).

 

Z1b9uC0d8z8t3qxH18V0Q6Jh9urxiVvIwz8TNK t8ltDgHH L03wFPlhOMKJyxfo tV i10lSEp849XhYGMhUJwVACiPusBpXAXJkVDLTdFLD2KQStggOXerAU2 C0 T48V8Kl98

Step 5: Open your WATI Dashboard, and go to Webhooks. Now, add the URL from Step 4 as a new.

 

Webhook. 

  • Enter the URL.
  • Select the Event as “New Contact Message”.
  • Select the Status as Enabled.

lhUzKHBAGviDsEIDCSp4nLqOZ961rPHT1dE8MO3QY3AlR1ovm3xIiThGtmuYmk cbSUwMlLbZ9qgFAQqvHkPo

Step 6: Open your Google Spreadsheet.

  • Go to Extensions > Apps Script.
  • Copy and paste this code under Code.gs

5eTgdM dcCGOe9Pxg90Rb KLdez8Un76yeqzyFV3J ez5LT8SWyJezi6Lig16zlA8ZigxZk

				
					function myFunction() {
 var read = SpreadsheetApp.getActive().getSheetByName('Sheet1').getRange('H2').setValue("")
}

				
			

Now, create a trigger to run this code every 30 minutes, and that should be it.

dPCFnAATJlXffS9z asznbbmeKpEc GuF5RAc1KfUQYvu1lyr0uhuM 81ohU651w zC3rEeDR9wrOgXGj82Z9Xchoax2EUA7Z6sasURd8WyD

If everything above went well, all your new contacts will show up on Zoho CRM. 

Share This Post
Share on facebook
Share on linkedin
Share on twitter
Share on email
More To Explore