Incoming Lead Email Intent Detection using Zia Assistant API in Zoho CRM

Incoming Lead Email Intent Detection using Zia Assistant API in Zoho CRM


Hello all! 
Welcome back to a fresh Kaizen week.
In this post, we will explore how Zia detects positive intent from incoming emails in the Leads module using the Zia Assistant API along with Workflow Rules and Custom Functions in Zoho CRM.

Use Case 

Problem

Sales teams often manage 1000+ leads in Zoho CRM. Sometimes, a lead sends an email showing clear buying interest such as:
  1. I want to buy your product.
  2. Please share pricing details.
  3. Can we schedule a demo?
These important emails can easily get buried among other emails and activities. As a result, sales representatives may respond after several days, and by that time, the lead may already move to a competitor. This leads to missed opportunities and revenue loss.

Solution

Using Workflow, Deluge, CRM Email APIs, and Zia Assistant API, incoming lead emails are automatically analyzed for purchase intent.

When a lead sends an email with strong buying interest:
  1. Workflow automatically triggers the custom function.
  2. The function fetches the latest incoming email.
  3. Zia Assistant analyzes the email intent and buying interest.
  4. If positive purchase intent is detected, CRM instantly performs multiple automated actions.
The system automatically:
  1. Marks the Lead as an Interested Lead.
  2. Creates a high-priority follow-up task.
  3. Adds a note to the lead record.
  4. Sends an alert email to the Lead owner.
  5. Sends an automatic acknowledgement reply to the Lead.


Result

Zero missed hot leads. Response time drops from days to minutes. Direct revenue protection, immediate follow-up for interested leads, and better customer engagement.

What sales teams need?

  1. Automatic monitoring of incoming lead emails.
  2. AI-based purchase intent detection instead of simple keyword matching.
  3. Automatic identification of hot leads.
  4. Immediate task creation for sales representatives.
  5. Instant alerts for faster follow-up.
  6. Automatic acknowledgement replies for better customer experience.
  7. Reduced chances of missing highly interested leads.


Prerequisites

1. Configure Mail Integration

Configure your mail with Zoho CRM. Without mail configuration, the workflow cannot detect incoming emails. Navigate to Setup → Channels → Email.
Configure one of the following:
  1. IMAP Integration
  2. POP Integration
  3. Zoho Mail Integration
  4. Microsoft 365 / Gmail Integration
Make sure:
  1. Incoming emails are synced successfully.
  2. Incoming emails are successfully appearing under the related Lead records in CRM.
  3. The sales representative mailbox is connected properly.

2. Enable Zia AI Configuration

Before using the Zia Assistant API inside the Deluge function, make sure that AI is enabled in Zoho CRM.
  1. To enable AI configuration, go to Setup → Zia → Models → Zoho Hosted LLM vendor. Note: In V8, only the Zoho Hosted LLM vendor is supported.

3. Connection 

Create a CRM connection with the required scopes. Navigate to Setup → Developer Space → Connections. Add the required OAuth scopes based on your use case.

Implementation steps

Step 1: Create Custom Fields

Navigate to Settings → Customization → Modules and Fields → Leads. Create the following custom fields for intent detection and automation.

Field Label

Field Type

Purpose

Hot Lead Flag

Checkbox

 Marks highly interested leads.

Email Intent

Picklist

 Stores detected intent such as Purchase Intent, General Inquiry, or Neutral.

Intent Detected Time

Date-Time

 Stores the last intent detection time.

Alert Sent

Checkbox

 Indicates whether an alert email was sent to the sales representative.

We will continue using the following existing Lead fields in this implementation:

    Existing Field

Purpose

Lead Status

 Updated to Interested when purchase intent is detected.

Rating

 Updated to Active for interested leads.

Owner

 Used to notify the assigned sales representative.

  

Step 2: Set up Zoho CRM Connection

  1. Go to Settings → Developer Space → Connections.
  2. Click Create Connection
  3. Select your services.
  4. Name the connection: zohocrm (used in this post)
  5. Add the required scopes
  6. Click Create and Connect
  7. Authorize the connection

Step 3: Create the Custom function

  1. Go to Settings → Developer Space → Functions
  2. Click Create Function
  3. Display Name: Detect Positive Lead Intent
  4. Function Name: detectPositiveLeadIntent
  5. Category: Automation
  6. Return Type: void
  7. Add Argument: leadId: Leads.Lead Id Type: int
  8. Click Save
See the complete code here.

