AI Market Research Agent

This project demonstrates how to use Composio to create a market research agent.

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

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
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.TAVILY, App.GOOGLEDOCS])
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 market research agent that finds niche ideas that can be built and marketed.
7 Your users are primarily indie hackers who want to build something new and are looking for ideas. The input will
8 be a domain or a category and your job is to research extensively and find ideas that can be marketed.
9 Write this content in a google doc, create a google doc before writing in it.
10 I want you to show the following content:
11 - Data Collection and Aggregation - Show data supporting a trend
12 - Sentiment Analysis - Show customer sentiment on the topic
13 - Trend Forecasting
14 - Competitor Analysis
15 - Competitor Benchmarking
16 - Idea Validation
17 """
18 )
19 )
20]
21agent = FunctionCallingAgentWorker(
22 tools=tools,
23 llm=llm,
24 prefix_messages=prefix_messages,
25 max_function_calls=10,
26 allow_parallel_tool_calls=False,
27 verbose=True,
28).as_agent()
6

Executing the Agent

run the agent
1a = input('Enter the domain or category you want to research about:')
2task = f"""
3The 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.
4"""
5response = agent.chat(task)
6print(response)
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 llama_index.llms.cerebras import Cerebras
6from llama_index.llms.groq import Groq
7from dotenv import load_dotenv
8from pathlib import Path
9import os
10
11load_dotenv()
12llm = OpenAI(model='gpt-4o')
13#llm = Groq(model="llama3-groq-70b-8192-tool-use-preview")
14#llm = Cerebras(model="llama3.1-70b")
15composio_toolset = ComposioToolSet()
16tools = composio_toolset.get_tools(apps = [App.TAVILY, App.GOOGLEDOCS])
17
18prefix_messages = [
19 ChatMessage(
20 role="system",
21 content=(
22 f"""
23 You are a market research agent that finds niche ideas that can be built and marketed.
24 Your users are primarily indie hackers who want to build something new and are looking for ideas. The input will
25 be a domain or a category and your job is to research extensively and find ideas that can be marketed.
26 Write this content in a google doc, create a google doc before writing in it.
27 I want you to show the following content:
28 - Data Collection and Aggregation - Show data supporting a trend
29 - Sentiment Analysis - Show customer sentiment on the topic
30 - Trend Forecasting
31 - Competitor Analysis
32 - Competitor Benchmarking
33 - Idea Validation
34 """
35 )
36 )
37]
38
39
40agent = FunctionCallingAgentWorker(
41 tools=tools,
42 llm=llm,
43 prefix_messages=prefix_messages,
44 max_function_calls=10,
45 allow_parallel_tool_calls=False,
46 verbose=True,
47).as_agent()
48
49
50a = input('Enter the domain or category you want to research about:')
51task = f"""
52The 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.
53"""
54response = agent.chat(task)
55print(response)