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
- Python
- Javascript
Connecting to tools and models
connect to required tools
composio add peopledatalabs
composio add googlesheets
export OPENAI_API_KEY="<your-openai-api-key>"
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()
Initializing the Tools and the LLM
initialize toolset and llm
toolset = ComposioToolSet(api_key="")
tools = toolset.get_tools(apps=[App.PEOPLEDATALABS, App.GOOGLESHEETS])
llm = OpenAI(model="gpt-4o")
Setting up Function Calling Worker
setup function calling worker
spreadsheetid = '14T4e0j1XsWjriQYeFMgkM2ihyvLAplPqB9q8hytytcw'
prefix_messages = [
ChatMessage(
role="system",
content=(
f"""
You are a lead research agent. Based on user input, find 10 relevant leads using people data labs.
After finding the leads, create a Google Sheet with the details for the lead description, and spreadsheet ID: ${spreadsheetid}.
Print the list of people and their details and the link to the google sheet."""
),
)
]
agent = FunctionCallingAgentWorker(
tools=tools,
llm=llm,
prefix_messages=prefix_messages,
max_function_calls=10,
allow_parallel_tool_calls=False,
verbose=True,
).as_agent()
Executing the Agent
run the agent
lead_description = 'Senior frontend developers in San Francisco'
user_input = f"Create a lead list based on the description: {lead_description}"
response = agent.chat(user_input)
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")
spreadsheetid = '14T4e0j1XsWjriQYeFMgkM2ihyvLAplPqB9q8hytytcw'
prefix_messages = [
ChatMessage(
role="system",
content=(
f"""
You are a lead research agent. Based on user input, find 10 relevant leads using people data labs.
After finding the leads, create a Google Sheet with the details for the lead description, and spreadsheet ID: ${spreadsheetid}.
Print the list of people and their details and the link to the google sheet."""
),
)
]
agent = FunctionCallingAgentWorker(
tools=tools,
llm=llm,
prefix_messages=prefix_messages,
max_function_calls=10,
allow_parallel_tool_calls=False,
verbose=True,
).as_agent()
lead_description = 'Senior frontend developers in San Francisco'
user_input = f"Create a lead list based on the description: {lead_description}"
response = agent.chat(user_input)
Connecting to tools and models
connect to required tools
composio add peopledatalabs
composio add googlesheets
export OPENAI_API_KEY="<your-openai-api-key>"
export COMPOSIO_API_KEY="<your-composio-api-key>"
Importing the required libraries
import required libraries
import { openai } from "@ai-sdk/openai";
import { VercelAIToolSet } from "composio-core";
import dotenv from "dotenv";
import { generateText } from "ai";
dotenv.config();
Initializing the Tools and the LLM
initialize toolset and llm
const toolset = new VercelAIToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
});
const tools = await toolset.getTools([App.PEOPLEDATALABS, App.GOOGLESHEETS]);
Setting up Agent
setup the ai agent
const leadDescription = 'Senior frontend developers in San Francisco';
const spreadsheetid='14T4e0j1XsWjriQYeFMgkM2ihyvLAplPqB9q8hytytcw'
const output = await generateText({
model: openai("gpt-4o"),
streamText: false,
tools: tools,
prompt: `
You are a lead research agent. Based on user input, find 10 relevant leads using people data labs.
After finding the leads, create a Google Sheet with the details for the lead description: ${leadDescription}, and spreadsheet ID: ${spreadsheetid}.
Print the list of people and their details and the link to the google sheet.
`,
maxToolRoundtrips: 5,
});
Final Code
final code
import { openai } from "@ai-sdk/openai";
import { VercelAIToolSet } from "composio-core";
import dotenv from "dotenv";
import { generateText } from "ai";
dotenv.config();
const toolset = new VercelAIToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
});
const tools = await toolset.getTools([App.PEOPLEDATALABS, App.GOOGLESHEETS]);
const leadDescription = 'Senior frontend developers in San Francisco';
const spreadsheetid='14T4e0j1XsWjriQYeFMgkM2ihyvLAplPqB9q8hytytcw'
const output = await generateText({
model: openai("gpt-4o"),
streamText: false,
tools: tools,
prompt: `
You are a lead research agent. Based on user input, find 10 relevant leads using people data labs.
After finding the leads, create a Google Sheet with the details for the lead description: ${leadDescription}, and spreadsheet ID: ${spreadsheetid}.
Print the list of people and their details and the link to the google sheet.
`,
maxToolRoundtrips: 5,
});
console.log("🎉Output from agent: ", output.text);