Step 4: Configure the Workflow Rule

  1. Go to Settings → Automation → Workflow Rules
  2. Click Create Rule
  3. Configure:
    1. Module: Emails
    2. Rule Name: Detect Positive Lead Intent
    3. Description: (optional) Triggers when incoming email is received for a Lead.
  4. Click Next
  5. WHEN: Execute this workflow rule based on: Select Incoming email → is → Received
  6. Click Done
  7. CONDITION: 
  8. Would you like to set conditions for email fields? → No
  9. Apply this rule to → Lead
  10. Which Leads would you like to apply this rule to? → All Leads

8. Click Done
9. INSTANT ACTIONS:
  1. Click Function
  2. Select your function: Detect Positive Lead Intent
  3. Map the argument: leadId → Select Lead → Lead Id
10. Click Save.

What happens inside the custom function?

At this stage, the workflow setup is complete. Whenever an email is received, the workflow automatically triggers the custom function. Now, let’s see what happens inside the function.
Instead of explaining the code line by line, we will look at the overall flow and understand how the system works step by step. The snippets below highlight only the important logic used in each stage.

Step 1:  Fetch the Lead & Owner details

The function receives the leadId from the workflow trigger and immediately fetches the full Lead record. It extracts the lead's name, company, email address, and the record owner's name, email, and ID.

leadData = zoho.crm.getRecordById("Leads", leadIdLong);
leadName = leadData.get("Full_Name");
company  = leadData.get("Company");
leadEmail = leadData.get("Email");
owner     = leadData.get("Owner");
ownerName = owner.get("name");
ownerEmail = owner.get("email");   // Alert will be sent here
ownerId = owner.get("id"); // Task will be assigned here

If no owner email is found, the function stops immediately.

Stage 2:  Fetch the latest incoming email

Why analyze only the latest email?

In this post, we use the latest email to identify the lead's current buying intent and trigger immediate sales actions. Analyzing the most recent customer email is sufficient for real-time purchase intent detection and faster follow-up. You can further customize this logic based on your specific business requirements. The function calls the Get Emails of a Record API to retrieve all emails associated with the Lead record. It then loops through the emails and identifies the latest email sent by the Lead by comparing the sender's email address with the Lead's email address.

emailsResp = invokeurl [ url: ".../Leads/{id}/Emails" ... ]; // Loop — find latest email sent by the Lead 
if(senderEmail.toLowerCase() == leadEmail.toLowerCase()) 
isIncoming = true; 
latestIncomingEmail = email; // keep the most recent 
}
Once the latest incoming customer email is identified, the function makes the View Email API call using the email's message_id to fetch the complete email body. The retrieved email content is then sent to Zia for intent analysis.

Stage 3: Zia analyzes the email

The email subject and body are sent to the Zia Assistant API with a carefully crafted prompt that instructs Zia to detect genuine purchase intent.
The prompt instructs Zia to look for strong purchase intent signals such as pricing requests, demo requests, free trial requests, implementation discussions, contract negotiations, budget approvals, and other buying-related conversations. 
Based on the email content, Zia returns either YES or NO. A YES response indicates that the lead is actively evaluating or interested in purchasing the product, while a NO response indicates that no clear purchase intent was detected.


analysisPrompt = "You are an enterprise-grade B2B sales intent detection AI. Analyze the incoming lead email and determine whether the customer shows strong and genuine PURCHASE_INTENT. Strong purchase intent includes asking for pricing, quotation, demo, free trial, implementation, onboarding, integrations, contract discussion, deployment timelines, budget approval, commercial discussion, next steps, or clear evaluation of the product for business adoption. Ignore greetings, thank you emails, support requests, informational questions, casual discussions, or unrelated conversations. Respond ONLY with YES if the lead is highly likely to purchase or actively evaluate the product for buying decision. Otherwise respond ONLY with NO.\n\nSubject:" + emailSubject + "\n\nEmail Content: " + cleanBody;
ziaResponse = invokeurl [
    url: ".../zia/smart_prompt/assistant"
    type: POST
    parameters: requestPayload.toString()
    ...
];


Stage 4: Parse Zia's Response

The function extracts Zia's answer from the response and sets the decision flag:

aiResponse = ziaResponse.get("assistant").get("details").get("data");
aiResponse = aiResponse.trim().toUpperCase();
if(aiResponse.contains("YES"))
{
    hasPurchaseIntent = true;
}


Stage 5: Five actions triggered on Purchase Intent

If has PurchaseIntent is true, five actions fire in sequence:

i.Update lead fields:


updateMap.put("Hot_Lead_Flag", true);
updateMap.put("Lead_Status",   "Interested");
updateMap.put("Rating",        "Hot");
updateMap.put("Email_Intent",  "Purchase_Intent");
updateMap.put("Intent_Detected_Time", zoho.currenttime);


