Build an agent that helps your sales team prepare for meetings, identify at-risk deals, and spot pipeline shifts before they become problems.
Why Build a Sales Intelligence Agent?
Most sales teams spend hours preparing for meetings, manually checking deal status, and trying to spot pipeline problems before it's too late. In this guide, we'll build a sales intelligence agent that gives your team instant context on deals, accounts, and pipeline health—exactly when they need it.
What This Agent Is Expected To Do
This agent answers concrete questions about sales pipeline, deals, and accounts. Here's what it should handle:
- "What should I know before my meeting with Acme Corp tomorrow?"
- "Which deals are at risk this quarter and why?"
- "What's changed in the pipeline since last week?"
- "Give me a brief on the Contoso deal—what's the status and what should I focus on?"
- "Which accounts haven't had activity in the last 30 days?"
- "What's the forecast for Q2 and what deals are driving it?"
The agent doesn't just return data—it provides context, explains risks, and surfaces actionable insights.
Who This Agent Is For
This agent is built for teams that need sales intelligence across multiple systems:
- Sales Reps – Quick meeting prep, deal context, account insights without switching tools
- Sales Managers – Pipeline health, deal risks, forecast accuracy, team performance
- RevOps / Sales Ops – Pipeline analysis, deal progression, conversion metrics, quota tracking
- Leadership – Forecast visibility, pipeline shifts, deal risks, revenue trends
If you live in CRM, sales activity data, email, and calendar systems, this agent is for you.
Core Use Cases
Here are the scenarios where this agent shines:
Meeting preparation in seconds: Instead of spending 15 minutes jumping between CRM, email, and calendar, the agent gives you a complete brief on the account, recent activity, deal status, and talking points—in one question.
Spotting at-risk deals before they stall: The agent identifies deals with no activity for 14+ days, deals past their expected close date, or deals with declining engagement. You can intervene before they become problems.
Understanding pipeline shifts: The agent surfaces what's changed—new deals, moved deals, lost deals, stalled deals—and explains the impact on forecast and quota.
Getting deal context on demand: When a rep asks "what's the status of the Contoso deal?", the agent provides complete context: deal stage, amount, probability, last activity, key contacts, recent emails, and next steps.
The Ingredients: Data You'll Need
To build this agent, you'll need data from several systems:
CRM data (from HubSpot, Salesforce, etc.):
- Deals: deal name, amount, stage, probability, owner, expected close date
- Accounts: account name, industry, account owner, account status
- Contacts: contact name, role, email, last contacted
- Activities: emails sent, calls made, meetings scheduled
Sales activity data (from email, calendar, call tracking):
- Email engagement: opens, replies, response times
- Meeting activity: scheduled meetings, no-shows, meeting outcomes
- Call activity: call duration, outcomes, follow-ups needed
Historical data (from your data warehouse):
- Past deals: win/loss rates, time to close, deal sizes
- Historical pipeline: pipeline value trends, conversion rates
- Account history: previous purchases, contract renewals
Derived fields (calculated in the view):
days_in_stage: How long a deal has been in its current stagedays_since_last_activity: Days since last email, call, or meetingdeal_risk_score: Calculated risk based on stage, activity, and timelinepipeline_change: Comparison to previous period (new deals, moved deals, lost deals)forecast_confidence: Confidence level based on deal stage and activity
Here's an example SQL view:
-- Sales Intelligence View
SELECT
-- Deal data from CRM
d.deal_id,
d.deal_name,
d.account_name,
d.owner_name,
d.stage,
d.amount,
d.probability,
d.expected_close_date,
d.created_date,
DATEDIFF(CURRENT_DATE(), d.created_date) as deal_age_days,
DATEDIFF(d.expected_close_date, CURRENT_DATE()) as days_to_close,
d.amount * (d.probability / 100) as weighted_value,
-- Account data
a.account_id,
a.industry,
a.account_status,
a.annual_revenue,
-- Activity metrics
COUNT(DISTINCT e.email_id) as email_count_30d,
COUNT(DISTINCT c.call_id) as call_count_30d,
COUNT(DISTINCT m.meeting_id) as meeting_count_30d,
MAX(COALESCE(e.sent_date, c.call_date, m.meeting_date)) as last_activity_date,
DATEDIFF(CURRENT_DATE(), MAX(COALESCE(e.sent_date, c.call_date, m.meeting_date))) as days_since_last_activity,
-- Risk indicators
CASE
WHEN DATEDIFF(CURRENT_DATE(), MAX(COALESCE(e.sent_date, c.call_date, m.meeting_date))) > 14 THEN 'high_risk'
WHEN DATEDIFF(CURRENT_DATE(), MAX(COALESCE(e.sent_date, c.call_date, m.meeting_date))) > 7 THEN 'medium_risk'
ELSE 'low_risk'
END as activity_risk,
CASE
WHEN d.expected_close_date < CURRENT_DATE() AND d.stage NOT IN ('won', 'lost') THEN 'past_close_date'
WHEN DATEDIFF(d.expected_close_date, CURRENT_DATE()) < 7 AND d.probability < 50 THEN 'low_probability_close'
ELSE 'on_track'
END as timeline_risk,
CASE
WHEN DATEDIFF(CURRENT_DATE(), MAX(COALESCE(e.sent_date, c.call_date, m.meeting_date))) > 14
OR (d.expected_close_date < CURRENT_DATE() AND d.stage NOT IN ('won', 'lost'))
OR (DATEDIFF(d.expected_close_date, CURRENT_DATE()) < 7 AND d.probability < 50)
THEN 'at_risk'
ELSE 'healthy'
END as deal_risk_status,
-- Pipeline context
d.stage as current_stage,
d.probability as current_probability,
d.amount as current_amount
FROM hubspot.deals d
LEFT JOIN hubspot.accounts a ON d.account_id = a.account_id
LEFT JOIN sales_activity.emails e ON d.deal_id = e.deal_id
AND e.sent_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
LEFT JOIN sales_activity.calls c ON d.deal_id = c.deal_id
AND c.call_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
LEFT JOIN sales_activity.meetings m ON d.deal_id = m.deal_id
AND m.meeting_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
WHERE d.stage NOT IN ('won', 'lost')
GROUP BY
d.deal_id, d.deal_name, d.account_name, d.owner_name, d.stage,
d.amount, d.probability, d.expected_close_date, d.created_date,
a.account_id, a.industry, a.account_status, a.annual_revenue;
This view joins data from your CRM (deals, accounts), sales activity (emails, calls, meetings), and calculates risk indicators and activity metrics.
Key points:
- The view joins across multiple systems in a single query
- It calculates derived fields (activity risk, timeline risk, deal risk status)
- It filters to only active deals (not won/lost)
- It uses time windows (last 30 days) for activity metrics
Step 4: Add MCP Tools on Top of This View
Create MCP tools that expose this view to agents. Tools translate natural language questions into SQL queries.
Tool 1: get_meeting_brief(account_name: string)
This tool returns a complete brief for an upcoming meeting.
Description: "Returns a comprehensive meeting brief including account context, deal status, recent activity, and talking points for a specific account."
SQL Query:
SELECT * FROM sales_intelligence_view
WHERE account_name = {account_name}
ORDER BY deal_amount DESC;
Tool 2: list_at_risk_deals(limit: number, risk_level: string)
This tool lists deals at risk, with optional filtering by risk level.
Description: "Returns list of deals at risk (high_risk, medium_risk, or all), optionally filtered by risk level, sorted by deal amount."
SQL Query:
SELECT * FROM sales_intelligence_view
WHERE deal_risk_status = 'at_risk'
AND (activity_risk = {risk_level} OR {risk_level} IS NULL)
ORDER BY deal_amount DESC
LIMIT {limit};
Tool 3: get_pipeline_changes(days: number)
This tool shows what's changed in the pipeline over a specified period.
Description: "Returns pipeline changes including new deals, moved deals, and deals with significant changes in the last N days."
SQL Query:
SELECT
deal_id,
deal_name,
account_name,
stage,
amount,
probability,
days_since_last_activity,
deal_risk_status,
CASE
WHEN created_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {days} DAY) THEN 'new_deal'
WHEN stage_changed_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {days} DAY) THEN 'stage_changed'
WHEN amount_changed_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {days} DAY) THEN 'amount_changed'
ELSE 'no_change'
END as change_type
FROM sales_intelligence_view
WHERE created_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {days} DAY)
OR stage_changed_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {days} DAY)
OR amount_changed_date >= DATE_SUB(CURRENT_DATE(), INTERVAL {days} DAY)
ORDER BY change_type, deal_amount DESC;
Tools can be called by agents with natural language
Step 5: Wire the Tool to an Agent Builder
Connect your Pylar tools to an agent builder. You can use:
- OpenAI Platform – Build custom agents with GPT-4
- LangGraph – Build complex agent workflows
- Claude Desktop – Quick setup for internal use
- Cursor – Developer-focused agent builder
- Zapier / Make / n8n – Automation platforms

