π©Zoho
How to connect Dapta and Zoho CRM
Last updated
How to connect Dapta and Zoho CRM
Last updated
In order to build the Zoho Integration, there are a series of steps that need to be followed. For all Zoho API requests, we need to add an Authorization token as a header to each request for it to be executed correctly. Nevertheless, these tokens are not as easily generated and an important issue to keep in mind is that these tokens have a validity of one hour. Additionally, if the token is requested on repeated occasions too soon, the application will block the requests. Taking this into account, the process to correctly manage the Zoho integration is to connect to Zoho to get the access token and store it locally on a Database in order to get the information without requesting it at each iteration to Zoho. To complement this process, we need to have a functionality to refresh the token every hour, so that this token remains valid.
The steps to accomplish this are as follows:
Selecting the necessary scopes
Setting the scopes is really important because Zoho has limited access to their entities. Selecting the relevant scopes is then crucial so you can access the information you need. You can get this from the Zoho documentation. These scopes can be seen here: https://www.zoho.com/crm/developer/docs/api/v7/scopes.html
An example of scopes to be added is this list:
ZohoCRM.modules.leads.ALL,ZohoCRM.modules.deals.ALL,ZohoCRM.settings.ALL, ZohoCRM.modules.custom.ALL, zohobookings.data.CREATE
Generating the auth code
Once you have gotten all of the necessary scopes, you need to go to the API console by going to this site: https://api-console.zoho.com/
Once you have logged in, go to create a new self client
There are two important tabs here, the generate code tab and the client credentials tab. On the client credentials tab there is the very important client ID and client secret. You need to store this information to create the request.
You then need to go to the Generate Code tab, paste your selected scopes, set a duration and a description and create the code
A new screen will be shown and you will have you new code.
Generating the access and refresh tokens
To generate your access and refresh tokens you need to perform an API request. You can do this from an external platform like Postman, or you can do this directly from Dapta. If youβre going to do it from Dapta directly, you need to open a new flow and add an API node.
Once you have this set up, you need to go to the node and add the following information:
It need to be a POST method to the url: https://accounts.zoho.com/oauth/v2/token
Then make sure to add query params for all 5 variables that are on the example. grant_type needs to be βauthorization_codeβ and βredirect_uriβ can be a random URL. As for βclient_idβ and βclient_secretβ, you need to add the information from the Client Secret tab in the βGenerating the auth codeβ step. As for the βcodeβ variable, make sure you add the code generated on the last step.
WARNING: The validity of this code is VERY short. You set up that validity manually but it will last for a maximum of 10 minutes. So make sure you make this request under those 10 minutes.
This request will generate an access token and a refresh token. With this access token you can already perform requests via the API.
This allows you to search Leads by phone for example.
These are the ones we are going to be storing locally and set a method to refresh the token automatically and not depend on manually generating the token on each iteration.
Storing the tokens locally
Once you have the access and refresh tokens, we are going to proceed to store these tokens locally in Dapta so that we can access and refresh the tokens from the platform.
We need to go to the Data Studio section in the Dapta platform, and Data Sources. Make sure you create a new Data Source, and create a table.
Then, go to the tables section
Select the table and click on βNewβ and add the refresh token and access token obtained previously
This will store the information locally in Dapta. If we want to go further we can set the functionality to automatically refresh this token
Refreshing the token
Make sure you use the template flow βRefresh Zoho Tokenβ, connect your database and make sure to update these Client IDs and Secrets
This will automatically refresh every hour their access token and you should have no issues with performing requests if you always extract the access token from our internal database.