Skip to main content

The Problem: Generic Sales Outreach Doesn’t Work

❌ Before

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

Response rate: 1.2%
✅ After

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

Response rate: 9.5%
This cookbook shows you how to build an AI-powered system that:
  • Researches prospects in real-time using up-to-date web data
  • Crafts personalized emails based on prospect-specific insights
  • Self-evaluates and improves its output before sending
  • Scales to thousands of prospects at a fraction of the usual cost

Multi-Agent Architecture

Our system combines three specialized AI models:
  1. Orchestrator (Claude 3.7): Generates research queries, drafts emails, and refines based on feedback
  2. Researcher (Perplexity): Gathers real-time web information about prospects and companies
  3. Evaluator (OpenAI): Reviews email quality, providing scores and improvement suggestions
This architecture delivers superior results because:
  • Each model handles tasks it excels at
  • The system includes built-in quality control
  • Cost efficiency through right-sized models and targeted research

Creating the Prompt Templates

  • Orchestrator Template
  • Researcher Template
  • Evaluator Template

What You’ll Create

The Orchestrator template handles three different roles depending on which “mode” is activated:
  1. Research Query Generator: Creates targeted questions for the researcher
  2. Email Drafter: Uses research findings to write personalized outreach
  3. Email Refiner: Incorporates evaluator feedback to improve the email

Variables You’ll Need

VariablePurposeExample
our_offeringYour product/service description”Umbrella Corp offers ‘Uber for personal protection’…”
company_nameProspect’s company”YMU Talent Agency”
company_industryIndustry sector”Elite Talent Management”
target_person_nameContact name”John Wick”
target_person_designationContact’s role”Event Organizer”
requirement_gathering_modeActivates research query mode”TRUE” or "" (empty)
research_modeActivates email drafting mode”TRUE” or "" (empty)
evaluator_modeActivates email refinement mode”TRUE” or "" (empty)
researcher_outputData from the researcher(JSON response from research)
evaluator_outputFeedback from evaluator(JSON with score and comments)

Step-by-Step Setup

  1. Create template in prompt.new with Claude 3.7 Sonnet
  1. Add core partials:
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.
You are the ultimate sales representative from Umbrella Corporation. Your job is to:
  1. Understand the company and target person
  2. Write research queries to learn more about them
  3. Use research findings to write the ultimate opener email
  4. Send to evaluator for improvements
  5. Write final email based on feedback
Your name is Ilya:
  • You acutely understand the exact requirements your target person and their company has
  • You write short, to the point emails that feel like a friend sending a text to you
  • At the same time, you understand the importance of coming across as a thorough professional
  • You have yourself been on both ends - when you needed private security and when you yourself were a private security professional
We’ll insert both partials into the template’s system role like this:
  1. Add product offering:
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.
  1. Add Prospect Information Section:
Now let’s add a section that will receive the prospect information variables:
We’ll send these values at runtime as well.
  1. Create Agent-Specific Sections with Conditional Logic:
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 VariablesThis 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).

Complete Template Overview

When finished, your template should have:
  1. Core instruction and persona partials at the top
  2. Company offering section
  3. Prospect information section
  4. Three conditional sections for different modes
This single template will now handle all three stages of the orchestrator’s job, activated by different variables in your code.

Implementing the Workflow

1

Setup

from portkey_ai import Portkey

# Initialize with tracing
client = Portkey(
  api_key="PORTKEY_API_KEY",
  trace_id="ultimate-ai-sdr-run-1"
)

# Company offering
our_offering = """Umbrella Corp offers 'Uber for personal protection'. Using our app, you can get highly vetted, 
arms-bearing ex-veterans who can accompany you to any place that's supported for any amount of hours or days..."""

# Target information
company_name = "YMU Talent Agency"
company_industry = "Elite Talent Management"
target_person_name = "John Wick"
target_person_designation = "Event Organizer"
2

Generate Research Queries

# Activate research query generation mode
variables = {
    "our_offering": our_offering,
    "company_name": company_name,
    "company_industry": company_industry,
    "target_person_name": target_person_name,
    "target_person_designation": target_person_designation,
    "requirement_gathering_mode": "TRUE"  # Activate research query mode
}

gatherer = client.with_options(span_name="gatherer").prompts.completions.create(
    prompt_id="your-orchestrator-template-id",
    variables=variables
).choices[0].message.content
Research Queries:

1. What are the typical event sizes and types that YMU Talent Agency organizes?
2. Have there been any security incidents at YMU's past events?
3. What is John Wick's specific role and experience in event organization at YMU?
4. Does YMU currently work with any security providers?
5. What are the most significant upcoming events that YMU is organizing?
...
3

Conduct Research

# Send queries to researcher
researcher = client.with_options(span_name="researcher").prompts.completions.create(
    prompt_id="your-researcher-template-id",
    variables={"requirement_gathering_output": gatherer}
).choices[0].message.content
Research Summary for YMU Talent Agency:

1. Company Profile:
   - YMU is one of the world's leading talent management companies
   - Represents high-profile clients including Simon Cowell, Nicole Scherzinger
   ...

2. Security Considerations:
   - Growing concern about celebrity stalking incidents in the industry
   - Multiple high-profile clients have experienced security threats
   ...
4

Draft Initial Email

# Activate email drafting mode
variables = {
    "our_offering": our_offering,
    "company_name": company_name,
    "target_person_name": target_person_name,
    "researcher_output": researcher,
    "requirement_gathering_mode": "",  # Deactivate research mode
    "research_mode": "TRUE"  # Activate email drafting mode
}

email_one = client.with_options(span_name="email-one").prompts.completions.create(
    prompt_id="your-orchestrator-template-id",  # Same template, different mode
    variables=variables
).choices[0].message.content
Subject: Quick security chat - from one protection expert to another

Hi John,

As someone who's been on both sides of event security, I know the stress of finding reliable protection for high-profile talent. Especially given YMU's roster including Simon Cowell and Nicole Scherzinger.

We've built an 'Uber for security' that top agencies use - you get instant access to vetted, armed ex-veterans through an app.
...
5

Evaluate Email

# Send to evaluator
evaluator = client.with_options(span_name="evaluator").prompts.completions.create(
    prompt_id="your-evaluator-template-id",
    variables={"work_history": gatherer + " " + researcher, "email_output": email_one}
).choices[0].message.content
{
    "score": 7,
    "comment": "The email does a good job establishing rapport by acknowledging John's background in event security and mentioning specific clients. However, it could be improved by directly addressing the specific pain point mentioned in the research - 'finding reliable security staff on short notice.'"
}
6

Refine Email

# Activate email refinement mode
variables = {
    "our_offering": our_offering,
    "company_name": company_name,
    "target_person_name": target_person_name,
    "researcher_output": researcher,
    "evaluator_output": evaluator,
    "requirement_gathering_mode": "",
    "research_mode": "",
    "evaluator_mode": "TRUE"  # Activate refinement mode
}

email_two = client.with_options(span_name="email-two").prompts.completions.create(
    prompt_id="your-orchestrator-template-id",  # Same template, third mode
    variables=variables
).choices[0].message.content
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. Think of it like having an elite security team in your pocket, available within hours.
...

Monitoring and Optimization

Portkey’s trace view provides complete visibility to track performance, cost, latency, and opportunities for improvement.

Implementation Checklist

✅ 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

Troubleshooting & Best Practices

IssueSolution
Low research qualityMake research queries more specific
Generic emailsEnsure research findings are prominently featured
High token usageRemove redundant information from prompts

Ready to Transform Your Outreach?

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.
I