AI Outreach Agent

This project demonstrates how to use Composio to create an outreach agent.

Overview

This agent automates lead outreach by crafting personalized emails tailored to each lead and sending them instantly. Designed to optimize engagement and streamline your sales process, the AI Outreach Agent helps businesses save time and improve the effectiveness of their email campaigns.

Getting Started

1

Installation

install the required dependencies
$pip install composio-core
2

Connecting to tools and models

connect to required tools
$composio add gmail
>composio add hubspot
>
>export OPENAI_API_KEY="<your-openai-api-key>"
3

Importing the required libraries

import required libraries
1from composio_llamaindex import ComposioToolSet, App, Action
2from llama_index.core.agent import FunctionCallingAgentWorker
3from llama_index.core.llms import ChatMessage
4from llama_index.llms.openai import OpenAI
5from dotenv import load_dotenv
6
7load_dotenv()
4

Initializing the Tools and the LLM

initialize toolset and llm
1toolset = ComposioToolSet(api_key="")
2tools = toolset.get_tools(apps=[App.HUBSPOT, App.GMAIL])
3
4llm = OpenAI(model="gpt-4o")
5

Setting up Function Calling Worker

setup function calling worker
1prefix_messages = [
2 ChatMessage(
3 role="system",
4 content=(
5 f"""
6 "You are a Lead Outreach Agent that is has access to the CRM through HubSpot."
7 "and is an expert writer. Your job is to first research some info about the lead "
8 "given to you and then draft a perfect ideal email for whatever input task is given to you. "
9 """
10 ),
11 )
12]
13
14agent = FunctionCallingAgentWorker(
15 tools=tools,
16 llm=llm,
17 prefix_messages=prefix_messages,
18 max_function_calls=10,
19 allow_parallel_tool_calls=False,
20 verbose=True,
21).as_agent()
6

Executing the Agent

execute the agent
1user_input = f"Draft an email for each lead in my Hubspot contacts page introducing yourself and asking them if they're interested in integrating AI Agents in their workflow."
2response = agent.chat(user_input)
7

Final Code

final code
1from composio_llamaindex import ComposioToolSet, App, Action
2from llama_index.core.agent import FunctionCallingAgentWorker
3from llama_index.core.llms import ChatMessage
4from llama_index.llms.openai import OpenAI
5from dotenv import load_dotenv
6
7load_dotenv()
8toolset = ComposioToolSet(api_key="")
9tools = toolset.get_tools(apps=[App.PEOPLEDATALABS, App.GOOGLESHEETS])
10
11llm = OpenAI(model="gpt-4o")
12
13prefix_messages = [
14 ChatMessage(
15 role="system",
16 content=(
17 f"""
18 "You are a Lead Outreach Agent that is has access to the CRM through HubSpot."
19 "and is an expert writer. Your job is to first research some info about the lead "
20 "given to you and then draft a perfect ideal email for whatever input task is given to you. "
21 """
22 ),
23 )
24]
25
26agent = FunctionCallingAgentWorker(
27 tools=tools,
28 llm=llm,
29 prefix_messages=prefix_messages,
30 max_function_calls=10,
31 allow_parallel_tool_calls=False,
32 verbose=True,
33).as_agent()
34
35user_input = f"Draft an email for each lead in my Hubspot contacts page introducing yourself and asking them if they're interested in integrating AI Agents in their workflow."
36response = agent.chat(user_input)