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
from composio_llamaindex import ComposioToolSet, App, Action
from llama_index.core.agent import FunctionCallingAgentWorker
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv

load_dotenv()
4

Initializing the Tools and the LLM

initialize toolset and llm
toolset = ComposioToolSet(api_key="")
tools = toolset.get_tools(apps=[App.HUBSPOT, App.GMAIL])

llm = OpenAI(model="gpt-4o")
5

Setting up Function Calling Worker

setup function calling worker
prefix_messages = [
    ChatMessage(
        role="system",
        content=(
            f"""
            "You are a Lead Outreach Agent that is has access to the CRM through HubSpot."
            "and is an expert writer. Your job is to first research some info about the lead "
            "given to you and then draft a perfect ideal email for whatever input task is given to you. "
            """
        ),
    )
]

agent = FunctionCallingAgentWorker(
    tools=tools,
    llm=llm,
    prefix_messages=prefix_messages,
    max_function_calls=10,
    allow_parallel_tool_calls=False,
    verbose=True,
).as_agent()
6

Executing the Agent

execute the agent
user_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."
response = agent.chat(user_input)
7

Final Code

final code
from composio_llamaindex import ComposioToolSet, App, Action
from llama_index.core.agent import FunctionCallingAgentWorker
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv

load_dotenv()
toolset = ComposioToolSet(api_key="")
tools = toolset.get_tools(apps=[App.PEOPLEDATALABS, App.GOOGLESHEETS])

llm = OpenAI(model="gpt-4o")

prefix_messages = [
    ChatMessage(
        role="system",
        content=(
            f"""
            "You are a Lead Outreach Agent that is has access to the CRM through HubSpot."
            "and is an expert writer. Your job is to first research some info about the lead "
            "given to you and then draft a perfect ideal email for whatever input task is given to you. "
            """
        ),
    )
]

agent = FunctionCallingAgentWorker(
    tools=tools,
    llm=llm,
    prefix_messages=prefix_messages,
    max_function_calls=10,
    allow_parallel_tool_calls=False,
    verbose=True,
).as_agent()

user_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."
response = agent.chat(user_input)