AI Lead Generator Agent

This project demonstrates how to use Composio to create a lead generation agent.

Overview

The AI Lead Generator Agent is a powerful tool built using Composio’s tooling ecosystem and agentic frameworks such as LlamaIndex. This agent streamlines the lead generation process for businesses by identifying potential leads, extracting valuable data, and organizing all lead information into a structured spreadsheet. With a user-friendly setup process and seamless integration capabilities, this agent can significantly enhance your outreach efficiency and sales pipeline management.

Getting Started

1

Installation

install dependencies
$pip install composio-llamaindex python-dotenv
2

Connecting to tools and models

connect to required tools
$composio add peopledatalabs
>composio add googlesheets
>
>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.PEOPLEDATALABS, App.GOOGLESHEETS])
3
4llm = OpenAI(model="gpt-4o")
5

Setting up Function Calling Worker

setup function calling worker
1spreadsheetid = '14T4e0j1XsWjriQYeFMgkM2ihyvLAplPqB9q8hytytcw'
2prefix_messages = [
3 ChatMessage(
4 role="system",
5 content=(
6 f"""
7 You are a lead research agent. Based on user input, find 10 relevant leads using people data labs.
8 After finding the leads, create a Google Sheet with the details for the lead description, and spreadsheet ID: ${spreadsheetid}.
9 Print the list of people and their details and the link to the google sheet."""
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

run the agent
1lead_description = 'Senior frontend developers in San Francisco'
2user_input = f"Create a lead list based on the description: {lead_description}"
3response = 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
13spreadsheetid = '14T4e0j1XsWjriQYeFMgkM2ihyvLAplPqB9q8hytytcw'
14prefix_messages = [
15 ChatMessage(
16 role="system",
17 content=(
18 f"""
19 You are a lead research agent. Based on user input, find 10 relevant leads using people data labs.
20 After finding the leads, create a Google Sheet with the details for the lead description, and spreadsheet ID: ${spreadsheetid}.
21 Print the list of people and their details and the link to the google sheet."""
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
35lead_description = 'Senior frontend developers in San Francisco'
36user_input = f"Create a lead list based on the description: {lead_description}"
37response = agent.chat(user_input)