- unwind ai
- Posts
- Build an AI Email GTM Outreach Agent Team
Build an AI Email GTM Outreach Agent Team
Fully functional multi-agent app using OpenAI GPT-5 (100% opensource)
Building targeted B2B outreach campaigns is one of the most time-consuming aspects of sales and marketing. The challenge isn't just finding companies; it's discovering the right decision-makers, researching genuine insights, and crafting personalized messages that actually get responses.
In this tutorial, we'll build a multi-agent AI email outreach system using GPT-5 (OpenAI's latest flagship model), Agno for orchestrating agent workflows, and Exa AI for intelligent web search. This system automates the entire outreach pipeline - from company discovery to personalized email generation - delivering professional, research-backed outreach emails in minutes instead of hours.
What makes this powerful? Unlike traditional outreach tools that rely on generic templates, our multi-agent system conducts real research on each company using website content and Reddit discussions, ensuring every email feels genuinely personalized. The system uses GPT-5's enhanced reasoning capabilities to understand context and generate more human-like, professional communications that convert better than template-based mails.
What We’re Building
This Streamlit application implements a sophisticated B2B outreach pipeline using multiple specialized AI agents to automate company discovery, contact research, insight gathering, and personalized email generation. The system uses GPT-5's capabilities combined with Exa AI's web search to deliver high-quality, research-backed outreach campaigns.
Features:
Multi-agent architecture with specialized roles
Company Finder: Discovers relevant companies using Exa AI's semantic search
Contact Finder: Identifies 2-3 key decision makers per company with email discovery
Research Agent: Gathers genuine insights from company websites and Reddit discussions
Email Writer: Creates personalized outreach emails in your preferred style
Intelligent web search using Exa AI's embedding-based search
Four email styles - Professional, Casual, Cold, and Consultative
Real-time progress tracking with stage-by-stage updates
How The App Works
User Setup:
Setup: Enter your OpenAI and Exa API keys in the sidebar to authenticate the system
Configuration: Define your target company criteria (industry, size, location, etc.) and describe your product/service offering
Personalization: Set your name, company, calendar link, and choose your preferred email style (Professional, Casual, Cold, or Consultative)
Execution: Select the number of companies to target (1-10) and click "Start Outreach" to begin the automated pipeline
Multi-Agent Pipeline:
Company Discovery: The Company Finder agent uses Exa AI's semantic search to discover companies matching your targeting criteria, going beyond simple keyword matching to understand intent and context.
Contact Research: The Contact Finder agent searches for decision-makers in key roles, prioritizing founders, GTM leadership, sales executives, and partnership managers. When direct emails aren't available, it intelligently infers them using common corporate email patterns.
Insight Gathering: The Research agent conducts deep research on each company, analyzing their website content and Reddit discussions to identify genuine, non-generic insights that enable authentic personalization.
Email Generation: The Email Writer agent combines all gathered information to create personalized outreach emails in your chosen style, incorporating research insights to demonstrate genuine interest and understanding.
Quality Control: Each stage includes JSON validation and error handling to ensure reliable operation, with progress tracking providing transparency into the system's work.
Monitoring: Watch real-time progress as the system moves through each stage with status updates
Results: Review discovered companies, contacts, research insights, and generated emails in organized sections
Prerequisites
Before we begin, make sure you have the following:
Code Walkthrough
Setting Up the Environment
First, let's get our development environment ready:
Clone the GitHub repository:
git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git
Go to the ai_email_gtm_outreach_agent folder:
cd advanced_ai_agents/multi_agent_apps/ai_email_gtm_outreach_agent
Install the required dependencies:
pip install -r requirements.txt
Creating the Streamlit App
Let's create our app. Create a new file ai_email_gtm_outreach_agent.py
and add the following code:
Import necessary libraries:
import json
import os
import sys
from typing import Any, Dict, List, Optional
import streamlit as st
from agno.agent import Agent
from agno.memory.v2 import Memory
from agno.models.openai import OpenAIChat
from agno.tools.exa import ExaTools
Create the Company Finder Agent:
def create_company_finder_agent() -> Agent:
exa_tools = ExaTools(category="company")
memory = Memory()
return Agent(
model=OpenAIChat(id="gpt-5"),
tools=[exa_tools],
memory=memory,
add_history_to_messages=True,
instructions=[
"You are CompanyFinderAgent. Use ExaTools to search the web for companies that match the targeting criteria.",
"Return ONLY valid JSON with key 'companies' as a list; respect the requested limit.",
"Each item must have: name, website, why_fit (1-2 lines).",
],
)
Create the Contact Finder Agent:
def create_contact_finder_agent() -> Agent:
exa_tools = ExaTools()
memory = Memory()
return Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[exa_tools],
memory=memory,
instructions=[
"You are ContactFinderAgent. Use ExaTools to find 1-2 relevant decision makers per company.",
"Prioritize roles from Founder's Office, GTM, Sales leadership, Partnerships, Product Marketing.",
"If direct emails not found, infer using common formats but mark inferred=true.",
"Return ONLY valid JSON with companies and contacts.",
],
)
Create the Research Agent:
def create_research_agent() -> Agent:
exa_tools = ExaTools()
memory = Memory()
return Agent(
model=OpenAIChat(id="gpt-5"),
tools=[exa_tools],
memory=memory,
instructions=[
"You are ResearchAgent. For each company, collect valuable insights from:",
"1) Their official website (about, blog, product pages)",
"2) Reddit discussions (site:reddit.com mentions)",
"Return 2-4 interesting, non-generic points per company for email personalization.",
],
)
Create the Email Writer Agent:
def create_email_writer_agent(style_key: str = "Professional") -> Agent:
memory = Memory()
style_instruction = get_email_style_instruction(style_key)
return Agent(
model=OpenAIChat(id="gpt-5"),
tools=[],
memory=memory,
instructions=[
"You are EmailWriterAgent. Write concise, personalized B2B outreach emails.",
style_instruction,
"Length: 120-160 words. Include 1-2 lines of personalization using research insights.",
"Return ONLY valid JSON with emails containing company, contact, subject, body.",
],
)
Implement the Multi-Stage Pipeline:
def run_pipeline(target_desc: str, offering_desc: str, sender_name: str,
sender_company: str, calendar_link: Optional[str], num_companies: int):
# Create agents
company_agent = create_company_finder_agent()
contact_agent = create_contact_finder_agent()
research_agent = create_research_agent()
# Execute pipeline stages
companies = run_company_finder(company_agent, target_desc, offering_desc, num_companies)
contacts_data = run_contact_finder(contact_agent, companies, target_desc, offering_desc)
research_data = run_research(research_agent, companies)
return {
"companies": companies,
"contacts": contacts_data,
"research": research_data,
"emails": [],
}
Create the Streamlit Interface:
def main() -> None:
st.set_page_config(page_title="GTM B2B Outreach", layout="wide")
# Sidebar: API keys
st.sidebar.header("API Configuration")
openai_key = st.sidebar.text_input("OpenAI API Key", type="password")
exa_key = st.sidebar.text_input("Exa API Key", type="password")
# Main interface
st.title("GTM B2B Outreach Multi Agent Team")
st.info("Automate B2B outreach with AI-powered research and personalization")
# Input configuration
col1, col2 = st.columns(2)
with col1:
target_desc = st.text_area("Target companies", height=100)
offering_desc = st.text_area("Your offering", height=100)
with col2:
sender_name = st.text_input("Your name")
sender_company = st.text_input("Your company")
num_companies = st.number_input("Number of companies", min_value=1, max_value=10, value=5)
email_style = st.selectbox("Email style", ["Professional", "Casual", "Cold", "Consultative"])
Handle Pipeline Execution:
if st.button("Start Outreach", type="primary"):
if not openai_key or not exa_key:
st.error("Please provide API keys in the sidebar")
else:
progress = st.progress(0)
stage_msg = st.empty()
try:
# Execute multi-stage pipeline
stage_msg.info("1/4 Finding companies...")
# ... pipeline execution logic
progress.progress(100)
stage_msg.success("Completed")
except Exception as e:
stage_msg.error("Pipeline failed")
st.error(f"Error: {str(e)}")
Running the App
With our code in place, it's time to launch the app.
In your terminal, navigate to the project folder and run:
streamlit run ai_email_gtm_outreach_agent.py
Streamlit will provide a local URL (typically http://localhost:8501). Open this in your web browser, enter your API key, and start asking questions about your knowledge base!
Working Application Demo
Conclusion
You've successfully built an AI email outreach agent team that automates hours of manual research and email crafting into a streamlined, intelligent process that delivers personalized, research-backed outreach at scale.
This setup can now be expanded further:
Integration with CRM Systems: Connect the system to Salesforce, HubSpot, or other CRM platforms to automatically log prospects and track outreach campaigns.
Email Sequence Automation: Extend the system to generate multi-touch sequences with follow-up emails based on recipient engagement patterns.
Advanced Targeting: Implement more sophisticated targeting criteria using company size, funding rounds, technology stack, or recent news events.
Analytics: Add tracking for email open rates, response rates, and conversion metrics to optimize messaging strategies.
Keep experimenting with different configurations and features to build more sophisticated AI applications.
We share hands-on tutorials like this 2-3 times a week, to help you stay ahead in the world of AI. If you're serious about leveling up your AI skills and staying ahead of the curve, subscribe now and be the first to access our latest tutorials.
Reply