ii. Create a high-priority task assigned to the Owner:

taskMap.put("Subject",  "HOT LEAD: " + leadName + " wants to buy!");
taskMap.put("Priority", "High");
taskMap.put("Due_Date", zoho.currentdate);
taskMap.put("Owner", ownerId);


iii. Add a Note to the lead record:

noteMap.put("Note_Title",   "Zia: Purchase Intent Detected");
noteMap.put("Note_Content", "From: " + customerEmail +
"\nSubject: " + emailSubject +
 "\nKey content: " + noteContent);



iv. Send alert email to the record owner:

sendmail [
    from:    zoho.loginuserid
    to:      ownerEmail
    subject: "HOT LEAD ALERT: " + leadName + " wants to buy!"
    message: emailHtml   
];



v. Auto-reply to the lead:

sendmail [
    from:    zoho.loginuserid
    to:      leadEmail
    subject: "Thank you for your interest - We'll follow up shortly"
    message: autoReplyHtml
];


Note: The acknowledgement email is sent only when Zia detects purchase intent. No auto-reply is sent for general inquiries, informational emails, or emails without clear buying intent.

Output

1.Record owner receives an alert email for immediate follow-up:

Sending alert mail to the respective record owner

2. Customer receives an automatic acknowledgement reply:



Notes

  1. To achieve better purchase intent detection, use a clear and strong prompt in the Zia Assistant API.
  2. The accuracy of intent detection depends on how well the prompt defines the purchase intent signals.
  3. Zia analyzes the complete email context, not just specific keywords.
  4. Emails containing pricing requests, demo requests, quotation requests, onboarding discussions, implementation questions, or next-step discussions are more likely to be identified as strong purchase intent.
  5. General support questions, greetings, thank you emails, and informational discussions may not be classified as purchase intent.
  6. The quality of incoming email content directly impacts the intent analysis result.
  7. Make sure the sales representatives' emails are properly synced with Zoho CRM before triggering the workflow.
  8. For better results, avoid sending incomplete or empty email bodies to Zia Assistant API.
  9. Sometimes Zia Assistant may not detect intent perfectly, as the analysis is AI-based.
This automation converts incoming lead emails into actionable sales insights. Instead of manually checking hundreds of emails, Zia automatically detects purchase intent, identifies hot leads, creates follow-up tasks, updates CRM fields, and alerts the sales representative in real time.


We trust that this post meets your needs and is helpful. Let us know your thoughts in the comment section or reach out to us at support@zohocrm.com
Stay tuned for more insights in our upcoming Kaizen posts!

