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

      • Announcing the new SKILL.md for Zoho CRM and the updated OAS repository!

        We are introducing a new zoho-crm skill to make working with Zoho CRM Developer tools (like APIs, functions, widgets, client scripts, queries etc) easier and faster, with the help of AI in your preferred AI harness like Claude Code, Codex, Cursor, VSCode
      • Kaizen #256 - Build an Arrival Readiness Web Tab in Zoho CRM

        Hi everyone! Welcome back to the Kaizen series! In the post, we discuss a use case in hospitality industry: how an Arrival Readiness web tab widget can be used to let reception staff identify and resolve issues before arrival of guests. Use case In the
      • 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

        • Recent Topics

        • Customer User Fields for use in Rules

          Hi, I would like to be able to add custom fields to the users, such as Department or Role, which can then be used in Rules, Reports, etc. as a condition. A use case is limiting Global lists or Choices based on the users Custom Field, so one form can be
        • Locked out of MFA due to changing phones

          I have been locked out of my Zoho Books account since i changed my mobile phone over. I can get the OTP through the ZOHO Books software but i cant confirm using my phone app as nothing appears to authorise. I need to know how to register/set up my new
        • 👍 Zoho CRM's Notes now gets Reactions and a new look

          Available in SA and JP DCs. Rolling out to other DCs in phases. Hello everyone, Notes help users capture important updates, collaborate with teammates, and maintain context for records. Now with Note Reactions, users can quickly acknowledge updates, express
        • All new Address Field in Zoho CRM: maintain structured and accurate address inputs

          Availability Update: 29 September 2025: It's currently available for all new sign-ups and for existing Zoho CRM orgs which are in the Professional edition exclusively for IN DC users. 2 March 2026: Available to users in all DCs except US and EU DC. 24
        • Zoho books and venmo

          Hi, Is there a way to hook Venmo into zoho books? I have a Venmo business account and want to be able to sync that. I know you can do it with the paypal integration but I dont want to use paypal for the fees and that doesnt allow me use/integrate my current
        • Payroll needs to automatically remit taxes, not just give me the calculations

          Wagepoint, PayEvo, Waveapps, etc... All your competitors deposit employee payroll, but they ALSO remit taxes automatically. Get with the program, your Payroll app is extremely sparse.
        • Creating new Teams meeting from CRM doesn't enable Team functions in the meeting

          Hi I'm trying to set up the meeting integration and I've seen that when I create a Meeting in the CRM and set the location to Online and the Provider to Teams, and complete the boxes, add a participant etc, whilst the meeting is created in Teams, the
        • Approval Process configuration is now more flexible and fully customizable

          The Approval Process is back with an improved user experience designed to make it easier to build structured, flexible, and intuitive approval workflows. Here’s a look at some of the key enhancements: Name Your Rules & Stages You can now give each approval
        • Introducing Approval SLA for Approval Processes

          Approvals can sometimes be delayed when approvers do not respond within the expected timeframe, which can slow down your recruitment processes. With the new Approval SLA in Zoho Recruit, you can set deadlines for approval requests and define automated
        • Introducing Microsoft Word Integration in Zoho Contracts

          We are excited to announce a new feature that brings contract authoring and negotiation in your familiar environment — the Microsoft Word Integration. What This Integration Brings The Microsoft Word Integration connects Zoho Contracts with the Microsoft
        • Map My Client Locations for Zoho CRM Extension: Turn CRM Addresses Into Action

          Hello everyone, Your CRM knows who your customers are. Now, see where they are on the interactive map directly from Zoho CRM. Introducing Map My Client Locations for Zoho CRM, an extension built for businesses that rely on sales visits, field service,
        • Scheduled and Automated Report Delivery from Zoho Projects

          Zoho Projects has useful reports including task reports, timesheet summaries, and workload charts. However, there is currently no way to schedule these reports to be automatically delivered to stakeholders on a recurring basis. This means: Project managers
        • Collaborate Visually with Whiteboard in Zoho Projects

          Whiteboard in Zoho Projects allows you to collaborate visually by creating diagrams, annotating designs, and sketching project workflows using shapes, text, and images within project modules. Team members can work simultaneously, improving productivity
        • Fields in MS-Word Template

          With the new MS-Word integration, how does one create fields in an imported MS-Word document which can then automatically be populated with an Intake Form?
        • Zoho Bookings Flow Step not Triggering on Appointment booked

          I noticed yesterday that my appointment booked flows were not triggering when we had booked appointments in Zoho Bookings. I checked the trigger and noticed the trigger values updated to be defined to a workspace and service event rather than our whole
        • UCP: Why We Killed the Multi-Portal Mess and Simplified Customer Self-Service

          Let's talk about the multi-portal mess nobody wants to admit that it exists. Your customer needs an invoice from one app, wants a ticket update from another, and has a project waiting in a third, each behind its own login, its own UI, its own "was it
        • Zoho Tables is now available in Zoho One!

          Hello Zoho One users, We’re excited to announce that Zoho Tables is now included as a part of Zoho One suite! As teams grow, managing projects, approvals, inventories, campaign trackers, and operational workflows across multiple spreadsheets become difficult.
        • Zoho Publish is now available in Zoho One!

          Hello Zoho One users, We’re excited to announce that Zoho Publish is now included as part of the Zoho One suite! As businesses grow, managing Google Business Profiles across many locations becomes challenging. Business information needs to stay accurate,
        • 📣 Ask the team behind Zoho SalesIQ: Summer '26 Q&A

          Hi everyone! Following our recent webinars, Summer '26 Release: What's New in Zoho SalesIQ—where we walked you through all the new features, what they do, and how they work—and Driving the AI Evolution: Building Smarter Customer Experiences with Zoho
        • Upcoming update to field values in Zoho Books - Zoho Analytics integration

          Hello Users, We'd like to inform you of an upcoming update to the tax_category values in the Zoho Books integration for Zoho Analytics from October 20, 2026. What's Changing? tax_category field values are being renamed to align with the conventions already
        • Announcing the new SKILL.md for Zoho CRM and the updated OAS repository!

          We are introducing a new zoho-crm skill to make working with Zoho CRM Developer tools (like APIs, functions, widgets, client scripts, queries etc) easier and faster, with the help of AI in your preferred AI harness like Claude Code, Codex, Cursor, VSCode
        • Kaizen #259 - Working with Zoho CRM APIs using zoho-crm skill

          In the previous Kaizen, we introduced the zoho-crm skill and discussed how it can work with different CRM developer capabilities. The zoho-crm skill makes it easier to work with Zoho CRM without having to remember every API endpoint, request structure,
        • How can I populate dropdown data with information from another source or app?

          I want to maintain a list of items in another app (say in excel or another database) and sync those as items in a drop down menu, instead of copy pasting to import. Is this kind of a feature available?
        • Zoho Community Digest - September 2026 | Part 1

          Hi everyone, and welcome back! September opens with a strong set of updates. Zoho CRM brings workflow automation down to the subform row level and ships a new SKILL.md for AI-assisted development, Zoho Desk introduces conditional branching with Automation
        • Tip #88 – Manage Incoming Support Requests Efficiently with the Service Queue – 'Insider Insights'

          Hello Zoho Assist Community! Not every team has a dedicated IT department or a fully built-out sysadmin setup. For smaller teams, when something breaks, there's no internal ticket system to log into, no helpdesk queue to route through, and no clear way
        • Delete CRM Portal

          How do I delete portals from my CRM? I created one just to test, it is not in use and is disabled but it's existence is preventing me from marking fields in modules as "required" unless I make it 'read/write' in the portal first. I'd rather just delete
        • Zoho Books | Product updates | July 2026

          Hello users, We’re excited to bring you the latest updates in Zoho Books for July 2026! This month's release introduces Terminal Payments, CMP-08 filing for composition taxpayers, SEPA Credit Transfer support, and Self-Billed Credit Notes and Debit Notes
        • Calendar invites from Contacts not being assigned to Account in CRM

          Hi all It's that time of year again when I try to get calendar and meetings sorted in CRM. I have two way sync enabled. I have the option set to check for customer meeting invitation mail and to add them as meetings. However, whilst those meetings show
        • Kaizen #258 - Getting Started with zoho-crm SKILL.md

          Howdy tech wizards, Welcome to a fresh week of Kaizen. This week, we are taking a look at the zoho-crm SKILL.md, an Agent Skill designed to help AI coding agents work with Zoho CRM’s developer capabilities. What is zoho-crm SKILL.md? The zoho-crm skill
        • Zoho Tables is now live in Australia & New Zealand!

          Hey everyone! We’ve got some great news to share — Zoho Tables is now officially available in the Australian Data Center serving users across Australia and New Zealand regions! Yes, it took us a bit longer to get here, but this version of Zoho Tables
        • Dashboard/Component filter by probability

          Hi all Can I request the ability to add a Component or Dashboard filter for Deal Probability? Would be useful to be able to see data of deals more than 60% probable. Olly
        • Stock (on-hand) Items not updated after using Composite items

          Hi there, I created a Composite item (consist of 3 items). After I created the Composite item, I invoiced it and shipped the items. However the actual stock on hand of the 3items didn't change at all. Have you guys encountered this? Thank you Regards,
        • 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
        • Important changes for users with Zoho accounts in the UAE and other Data Centers

          What's changing? Previously, the same email address could be used to create separate Zoho accounts in both the UAE data center and another Zoho data center (such as US, EU, IN, AU, JP, CA, SA or SG). With this change, an email address can be associated
        • Conditional Layouts On Multi Select Field

          How we can use Conditional Layouts On Multi Select Field field? Please help. Moderation update: Multi-select picklist fields are now supported in Layout Rules. Additionally, Layout Rules is now available in the Professional Edition. These updates have
        • Zoho Marketing Automation WhatsApp Campaign Import Sync for Zoho Analytics

          WhatsApp is a critical channel in modern marketing, yet WhatsApp Campaign metrics from Zoho Marketing Automation currently cannot be natively imported into Zoho Analytics via the default advanced analytics connector. Integrating this into the standard
        • merge the Multiple POs to single PO if Vendor of PO"s --in Zoho Inventory

          HI Merge the Multiple POs to single PO if Vendor of PO"s are Same ----in Zoho inventory Please provide any work around to achive this .
        • Is there a CRM Deluge function available to convert an RTF (rich text field) to plain text (with no formatting tags)?

          I know that we can run reports so that RTF fields can either show as plain text or the text or the text with the formatting fields included (which is wonderful, btw, as it helps me adjust tags when I need to troubleshoot and just see what I need to see
        • 【Zoholics Japan 2026】ITreview 口コミ投稿キャンペーンを実施します!

          ユーザーの皆さま、こんにちは! 2026年9月25日(金)開催の「Zoholics Japan 2026」会場にて、 Zoho CRM・Zoho Workplace・Zoho Mail を対象とした「ITreview 口コミ投稿キャンペーン」を実施します! Zoholics にご来場いただく皆さま、ぜひこの機会に普段お使いの Zoho 製品について、率直なご感想をお聞かせください。 【キャンペーン内容】 対象製品: ・Zoho CRM ・Zoho Workplace ・Zoho Mail キャンペーン実施時間:
        • Goods in transit

          When creating a purchase order in Zoho Books, how can I properly reflect the inventory as "Goods in Transit" until it reaches its final destination?
        • Next Page