Overview
The AI Market Research Agent is a powerful SDR built using Composio’s tooling ecosystem and LlamaIndex agentic framework. The agent uses Tavily to find niche ideas that can be built and marketed. 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
1
Installation
install dependencies
pip install composio-llamaindex python-dotenv
2
Connecting to tools and models
connect to required tools
composio add tavily
composio add googledocs
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.TAVILY, App.GOOGLEDOCS])
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 market research agent that finds niche ideas that can be built and marketed.
Your users are primarily indie hackers who want to build something new and are looking for ideas. The input will
be a domain or a category and your job is to research extensively and find ideas that can be marketed.
Write this content in a google doc, create a google doc before writing in it.
I want you to show the following content:
- Data Collection and Aggregation - Show data supporting a trend
- Sentiment Analysis - Show customer sentiment on the topic
- Trend Forecasting
- Competitor Analysis
- Competitor Benchmarking
- Idea Validation
"""
)
)
]
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
run the agent
a = input('Enter the domain or category you want to research about:')
task = f"""
The domain or category you want to research about is {a}. Use all the tools available to you to find and gather more insights on customers and market.
"""
response = agent.chat(task)
print(response)
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 llama_index.llms.cerebras import Cerebras
from llama_index.llms.groq import Groq
from dotenv import load_dotenv
from pathlib import Path
import os
load_dotenv()
llm = OpenAI(model='gpt-4o')
#llm = Groq(model="llama3-groq-70b-8192-tool-use-preview")
#llm = Cerebras(model="llama3.1-70b")
composio_toolset = ComposioToolSet()
tools = composio_toolset.get_tools(apps = [App.TAVILY, App.GOOGLEDOCS])
prefix_messages = [
ChatMessage(
role="system",
content=(
f"""
You are a market research agent that finds niche ideas that can be built and marketed.
Your users are primarily indie hackers who want to build something new and are looking for ideas. The input will
be a domain or a category and your job is to research extensively and find ideas that can be marketed.
Write this content in a google doc, create a google doc before writing in it.
I want you to show the following content:
- Data Collection and Aggregation - Show data supporting a trend
- Sentiment Analysis - Show customer sentiment on the topic
- Trend Forecasting
- Competitor Analysis
- Competitor Benchmarking
- Idea Validation
"""
)
)
]
agent = FunctionCallingAgentWorker(
tools=tools,
llm=llm,
prefix_messages=prefix_messages,
max_function_calls=10,
allow_parallel_tool_calls=False,
verbose=True,
).as_agent()
a = input('Enter the domain or category you want to research about:')
task = f"""
The domain or category you want to research about is {a}. Use all the tools available to you to find and gather more insights on customers and market.
"""
response = agent.chat(task)
print(response)
1
Installation
install dependencies
npm install composio-core langchain dotenv @langchain/openai
2
Connecting to tools and models
connect to required tools
composio add tavily
export OPENAI_API_KEY="<your-openai-api-key>"
export COMPOSIO_API_KEY="<your-composio-api-key>"
3
Importing the required libraries
import required libraries
import { ChatOpenAI } from "@langchain/openai";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { pull } from "langchain/hub";
import dotenv from 'dotenv';
import { LangchainToolSet } from "composio-core";
dotenv.config();
4
Initializing the Tools and the LLM
initialize toolset and llm
const llm = new ChatOpenAI({
model: "gpt-4-turbo",
apiKey: process.env.OPENAI_API_KEY,
});
const toolset = new LangchainToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
});
const tools = await toolset.getTools({
apps: ["tavily","googledocs"]
});
5
Setting up Agent
setup the ai agent
const prompt = await pull("hwchase17/openai-functions-agent");
const additional = `You are a market research agent that finds niche ideas that can be built and marketed.
Your users are primarily indie hackers who want to build something new and are looking for ideas. The input will
be a domain or a category and your job is to research extensively and find ideas that can be marketed.
Write this content in a google doc, create a google doc before writing in it.
I want you to show the following content:
- Data Collection and Aggregation - Show data supporting a trend
- Sentiment Analysis - Show customer sentiment on the topic
- Trend Forecasting
- Competitor Analysis
- Competitor Benchmarking
- Idea Validation`;
const agent = await createOpenAIFunctionsAgent({
llm,
tools,
prompt,
});
6
Executing the Agent
execute the agent
const agentExecutor = new AgentExecutor({
agent,
tools,
verbose: true,
});
const domain = 'AI SaaS'
const result = await agentExecutor.invoke({
input: additional + 'This is the domain:' + domain
});
console.log('🎉Output from agent: ', result.output);
7
Final Code
final code
import { ChatOpenAI } from "@langchain/openai";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { pull } from "langchain/hub";
import dotenv from 'dotenv';
import { LangchainToolSet } from "composio-core";
dotenv.config();
const llm = new ChatOpenAI({
model: "gpt-4-turbo",
apiKey: process.env.OPENAI_API_KEY,
});
const toolset = new LangchainToolSet({
apiKey: process.env.COMPOSIO_API_KEY,
});
const tools = await toolset.getTools({
apps: ["tavily","googledocs"]
});
const prompt = await pull("hwchase17/openai-functions-agent");
const additional = `You are a market research agent that finds niche ideas that can be built and marketed.
Your users are primarily indie hackers who want to build something new and are looking for ideas. The input will
be a domain or a category and your job is to research extensively and find ideas that can be marketed.
Write this content in a google doc, create a google doc before writing in it.
I want you to show the following content:
- Data Collection and Aggregation - Show data supporting a trend
- Sentiment Analysis - Show customer sentiment on the topic
- Trend Forecasting
- Competitor Analysis
- Competitor Benchmarking
- Idea Validation`;
const agent = await createOpenAIFunctionsAgent({
llm,
tools,
prompt,
});
const agentExecutor = new AgentExecutor({
agent,
tools,
verbose: true,
});
const domain = 'AI SaaS'
const result = await agentExecutor.invoke({
input: additional + 'This is the domain:' + domain
});
console.log('🎉Output from agent: ', result.output);