Cheers!!!


    • Sticky Posts

    • Kaizen #198: Using Client Script for Custom Validation in Blueprint

      Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Kaizen #226: Using ZRC in Client Script

      Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this
    • Kaizen #222 - Client Script Support for Notes Related List

      Hello everyone! Welcome to another week of Kaizen. The final Kaizen post of the year 2025 is here! With the new Client Script support for the Notes Related List, you can validate, enrich, and manage notes across modules. In this post, we’ll explore how
    • Kaizen #217 - Actions APIs : Tasks

      Welcome to another week of Kaizen! In last week's post we discussed Email Notifications APIs which act as the link between your Workflow automations and you. We have discussed how Zylker Cloud Services uses Email Notifications API in their custom dashboard.
    • Kaizen #216 - Actions APIs : Email Notifications

      Welcome to another week of Kaizen! For the last three weeks, we have been discussing Zylker's workflows. We successfully updated a dormant workflow, built a new one from the ground up and more. But our work is not finished—these automated processes are
    • Recent Topics

    • 'Pinned' notes feature of a pipeline record

      Hi team, Could you please implement a feature which will allow users to pin different notes so that they will appear at the very top of the notes tab in a pipeline record. Sometimes we have a wide range of notes on a record which means more important
    • Associate emails from both primary and secondary contacts to deal

      We need to associate emails from multiple contacts to a deal. Please advise how this can be achieved. At present, only emails from primary contacts can be associated. Thanks
    • Custom Button Creation from Layout Editor in Zoho CRM

      Hello All, Buttons in Zoho CRM act as triggers that perform a specific action when clicked. Zoho CRM includes a set of system buttons that help you carry out common actions with a single click. Beyond these, your organization can create custom buttons
    • #PitStop3: Share & Collect Payment using Zoho Invoice

      We have reached another milestone in our journey. Post #15 to #20 weren't just about sharing invoices, they were about building a payment workflow that works for you, your customers and your business. Here's a quick wrap of what we covered in this segment:
    • Suggestions for Improving the Deluge Development Experience

      Hello, I would like to share some ideas that could significantly improve the Deluge development experience, especially for partners and developers building larger solutions across the Zoho ecosystem. Some key areas that would add a lot of value: Deluge
    • Enhancement announcement: Mitigate mailbox clutter using the new field: "Sync emails from"

      Dear Customers, We hope you're well! We are here with a minor enhancement in email integration in Zoho CRM. Emails have become the primary mode of communication these days. Because of which mailboxes are getting overly cluttered day after day. To help
    • Zoho CRM Sandbox now supports integrations

      Hello everyone, We are now expanding Zoho CRM Sandbox to support integrations with other Zoho products. You can connect, configure, and validate the behavior of your integrated tools within a safe, isolated environment - testing end-to-end without touching
    • Building Toppings #8 - Using widgets to extend the Bigin UI

      Hello Biginners, In our previous forum post, we explored schedules and workflow functions and learned how to automate real-time and time-based actions inside a topping. In this post we'll look at how to embed custom UI components inside Bigin using widgets.
    • Tip #81 – Turn every session into a story with Session Highlights – 'Insider Insights'

      Hello Zoho Assist Community! Picture this: your team wraps up dozens of remote support sessions every week. Each one involved troubleshooting, tools, fixes, and back-and-forth with customers. But when it's time to review what actually happened across
    • Zoho CRM APIs

      Hello, I think as a developer, it is very important to have the ability to manage, develop, and execute functions directly from my local development environment (for example, VS Code). Zoho CRM should have a way to create, deploy, and manage functions
    • 🎙️ Ask The Experts: Get Your Bigin Questions Answered Live

      We've seen so many thoughtful questions from our #BiginnersClub community over the years. While we're always happy to help here, we're excited to introduce a new way for you to connect with us directly. Join us for Ask The Experts, a one-hour live fireside
    • Pricelists

      So we have them in books but I cannot find them in commerce?
    • Postcode problems

      So we were very pleased to see we could limit shipping with postcodes. Brilliant. Unfortunately we have discovered It does not seem fit for purpose. In the UK we write postcodes in various ways Examples BH217NL BH21 7NL Bh217nl bh217NL and many more ways
    • Certain items certain shipping

      Me again it would be helpful to have different shipping for different categories. Our example are salt. Delivery is free but have a minimum delivery. Pickup is cheaper so it has its own category- pickup.
    • Cookies Consent Management in Webforms

      Hello Everyone! We are excited to introduce Cookie Consent Management for webforms. Read on to learn more. Webforms are online forms embedded on websites that allow users to submit data and create records in Zoho CRM. These forms utilize cookies to track
    • Payment links in Bigin just got supercharged

      Greetings, We're happy to announce major enhancements to the Payments feature in Bigin. As you may already know, Bigin supports Payments integration, which enables you to create and send payment links directly from Bigin to your customers. It also allows
    • Disable Spam filter

      Hi Support Team, Please disable spam filter for https://desk.zoho.in/support/keboli. Some spam ticket ids: #102, #103, #104
    • I just signed up

      Hi, I have just signed up for the domain griffithcgenterprises.com. I would like to make two adjustments: If possible, I would prefer a 5 GB hosting/email plan instead of the current 10 GB option, as I believe that should be sufficient for my needs at
    • History tab stuck loading indefinitely on Android (v2.22.0)

      History tab stuck loading indefinitely on Android (v2.22.0) — server returns 500 on visitorhistoryviews Hi all, I'm running into an issue where the History tab in the SalesIQ Android app (v2.22.0) never loads — it just spins indefinitely. Screenshots
    • Não consigo enviar e receber e-mail

      Estou tendo problema de envio e recebimento de e-mail (meu e-mail é ands....lisi.com.br) Esta mensagem foi criada automaticamente pelo software de entrega de e-mails. Uma mensagem que você enviou não pôde ser entregue a um ou mais destinatários. Este
    • إلغاء الإشتراك

      أريد إلغاء الإشتراك نهائياً.
    • Opening two notes at once in the Mac app

      Just like the title says - I want two notes open the same time on my Mac Air. AI search seems to think I have the option to open one window, then click on a second one. But of course if one window is open I can't see the others. It also recommended using
    • Introducing the Employee Portal for internal job posting

      Employee referrals and internal applications are one of the most trusted hiring channels. But in many organizations, employees only hear about openings through messages, word of mouth, or after the role has already been open for a while. When employees
    • Department Customization Copy/Paste

      Hello! I love the new customization of the layouts, rules and templates! However, we have several "departments" that operate similar and as I'm updating either ticket layout or workflow rules, I'm finding that I have to do it in each department. I would
    • How do you import mail from Thunderbird into ZOHO mail

      Hi, We have Thunderbird on our Apple Macs and want to transfer the emails from this to our shiny new Zoho mail account. I know using Outlook on a PC you can zip the .eml files up and upload them into specific folders on your ZOHO mail account using this form: mail.zoho.com/mail/jsp/importFolder.jsp However as Thunderbird use mbox files I'm not sure how to do it. Can anyone let me know if they have migrated mail from Thunderbird to Zoho mail and how they did it. I have many folders and emails to transfer
    • How to Open .mbox file in Gmail with Attachments?

      Gmail offer users to backup INBOX folder in .mbox file format via Google Takeout Feature. Howver there is no such option to Restore Gmail MBOX. Thus I would like to suggest you to choose an alternate approach i.e. MBOX to Gmail Wizard. This utility will open .mbox file in Gmail with attachments.  Steps to open MBOX file in Gmail are; Run MBOX to Gmail Wizard Click Add File and add .mbox file. Enter your Gmail login credentials. Click Convert button. Finished! This is how you can open MBOX file in
    • Poor Zoho Support

      Been trying to reach support via telephone and email. The support has always been slow to respond but now its been two weeks without a return call. I have even sent them screen shots of the problem I've having with no results. Is anyone had the same problem.
    • Admin Logging in as another User

      How can a Super Admin login as another user. For example, I have a sales rep that is having issues with their Accounts and I want to view their Zoho Account with out having to do a GTM and sharing screens. Latest Update (27th April 2026): With the early
    • Desk Contact Name > split to First and Last name

      I am new to Zoho and while setting up the Desk and Help Center, I saw that new tickets created or submitted from the Help Center used the Contact Name field. This would create a new Contact but put the person's name in the Last Name field only. The First
    • SalesIQ operators will not receive any messages if customers do not answer the Pre-Chat questions in Flow Controls.

      Hi Zoho SalesIQ Team, I am reaching out to report a issue regarding the Brands > Flow Controls SalesIQ operators will not receive any messages if customers do not answer the Pre-Chat questions in Flow Controls and continue sending messages without completing
    • SalesIQ's Summer '26 Release: For The Moments That Matter

      Every customer journey is made up of moments. The moment someone discovers your business. The moment they need help. The moment you decide to reach out. The moment a simple chat turns into something more. And the moments that continue long after the conversation
    • Add Comprehensive Accessibility Features to Zoho Writer

      Hello Zoho Writer Team, We hope you are doing well. We would like to submit a feature request to enhance Zoho Writer with a full set of accessibility tools, similar to the accessibility options already available in the Zoho Desk agent interface. 🚧 Current
    • Copying a Document with its Citations

      When I copy a document that contains citations using File>Make a Copy from the document's menu the text copies but the citations do not (according to Google they should). Is this the correct way to make a complete copy of a document with its citations
    • Bing ads integration and tracking

      Hi, Is there any way to track Bing ads in the same way that we are able to track google adwords?  It is important for us to be able to determine the conversion rate of our Bing ads.  If this is not possible now, will this feature be added in the future?
    • #20 Your Business Shouldn't Stop Just Because You Do

      Imagine you are on a well-deserved vacation. Your clients are expecting invoices at the beginning of the month, recurring customers are due for billing, and payments are still coming in. Do you carry your laptop everywhere, hoping you don't miss a billing
    • Marketing Tip #26: Optimize product images for SEO

      Product images can do more than make your store look good. They can also help customers discover your products through search. Since search engines can’t "see" images, they rely on text signals to understand what an image is about. Two small actions make
    • Canva Integration

      Hello! As many marketing departments are streamlining their teams, many have begun utilizing Canva for all design mockups and approvals prior to its integration into Marketing automation software. While Zoho Social has this integration already accomplished,
    • Automation Series: Mandatory Time Logging Before Task Closure

      In a project, when users work on multiple tasks simultaneously, they track time in different ways, either by starting a timer or by adding a time log. Sometimes users may forget to add time, which can lead to discrepancies in the timesheet. When timesheets
    • Is there a way to show contact emails in the Account?

      I know I can see the emails I have sent and received on a Contact detail view, but I want to be able to see all the emails that have been sent and received between all an Accounts Contacts on the Account Detail view. That way when I see the Account detail
    • Zoho CRM gets a new email compose and lot more

      Dear Customers,  [UPDATE October 21, 2021: We have started opening these features to some of the customers already. And, it will be available to all the customers before November 2nd Week, 2021. Sorry for the delay caused]  [UPDATE February 21, 2022:
    • Next Page