Building a sophisticated AI SDR agent leveraging internet search and evals to draft personalized outreach emails in 15 seconds
Dear John,
I hope this email finds you well. I wanted to reach out about our security services that might be of interest to YMU Talent Agency.
Our company provides security personnel for events. We have many satisfied customers and would like to schedule a call to discuss how we can help you.
Let me know when you’re available.
Regards,
Sales Rep
Subject: Quick security solution for YMU’s talent events
Hi John,
I noticed YMU’s been expanding its roster of A-list talent lately – congrats on that growth. Having worked event security for talent agencies before, I know how challenging it can be coordinating reliable security teams, especially on short notice.
We’ve built something I think you’ll find interesting – an on-demand security platform that’s already being used by several major talent agencies.
Best,
Ilya
This cookbook shows you how to build an AI-powered system that:
Our system combines three specialized AI models:
This architecture delivers superior results because:
The Orchestrator template handles three different roles depending on which “mode” is activated:
Variable | Purpose | Example |
---|---|---|
our_offering | Your product/service description | ”Umbrella Corp offers ‘Uber for personal protection’…” |
company_name | Prospect’s company | ”YMU Talent Agency” |
company_industry | Industry sector | ”Elite Talent Management” |
target_person_name | Contact name | ”John Wick” |
target_person_designation | Contact’s role | ”Event Organizer” |
requirement_gathering_mode | Activates research query mode | ”TRUE” or "" (empty) |
research_mode | Activates email drafting mode | ”TRUE” or "" (empty) |
evaluator_mode | Activates email refinement mode | ”TRUE” or "" (empty) |
researcher_output | Data from the researcher | (JSON response from research) |
evaluator_output | Feedback from evaluator | (JSON with score and comments) |
Let’s create reusable components that define our SDR’s core instructions and persona. These are added as Prompt Partials - reusable blocks that can be inserted in any template.
Core Agent Instructions Partial
You are the ultimate sales representative from Umbrella Corporation. Your job is to:
SDR Persona Partial
Your name is Ilya:
We’ll insert both partials into the template’s system role like this:
Next, we’ll add a section that will receive your company’s offering details from a variable:
We’ll send this variable’s content at runtime.
Now let’s add a section that will receive the prospect information variables:
We’ll send these values at runtime as well.
This is where the magic happens! We’ll add three “conditional sections” that only appear when a specific mode is activated:
A. Research Query Generation Mode: Here, we’ll explain how the research query should be generated.
At this stage, we can send a request to the researcher get the research output back.
B. Email Drafting Mode (add this section next):
Once we have the research output, we can create the first email, and add the following to a new user role in the prompt template:
We’ll take this email and send it to the evaluator, which will send back a JSON with two keys: “score” and “comment”.
C. Email Refinement Mode (add this final section):
With the Evaluator’s output, we’ll now create the final email.
The Power of Conditional Variables
This approach with {{#variable_name}}
syntax lets you use a single template for three different purposes. When you set requirement_gathering_mode
to “TRUE”, only that section appears. When you set it to empty and instead set research_mode
to “TRUE”, the email drafting section appears instead. This keeps your templates DRY (Don’t Repeat Yourself).
When finished, your template should have:
This single template will now handle all three stages of the orchestrator’s job, activated by different variables in your code.
Setup
Generate Research Queries
Example Output
Conduct Research
Example Output
Draft Initial Email
Example Output
Evaluate Email
Example Output
Refine Email
Final Email
Portkey’s trace view provides complete visibility to track performance, cost, latency, and opportunities for improvement.
✅ Set up Portkey account and API credentials
✅ Create prompt templates for all three agents
✅ Define your company offering and SDR persona
✅ Configure basic prospect information
✅ Implement the five-step workflow
✅ Set up tracing and monitoring
✅ Create a system for batching multiple prospects
Issue | Solution |
---|---|
Low research quality | Make research queries more specific |
Generic emails | Ensure research findings are prominently featured |
High token usage | Remove redundant information from prompts |
This AI SDR system isn’t just an incremental improvement—it’s a fundamental reimagining of how sales development works. By combining specialized AI agents in an orchestrated workflow, you can achieve personalization at scale that was previously impossible.
The result? More meetings, stronger relationships, and ultimately more closed deals—all while freeing your team to focus on high-value activities.