← Back to Projects
IntermediateLangGraphTavily APIOpenAI
Build a Sales Agent
In this project, we will build a multi-step agent using LangGraph. The agent will accept a company name, research it using a search tool, identify key value propositions, and draft a cold outreach email.
Architecture
User Input (Company Name) --> [Research Node] --> Search API --> [Synthesis Node] --> Identify Pain Points --> [Drafting Node] --> LLM Generation --> Final Email Draft
Implementation Steps
1
Environment Setup
Install LangGraph and configure API keys for OpenAI and Tavily.
2
Define the State
Create a TypedDict state to hold the company info, research notes, and draft.
3
Implement Research Node
Write a function that calls the search API and summarizes top 3 results.
4
Implement Drafting Node
Prompt the LLM to write an email based *only* on the research notes.
5
Connect the Graph
Wire the nodes together and compile the graph.
Code Structure
agent.py
from typing import TypedDict
from langgraph.graph import StateGraph, END
class AgentState(TypedDict):
company: str
research: str
draft: str
def research_node(state: AgentState):
# Call search tool
return {"research": "..."}
def draft_node(state: AgentState):
# Call LLM
return {"draft": "..."}
workflow = StateGraph(AgentState)
workflow.add_node("research", research_node)
workflow.add_node("draft", draft_node)
workflow.set_entry_point("research")
...Ready to start?