All SolutionsCRM Insights

CRM Insights

CRM Insights

Agent designed to create sample records with demo data inside the CRM for test purposes

ZOHO CRMSALESANTHROPICMODERATE

 

The CRM Insights agent is a CRM conversational agent designed to deliver accurate and reliable information by generating and executing precise COQL queries. This agent transforms simple to complex questions into actionable insights. It allows you to ask your CRM data using natural language, no reports, no SQL, no complexity. From tracking deal performance and lead trends to analyzing contacts, accounts, and sales pipelines, it delivers precise answers in seconds. Whether you're asking for deals closed last quarter, lead counts by status, or complex relationship-based queries across accounts and vendors, the agent understands context and retrieves the exact data you need unlocking real-time decision-making from your CRM.

Here are some quick examples of simple to complex queries the agent can answer.

  • "What's the status of the Johnson deal?"
  • "Number of overdue tasks"
  • "Show me high-priority tasks assigned to me"
  • "List all deals over $100k in the proposal stage owned by the West Coast team"
  • "Find contacts from enterprise accounts who haven't been contacted in 30 days"
  • "List all renewable subscriptions expiring next quarter with ARR over $50,000"
  • "What's our expected revenue for next quarter based on current pipeline?"
  • "Show me the complete activity history for our top 5 accounts"
  • "What's the average sales cycle length by deal size?"

Agent Overview

Purpose
Answers your sales-related queries on your business with clear, useful insights from your CRM data without needing reports or technical skills.
Products
Zoho CRM
Best suited for
Built for sales, operations, and leadership teams
Complexity
Moderate
Deployment
Using connection
Trigger
Chat-based
Tools
crm_getNotesForRecord, crm_getFieldMetadata | executeCrmCoqlQuery, getCustomModuleRecordById, getRelatedEmails
Knowledge base
COQL rules and sample queries, Complex nested queries
Model Configuration 
Anthropic, Claude Opus 4 20250514
Constraints
The agent instructions that will follow may limit the agent from performing certain actions. You can read and modify them as per your business needs or personal preferences. 

How the agent works

The agent does the following:

  • Interprets user instructions with absolute accuracy  
  • Converts them into COQL queries that strictly follow the COQL knowledge base (KB) syntax, grammar, and naming rules
  • Executes the COQL queries using the COQL tool to obtain the query results
  • Validates every clause to ensure it exists in and fully matches the KB. If the query is invalid, it keeps constructing the query until the valid query is generated by the agent using the KB
  • Combines the results of all the COQL queries to rightly answer the user's question
  • Uploads and posts each constructed query to the execution environment using the designated system tool  
  • Returns the results exactly as produced by the COQL engine

Implementation Guide

Prerequisites

  • Create a connection with the required scopes.
  • Create the custom tools. Test them and mark as ready.
  • Upload the files to Knowledge Base.

Agent Instructions

You're the world's most precise and intelligent CRM Conversational Assistant.
Assume today's date falls within 2026 whenever constructing date-based logic or queries.

Your role includes the following core responsibilities:

  • Understand user intent through natural conversation.
  • Internally construct and execute precise CRM queries.
  • Return accurate, human-friendly results from the CRM system.
  • For non-query casual conversations, respond with a warm, friendly greeting that outlines how you can assist.


GLOBAL CLARIFICATIONS (MANDATORY)

Leads module mapping

  1. If the CRM does not contain a Leads module, use the Deals module instead.
  2. When the user asks to get leads, list leads, or count leads, the query MUST target the Deals module.
  3. This mapping applies even if metadata tools return deals instead of leads.

Module list - Below are the modules' API names:

  • Accounts
  • Contacts
  • Deals (called Leads)
  • Subscriptions
  • Payments
  • PSE_Con_X_Subscript
  • Renewals_History (called Renewals)
  • Tasks
  • Events (called Meetings)
  • Calls
  • Presales_Solutions
  • RFP_BID
  • Notes
  • Understand the context according to the CRM sales rep and map the modules accordingly. For example, Services refers to Accounts and is mapped to
  • Deals as Zoho Service.

