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

      • Dark Mode - Font Colors Don't Work

        When editing a document in Dark Mode and selecting font colors, they don't show up on screen.  Viewing/editing the same document in Light Mode shows them just fine.
      • API to post drafts for social media

        I we want to post draft posts to our zoho social account and then approve and schedule them within Zoho social. is this possible with for example: https://apis.zoho.com/social/v2/post TIA Jon
      • How to show product cards in your chatbot

        Hey everyone, If you are using Guided Conversations to help customers find products, you have probably run into this problem: the bot gives customers a list of options, but they still have no idea which one to pick. There will be no images, no specs,
      • Changing settings for auto logoff

        I've noticed that when I haven't used Cliq for a while, I have to re-enter my password. That is really clumsy, especially if you have a complicated password. Because it won't be filled in automatically. Is there a way to change that behaviour? We are
      • How do you create invoices before sending them through Zoho Invoice?

        Hi everyone, I'm curious how other businesses handle their invoicing workflow before sending invoices through Zoho Invoice. Do you: Create invoices directly inside Zoho? Prepare them first in another invoice tool or template? Use Excel or Word before
      • ZML Error/Bug

        Hi, I would like to request for your help regarding this kind of behavior. Requested_Start_Time & End_Time - date-time fields https://......#Page:PH_Calendar_Page?reqDate=08-04-2026 https://......#Page:PH_Calendar_Page?reqDate=07-31-2026 https://....#Page:PH_Calendar_Page?reqDate=08-03-2026
      • Item with name in different languate

        Hello, is there a way to have an item with its name in different languages? For example: I sell an item in different markets and I'd like to have a Proposal and the Invoice with the Item Name in a specific language. Rino Bertolotto Zoho Specialist, STESA srl
      • Migration of emails from Yandex to Zoho

        I am trying to migrate an yandex mail account to zoho mail account. I am confused with all the related articles/informations in the net. Could someone please outline the process to do it, just thinking about me as a novice with limited knowledge or experience. A couple of questions from the knowledge gained. 1. I believe we have to delete the yandex current MX from the website records and add Zoho MX. What happens to the emails as we remove the mail exchange record. Yandex stops updating emails and
      • Auto-fill from logged-in user's profile for Name Fields in Subforms

        Hi, The Name field is great, but I see you can't tick the Initial Value option of "Auto-fill from logged-in user's profile" when it is on a Subform, why not? Thanks Dan
      • Calling a function within another function

        Hello there, I have just found out that you can simply call up functions in other functions, regardless of the department. You can't create functions with the same name twice, even though you are in a different department. If you try it, you don't get
      • 【続々公開】Zoholics Japan 2026 セッション情報を更新しました!

        ユーザーの皆さま、こんにちは! Zoholics Japan 2026のセッション情報を続々と公開しています! 今年は3つのトラックで、Zohoの最新情報やAI活用、製品アップデート、 活用事例など、多彩なセッションをお届けします。 現在公開中のセッション(一部) ・Zoho CRM 製品アップデート ・Zoho CRM Plus 製品アップデート ・Zoho Community セッション ・Zoho Desk セッション ・中堅・成長企業の人事DX ~AI時代に何から始めるべきか?~ ・Zoho
      • Zoho CRM Community Digest - July 2026 | Part 1

        Hello everyone, July is here! The first two weeks brought six CRM updates ranging from privacy-ready webforms to a significantly more powerful Layout Rules engine, two community wins worth a look (a dashboard workaround for spotting leads with no activities,
      • New Ways to Personalize, Organize, and Share Your Notes

        We're excited to introduce a new set of enhancements in Zoho Notebook that make your note-taking experience cleaner, more flexible, and easier to share. With this update, you can create notes that automatically adapt to your device theme, browse your
      • Zoho Commerce B2B

        Hello, I have signed up for a Zoho Commerce B2B product demo but it's not clear to me how the B2B experience would look for my customers, in a couple of ways. 1) Some of my customers are on terms and some pay upfront with credit card. How do I hide/show
      • Introducing spam detection for webforms: An additional layer of protection to keep your Zoho CRM clean and secure

        Greetings all, One of the most highly anticipated feature launches—Spam Detection in webforms—has finally arrived! Webforms are a vital tool for record generation, but they're also vulnerable to submissions from unauthenticated or malicious sources, which
      • Rich-text fields in Zoho CRM

        Moderation Update: During the initial release of Rich Text fields, it was supported only in the Enterprise and Ultimate editions. We have gradually extended Rich Text fields to all the paid editions of Zoho CRM. Hello everyone, We're thrilled to announce
      • Add Large Lists to Choice-Based Field Rules

        Hi, The new Large List is good, but you can't then use the Choice-Based Field Rules with it to limit the Group Choices or Choices? Thanks Dan
      • Email-Data Synchronization with Zoho Analytics

        Hello, Enterprise Support Community! We're excited to announce the availability of Email Data Synchronization with Zoho Analytics! This highly requested enhancement allows you to sync email data from Zoho CRM into Zoho Analytics, making it easier to analyze
      • Zoho - shopify sales order - invoicing

        we have integrated zoho with shopify. so now , when an order comes through shopify-it raises a sales order in zoho. And at this time- the inventory goes down in shopify, according to the sale. Then we manually convert the sales order to an invoice, and
      • Enable Replenishments Option not Available

        I'm looking to turn on the replenishment option in Zoho Inventory and I'm not finding settings for it in Zoho Books or Zoho Inventory. This is the tutorial I was following from Zoho. Is there a step I'm missing to have Replenishments be available in Zoho
      • Kiosk Page Refresh

        We have a Kiosk running from a button in contacts to update values and also add related lists, which works great, but when the kiosk is finished the page does not refresh to show the changes. Is there a way to force the contact to refresh/update when
      • [Solution] Analyze, Act and Automate with Drill Actions

        Insights create value only when they lead to action. Traditional dashboards excel at helping you understand what is happening, but acting on those insights often requires manual intervention leaving the dashboard, opening another application, finding
      • Building extensions #6: Handling modal boxes to enhance user experience

        In our previous post, we explored creating custom graphical user interfaces using widgets. In this post, we'll learn about enhancing user experience through modal boxes. What is a modal box, and where is it used? A modal box is essentially a widget interface
      • Improve User Onboarding in Zoho Projects with Zoho DAP

        Rolling out new processes or onboarding new users in the tool comes with a familiar challenge: the employees need guidance at the moment they are doing the work. Traditional training sessions and knowledge sharing often require users to leave the application.
      • Zoho Social API for generating draft posts from a third-party app ?

        Hello everyone, I hope you are all well. I have a question regarding Zoho Social. I am developing an application that generates social media posts, and I would like to be able to incorporate a feature that allows saving these posts as drafts in Zoho Social.
      • Your CRO data is now on your AI Assistant: PageSense is live on Zoho MCP

        Hello Everyone, We are excited to announce Zoho PageSense is now live on Zoho MCP servers. Here is what that means for you. Every answer about your website lives behind tons of data across different modules. Which test is winning. Where visitors bail.
      • Feature Enhancement Request – Bulk Download of Signed Documents in Zoho Sign

        Hi Team, We would like to request a Bulk Download feature for signed documents in Zoho Sign. Currently, Zoho Sign allows users to send documents in bulk using an Excel sheet, but there is no option to download the completed signed documents in bulk. Users
      • delete a user on Zoho Desk

        Kindly I Need help to delete a user on Zoho Desk but I deactivated but not deactivated with licenses so what can I Do?
      • Unable to open Attendance Regularization request, reason?

        Unable to open Attendance Regularization request.
      • What's New in Zoho Inventory | June 2026

        Hello users, June 2026 introduces a range of exciting enhancements to Zoho Inventory. With the full rollout of the Zoho Inventory Windows application, the launch of Terminal Payments, and new tracking combinations in Advanced Inventory Tracking, you can
      • Tax/Vat Number Field As Standard - Customer & Vendor

        Hello, when are you'll going to have the customer & vendor tax/vat number as a standard field under the relevant profile pages? I find it strange that after 6 years of using Zoho Inventory that I still have to use a custom field for a tax/vat number,
      • Zoho CRM - Feature Request - Conditional Lead Conversion

        Hi CRM team, My feature request is to allow admins to create some conversion logic in the Lead Conversion settings. It is a common case where we want to convert a Lead to a Commercial or Residential Deal layout. Layout rules are not ideal because the
      • Zoho CRM Approval Process based on Field Update

        Hello, In current structure, Zoho CRM send records to approval based on record creation and edit.  I think, it should be to set approval process trigger based on any field update in record. When the user update any field, the record can assign to approval
      • Free webinar: Automate signature workflows with Zoho Sign and Zoho WorkDrive

        Hi there! Are you still storing and managing physical paperwork before and after signing? This traditional method is bulky, costly, and impractical at scale. Attend our free webinar to learn how you can connect Zoho Sign, our digital signature app, with
      • Global Sets for Multi-Select pick lists

        When is this feature coming to Zoho CRM? It would be very useful now we have got used to having it for the normal pick lists.
      • Introducing the Zoho Projects Learning Space

        Every product has its learning curve, and sometimes having a guided path makes the learning experience smoother. With that goal, we introduce a dedicated learning space for Zoho Projects, a platform where you can explore lessons, learn at your own pace,
      • Leave request problem on mobile phones

        Hello, When any employee attempts to submit a leave request on an Android or iOS phone, the error shown in the attachment appears. How can we solve this problem?
      • [Webinar] Digitizing forms and form-based workflows

        Live webinar on August 13, 2026 | Time: 2 PM IST | 2 PM EDT Hi, Struggling with paper forms, manual data entry, disconnected approvals, and form data that never reaches the apps that need it? Join our live webinar to learn how Zoho Writer's fillable templates
      • Multi-currency and Products

        One of the main reasons I have gone down the Zoho route is because I need multi-currency support. However, I find that products can only be priced in the home currency, We sell to the US and UK. However, we maintain different price lists for each. There
      • Price Book in foreign currency

        We have many customers who buy in foreign currency (USD), where our base currency is our local currency (AUD). It would be normal (it is in Zoho Books, Zoho Inventory etc.) to assign a currency to a price book, but I cannot find this option in Zoho CRM
      • Next Page