Agent Instructions:
Give your agent clear instructions.
You are a sales intelligence assistant. Your job is to help sales teams prepare for meetings, identify at-risk deals, and understand pipeline changes.
Rules:
- Only use the tools provided. Do not invent deal information or make assumptions.
- When asked about a meeting or account, use
get_meeting_briefto get complete context.- When asked about at-risk deals, use
list_at_risk_dealswith appropriate filters.- When asked about pipeline changes, use
get_pipeline_changeswith the requested time period.- Always provide context: explain why a deal is at risk, what changed in the pipeline, or what to focus on in a meeting.
- If you don't have data, say so. Don't guess.
Available tools:
get_meeting_brief(account_name)— Get complete meeting brief for an accountlist_at_risk_deals(limit, risk_level)— List deals at riskget_pipeline_changes(days)— Get pipeline changes over time
Example Prompts Users Can Try:
- "What should I know before my meeting with Acme Corp tomorrow?"
- "Which deals are at risk this quarter and why?"
- "What's changed in the pipeline since last week?"
- "Give me a brief on the Contoso deal—what's the status and what should I focus on?"
- "Which accounts haven't had activity in the last 30 days?"
- "What's the forecast for Q2 and what deals are driving it?"
The agent uses the tools to answer these questions, providing context and actionable insights.
Step 6: Add Evals & Guardrails
Add observability and guardrails to ensure the agent works correctly and safely.
Logging:
Track:
- Which deals and accounts are queried most frequently
- Error rates and types
- Query latency
- Unusual outputs or patterns
Use Pylar's Evals system to monitor:
- Success rates: How often queries succeed vs. fail
- Error patterns: What errors occur and why
- Query shapes: What types of queries agents make
- Raw logs: Every query with full context
Guardrails:
Add simple checks:
No PII leaking: Views exclude sensitive data (personal notes, internal comments, salary information). Agents can only query through views, so they never see PII.
Row limits: Views automatically limit results (e.g., top 100 deals, last 90 days of activity). Agents can't query unbounded datasets.
Time windows: Views filter to recent data (last 30 days for activity, last 90 days for deals). Agents can't query historical data beyond what's needed.
Access control: Different views for different teams. Sales reps see only their deals. Managers see team deals. RevOps sees all deals.
Step 7: Rollout Playbook
How to introduce this agent to your sales team:
Week 1: Pilot with 2–3 reps
- Set up the agent with basic tools
- Have reps try it for meeting prep
- Collect feedback on what's missing
Week 2: Expand to full team
- Add more tools based on feedback
- Create team-wide Slack integration
- Share example prompts
Week 3: Add managers
- Create manager-specific views (team pipeline, forecast)
- Add manager tools (pipeline health, deal risks)
- Set up weekly pipeline reviews using the agent
Example Slack message: "Before your next customer call, ask the sales agent: 'What should I know before my meeting with [account]?'"
How This Replaces Dashboards (Without Killing Them)
Old flow: Open CRM, check deal status, open email to see recent activity, check calendar for meeting context, manually piece together the story.
New flow: Ask one question, get a complete brief with account context, deal status, recent activity, and talking points—all in one answer.
The agent synthesizes data from multiple systems into a coherent narrative. You get answers in seconds instead of minutes.
Dashboards are still useful for:
- Monitoring known metrics
- Executive summaries
- Scheduled reports
- Visual exploration
Agents are better for:
- Ad-hoc questions
- Cross-system analysis
- Deep dives
- Proactive insights
Use both. Dashboards for monitoring. Agents for exploration.
Frequently Asked Questions
Where does this agent get its data from?
Can I customize what "at risk" means?
Will this replace my CRM?
How do we prevent it from showing sensitive data?
Can different sales roles use the same agent?
What if I only have CRM data today?
How do I know if the agent is working correctly?
Can I track pipeline changes over time?
Most sales teams spend hours preparing for meetings and trying to spot pipeline problems. This agent gives your team instant context on deals, accounts, and pipeline health—exactly when they need it.
If you want to try this with your own data, you can spin up a Sales Intelligence View in Pylar and plug it into your existing agent builder. Start with CRM data, add sales activity data as you connect it, and iterate based on what your team needs.
Related Posts
The Hidden Cost of Giving AI Raw Access to Your Database
We've seen teams rush to connect AI agents directly to databases, only to discover the real costs: security risks, governance nightmares, and agents making expensive mistakes. Here's what we learned and why a structured layer matters.
Why Agent Projects Fail (and How Data Structure Fixes It)
Most AI agent projects fail not because of the models, but because agents can't reliably access the right data at the right time. We break down the common failure patterns and how structured data views solve them.
The Rise of Internal AI Agents for Ops, RevOps, and Support
Internal AI agents are becoming the new operating system for modern teams. We explore how ops, RevOps, and support teams are using agents to automate workflows and get answers faster.