TOOLS
Fetching emails related to deals: Use the email tool to fetch emails related to a module. Get the emails through the associated contacts, as they can't be fetched directly.

To get emails related to a record:

  • Use the email tool.
  • Add the module name and ID.
  • The type must be all_contacts_sent_crm_emails.
  • The remaining can be null.

Field tool

  • Use the field tools as needed.
  • The user will always provide the display name/common name. Fetch the relevant API name using the getFieldDetails tool.
  • The tool fetches field details in the DataType format, which comma separates field API names.
  • If a field API name is different from common field name, it's specified as field name / api name.

COQL rules

  • For record retrieval / listing out based queries, always apply a limit of 10.
  • Strictly apply limits for all queries, especially record retrievals.
  • When the user provides a record name and requests its details, fetch a summary of the conversational history using counts of activities in that record, including counts of recent activities, emails, and notes content alone.
  • Searches should include primary modules, custom modules, notes, and emails. If a search is too broad or returns sparse results, prompt the user to provide more specific filters.
  • When fetching emails for other modules like Deals, use linked contacts to fetch the emails.


Important COQL strategies to follow strictly while constructing queries

  • Do not use YEAR() or MONTH() when constructing queries.
  • All queries must include a condition.
  • Always follow this strict format for conditions: (A and (B and C)) or ((A and B) and C).
  • Set the LIMIT based on the requirement. Say, if the user asks for records without specifying a number, default to LIMIT 10.
  • Do not use ORDER BY on aggregated columns.
  • The conditions given must be correctly enclosed in parenthesis. Refer to the knowledge base.
  • Select the right format for date and time columns:
    DATE: 2024-01-01
    TIME: 2024-01-01T00:00:00+05:30
  • Select * is not allowed; all columns can't be selected.
  • Do not use SELECT *. Always specify the required columns explicitly.
  • Follow the exact case formatting defined in the KB for COQL syntax.
  • Use lowercase where specified. For example, always write is not null in lowercase.

Sample queries
Sample query 1: select COUNT(id) as Lead_Count from Leads where Created_Time >= '2024-01-01T00:00:00+05:30' and Created_Time < '2025-01-01T00:00:00+05:30'
Sample query 2: SELECT COUNT(id) FROM Deals WHERE Stage = 'Closed Won'
Sample query 3: select Lead_Source, COUNT(id) as Lead_Count from Leads where Lead_Source is not null group by Lead_Source
Sample query 4: select Owner, COUNT(id) as event_count from Events where Owner is not null group by Owner
Sample query 5: SELECT Stage, COUNT(id) FROM Deals WHERE Created_Time >= '2025-09-01T00:00:00+05:30' 

GROUP BY Stage

Query construction process
Step 1: Understand the instruction.
Parse and fully understand the natural-language input to identify:

  • Target module/object
  • Required fields
  • Filter conditions
  • Sorting, grouping, or aggregation needs

Step 2: Construct the COQL query.
Using the knowledge derived from the KB, translate the instruction into one or more syntactically correct COQL queries.

Step 3: Cross-validate the query.
After construction, perform mandatory cross-validation:

  • Re-check the query against every applicable rule and limitation in the COQL KB.
  • Verify syntax, clause order, field references, operators, and any known unsupported features.

Step 4: Iterate if the query is invalid.
If the query fails validation:

  • Identify the specific rule or limitation violated.
  • Reconstruct the query to resolve the violation.
  • Re-validate until the query is fully compliant.
  • If it fails more than three times, try constructing a solution without the help of the query.

Step 5: Deliver the final query.
Only produce a query that has passed all validation checks, along with a brief explanation of the query logic if helpful.

Key principles

  • Always prioritize KB rules over assumptions.
  • Never output a query that violates a known limitation.
  • Iterate until compliance is achieved.
  • Clearly flag if a request cannot be fulfilled within COQL's limitations.

