Kaizen 264 - Using zoho-crm Skill to Write Functions

Kaizen 264 - Using zoho-crm Skill to Write Functions



Hello CRM wizards,

Welcome back to another week of Kaizen.

In our previous Kaizens, we explored how the zoho-crm skill can assist you across various Zoho CRM developer tools. This time, let us see how it can help you write Deluge Functions, from simple workflow automations to complex integrations with third-party services. 

Since Deluge is a Zoho's exclusive scripting language, let's put the skill to test with three use cases of increasing complexity. We'll start with a basic field update, move on to querying CRM data, and finally explore an integration with Zoho Books. 

If you are starting new with the skill, check out Kaizen #258 on Getting Started with zoho-crm skill for more information.

Case 1: Automating a Simple Field Update

Let's start with a straightforward use case. 

Prompt 

Quote/zoho-crm Whenver the Phone field of a lead is populated or updated, automatically copy its value to the Mobile field.

Response



The skill identifies the appropriate approach which is a function triggered by a workflow rule. It generates Deluge code and provides the steps needed to put the solution into action. This includes instructions for creating the workflow rule, configuring its trigger and mapping the function arguments to the relevant fields. 

As a result, you get more than just a code snippet. The skill also guides you through the CRM configuration needed to make the function work. 

Info
Watch all the videos till the end to see the generated code in action.

Case 2: Identifying and Updating Stale Leads Using COQL

Now that we have covered a basic automation, let's introduce a little more complexity. This time, we'll use COQL to query CRM records and update them based on specific conditions. 

Prompt

Quote/zoho-crm Identify stale leads in Zoho CRM that have had no meaningful activity for more than 30 days and update their custom Lead Health field to “Stale”.

Response



Notice how the skill asks for additional information when the initial prompt doesn't provide enough details to implement the solution. Once the requirements are clarified, it generates the function code to indentify stale leads and update their Lead Health field.

It also guides you through the setup required to run the function, including creating a connection with the appropriate OAuth scopes and configuring a schedule. Before running the function, it recommends verifying that the field names and other details in the generated code match your CRM setup. 

There's another useful detail to look out for, which is the error handling. The generated code includes a failure-handling path that sends an email to the logged-in user if it cannot update a lead's health status. This helps notify the user when something goes wrong, making troubleshooting easier. 

You can also explicitly mention error handling in your prompts, and the skill can incorporate it into the generated code.

Notes
The skill generated codes are available on our github for your reference. 

Case 3: Creating Zoho Books Invoices from Zoho CRM

Let us take things up a notch and explore a use case involving third-party APIs. 

Prompt

Quote
/zoho-crm Need to create an invoice in Zoho Books when a Deal in Zoho CRM is closed with a stage Closed Won and save the invoice ID from the API response in the Deal's Invoice custom field.

1. Fetch the Deal's Stage, Account ID
2. Make a Related Records call and find the associated Quotes ID
3. Fetch the line items from the Quotes
4. Using the account ID find the Zoho Books customer ID
5. Create an invoice with the customer ID and line items
6. Update the invoice ID in the deal's Invoice field

connection link name : books_oauth_connection
Books Org ID: 131786026

Response



In this scenario, the function integrates Zoho CRM with Zoho Books to automate invoice creation for closed-won deals. The workflow involves retrieving the relevant CRM details, identifying the corresponding customer in Zoho Books, and using the required information to create an invoice. 

Unlike the previous examples, much of the function's logic depends on the responses returned by earlier API calls. The function must process those responses extract the necessary details and pass them to subsequent API requests. 

For complex use cases, the more context you provide, the better the skill can tailor the solution to your requirements. Describing the expected code flow, the sequence of API calls and the data to be passed between them can help reduce the need for multiple iterations. 

You can also refer the skill to relevant third-party API documentation help pages when you need it to follow specific API requirements. 

Notes
Note

The key is to start with a clear requirement, provide additional context when needed, and review and test the generated code before deploying it. The skill can help with both the implementation and the steps required to configure the function in Zoho CRM. 
We hope you find this kaizen helpful.

Have questions or suggestions? Drop them in the comments or write to us at support@zohocrm.com.

On to Better Building!

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Idea
Previous Kaizen: Using Zoho CRM Skill to Build Widgets | Kaizen Collection: Home
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------