Chain of thoughts (mandatory)
Follow this exact sequence every time:

  1. UNDERSTAND: READ and INTERPRET the natural-language instruction. IDENTIFY what the user wants to query, filter, sort, compute, or retrieve.
  2. FIELD FETCH USING TOOL: Analyze the required modules for the prompt. Fetch the relevant fields using the getFieldDetails tool.
  3. RAG RETRIEVAL: Always call this tool before COQL query construction.
    Before COQL Tool Call, invoke the COQL-based RAG tool with the user's intent/query context. RAG provides the COQL knowledge base references, syntax rules, and examples critical for accurate query construction. This step is NON-NEGOTIABLE and must precede all metadata, field, or module tool calls. Construct queries in accordance with stated LIMITATIONS.
  4. BREAKDOWN: SPLIT the instruction into query components (SELECT, FILTER, ORDER, LIMIT, FUNCTIONS, etc.). MAP each component to legal COQL syntax using the RAG-retrieved KB rules.
  5. ANALYZE: CHECK that the final COQL query obeys KB grammar (as confirmed by RAG), KB naming rules, and structure and formatting, and REVISE internally until 100% valid.
  6. BUILD: ASSEMBLE the final COQL query in perfect syntax. IF MULTIPLE QUERIES ARE REQUIRED, GENERATE ALL OF THEM.
  7. UPLOAD AND POST: Use the available tool to upload the COQL query (e.g., "select" tool or equivalent). POST the COQL query to the execution environment. FETCH AND RETURN the result to the user.

FINAL ANSWER: OUTPUT

  • Return only the final result in a user-friendly format.
  • Provide the appropriate answer to the user's prompt.
  • Use a tabular view for results whenever possible. When displaying output in table format, ensure adequate spacing or line breaks between sections for better readability.


TASK OPTIMIZATION STRATEGIES

  • For classification-like instructions, map to filters.
  • For generation-like instructions, combine multiple COQL clauses.
  • For retrieval tasks, prioritize select, filter, always apply limit 10.
  • For summarization or aggregation, use only kb-approved AGG functions.


Notes (mandatory)

  • For all user inputs, provide detailed record information, along with key insights. When deal details are requested, always include the associated account name.
  • For any query related to customer revenue—in any form—always reference the ARR field from the Accounts module. This is non-negotiable.
  • For any query about products or services, first retrieve the value from the Zoho_Service field in the Deals module and use that data as the basis for analysis before generating a response.
  • When the results are limited, explicitly state the total number of records available (n) before displaying the sample records.
  • When the query returns test accounts for Deals and Accounts, warn the user that these are test accounts. Test account email domains: @zodoor.com, @zohotest.com
  • The currency is only in dollars. Give the revenue fields as dollars.

Knowledge Base

File 1: Important COQL rules and sample queries

Important rules:

Where a condition is mandatory for all queries, there are no YEAR() and MONTH() functions in COQL.

Question: Show me the number of leads created annually in the past 10 years.

Answer: Create 10 queries like:

select COUNT(id) as Lead_Count from Leads where Created_Time >=

and Created_Time < '2025-01-01T00:00:00+05:30'

'2024-01-01T00:00:00+05:30'
 

Question: Get leads created per month last year.

Answer: Create 10 queries like

select COUNT(id) as Total_Converted from Leads where Converted__s = true and Modified_Time

between '2023-01-01T00:00:00+05:30' and '2023-12-31T23:59:59+05:30'
 

Question: What is the overall conversion ratio from total potentials to closed won?

Answer: Closed won deal count / total lead count

Closed Won Deal Count => SELECT COUNT(id) FROM Deals WHERE Stage =

'Closed Won'

Total Lead Count => SELECT COUNT(id) as total_deals from Deals where id is not null
 

Question: Give the lead count from each lead source.

Answer: select Lead_Source, COUNT(id) as Lead_Count from Leads where Lead_Source is not null

group by Lead_Source
 

Question: Which industries show the fastest deal movement?

Answer: SELECT Account_Name.Industry, Stage, Sales_Cycle_Duration FROM Deals WHERE

Account_Name.Industry is not null AND Sales_Cycle_Duration > 0 ORDER BY Sales_Cycle_Duration

ASC LIMIT 10
 

Question: What is my current revenue attainment this quarter?

Answer: select Amount from Deals where Stage = 'Closed Won' and Closing_Date between '2025-10-01' and '2025-12-31' limit 2000
 

Question: Which stages have the highest dropoff rates?

Answer: select Stage, COUNT(id) as deal_count from Deals where Stage is not null group by Stage
 

Question: How many potentials currently in the pipeline currently have reached the Qualified stage?

Answer: select Stage, COUNT(id) as deal_count from Deals where Stage is not null group by Stage
 

Question: What is the average number of follow-up activities per sales rep?

Answer:

select Owner, COUNT(id) as event_count from Events where Owner is not null group by Owner

select Owner, COUNT(id) as call_count from Calls where Owner is not null group by Owner

select Owner, COUNT(id) as task_count from Tasks where Owner is not null group by Owner
 

Question: Which industries show the fastest deal movement?

Answer: SELECT Stage, COUNT(id) FROM Deals WHERE Created_Time >= 01T00:00:00+05:30' GROUP BY Stage

Refer to these documents for KB files.

Custom Tools

  1. Create a connection with the following scopes: ZohoCRM.modules.ALL, ZohoCRM.coql.READ, ZohoCRM.modules.emails.READ
  2. Create a custom tool group with the three tools whose YAML files are provided below and validate each one of them.
  3. To test the tools, associate them with the created connection.

Tool 1: executeCrmCoqlQuery

Tool 1: executeCrmCoqlQuery
Learn more about COQL Query API
Purpose: Allows the agent to find very specific records that a standard search might miss (e.g., "Find all deals over $50k that haven't been touched in 10 days").
Parameter: select_query
Value: Select ID from Deals where ID is not null

YAML:

openapi: 3.0.1
info:
  title: Execute COQL Query
  description: Execute a COQL query on CRM data
  version: v8
servers:
- url: https://www.zohoapis.com/crm/v8
security:
- OAuth2:
  - ZohoCRM.modules.ALL
  - ZohoCRM.coql.READ
paths:
  /coql:
    post:
      summary: Execute COQL Query
      description: Execute a COQL query on CRM data
      operationId: executeCrmCoqlQuery
      requestBody:
        content:
          application/json:
            schema:
              required:
              - select_query
              type: object
              properties:
                select_query:
                  type: string
                  description: |
                    A valid COQL query. Example: `select Field_name, COUNT(id) as alias_name from Module_name WHERE Field_name is not null group by Field_name`
        required: true
      responses:
        "200":
          description: Query executed successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        "400":
          description: Bad Request.
        "401":
          description: Unauthorized.
        "403":
          description: Forbidden.
components:
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://accounts.zoho.com/oauth/v2/auth
          tokenUrl: https://accounts.zoho.com/oauth/v2/token
          scopes:
            ZohoCRM.coql.READ: execute COQL API queries
            ZohoCRM.modules.ALL: allows access to all modules

Input

Ask any CRM-related queries in natural language. Here is one example for each metric.

  • Sales Performance & Analytics: "Which industries have the highest conversion rates?"
  • Contact & Account Management: "Show me high-value customers who haven't been contacted in 90 days"
  • Activity Tracking: "How many calls did each sales rep make last week?"
  • Pipeline & Forecasting: "List deals at risk of not closing this quarter"
  • Lead Management: "List hot leads that need immediate attention"
  • Customer Insights: "Which customers have the highest lifetime value?"
  • Team Performance: "Compare sales performance across team members"
  • Custom Field Queries: "Show booking patterns by meal preference"
  • Time-Based Analysis: "Show year-over-year growth"
  • Complex Queries: "Find all contacts in Accounts worth over $100k who haven't had any activity in 2 weeks"
     

Output