Skip to content

Commit df35172

Browse files
Merge pull request #443 from MervinPraison/develop
Add WhatsApp and Perplexity MCP Integrations
2 parents 54fdf5a + 083411b commit df35172

13 files changed

Lines changed: 385 additions & 7 deletions

docs/mcp/openrouter.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ flowchart LR
4848
<Step title="Install Dependencies">
4949
Make sure you have Node.js installed, as the MCP server requires it:
5050
```bash
51-
pip install praisonaiagents
51+
pip install "praisonaiagents[llm]"
5252
```
5353
</Step>
5454

docs/mcp/perplexity.mdx

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: "Perplexity MCP Integration"
3+
sidebarTitle: "Perplexity"
4+
description: "Guide for integrating Perplexity search with PraisonAI agents using MCP"
5+
icon: "magnifying-glass"
6+
---
7+
8+
## Add Perplexity Search Tool to AI Agent
9+
10+
```mermaid
11+
flowchart LR
12+
In[In] --> Agent[AI Agent]
13+
Agent --> Tool[Perplexity MCP]
14+
Tool --> Agent
15+
Agent --> Out[Out]
16+
17+
style In fill:#8B0000,color:#fff
18+
style Agent fill:#2E8B57,color:#fff
19+
style Tool fill:#4B0082,color:#fff
20+
style Out fill:#8B0000,color:#fff
21+
```
22+
23+
## Quick Start
24+
25+
<Steps>
26+
<Step title="Set API Key">
27+
Set your Perplexity API key as an environment variable in your terminal:
28+
```bash
29+
export PERPLEXITY_API_KEY=your_perplexity_api_key_here
30+
```
31+
</Step>
32+
33+
<Step title="Create a file">
34+
Create a new file `perplexity_search.py` with the following code:
35+
```python
36+
from praisonaiagents import Agent, MCP
37+
import os
38+
39+
# Get API key from environment variable
40+
api_key = os.getenv("PERPLEXITY_API_KEY")
41+
42+
agent = Agent(
43+
instructions="You are a helpful assistant that can search the web for information. Use the available tools when relevant to answer user questions.",
44+
llm="gpt-4o-mini",
45+
tools=MCP("uvx perplexity-mcp",
46+
env={"PERPLEXITY_API_KEY": api_key, "PERPLEXITY_MODEL": "sonar" })
47+
)
48+
49+
result = agent.start("What is the latest news on AI?, Pass only the query parameter to the tool")
50+
51+
print(result)
52+
```
53+
</Step>
54+
55+
<Step title="Install Dependencies">
56+
Make sure you have the required packages installed:
57+
```bash
58+
pip install "praisonaiagents[llm]"
59+
```
60+
</Step>
61+
62+
<Step title="Run the Agent">
63+
Execute your script:
64+
```bash
65+
python perplexity_search.py
66+
```
67+
</Step>
68+
</Steps>
69+
70+
<Note>
71+
**Requirements**
72+
- Python 3.10 or higher
73+
- Perplexity API key
74+
</Note>
75+
76+
## Features
77+
78+
<CardGroup cols={2}>
79+
<Card title="Web Search" icon="globe">
80+
Search the web for real-time information using Perplexity's powerful search API.
81+
</Card>
82+
<Card title="Sonar Model" icon="radar">
83+
Utilize Perplexity's Sonar model for high-quality search results.
84+
</Card>
85+
<Card title="MCP Integration" icon="plug">
86+
Seamless integration with Model Context Protocol.
87+
</Card>
88+
<Card title="Environment Variables" icon="key">
89+
Securely pass API keys using environment variables.
90+
</Card>
91+
</CardGroup>

docs/mcp/whatsapp.mdx

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
title: "WhatsApp MCP Integration"
3+
sidebarTitle: "WhatsApp"
4+
description: "Guide for integrating WhatsApp messaging with PraisonAI agents using MCP"
5+
icon: "whatsapp"
6+
---
7+
8+
## Add WhatsApp Tool to AI Agent
9+
10+
```mermaid
11+
flowchart LR
12+
In[In] --> Agent[AI Agent]
13+
Agent --> Tool[WhatsApp MCP]
14+
Tool --> Agent
15+
Agent --> Out[Out]
16+
17+
style In fill:#8B0000,color:#fff
18+
style Agent fill:#2E8B57,color:#fff
19+
style Tool fill:#25D366,color:#fff
20+
style Out fill:#8B0000,color:#fff
21+
```
22+
23+
## Quick Start
24+
25+
<Steps>
26+
<Step title="Set Up WhatsApp MCP Server">
27+
Clone and set up the WhatsApp MCP server:
28+
```bash
29+
git clone https://github.com/lharries/whatsapp-mcp.git
30+
cd whatsapp-mcp
31+
cd whatsapp-bridge
32+
go run main.go
33+
```
34+
</Step>
35+
<Step title="Create a file">
36+
Create a new file `whatsapp_message.py` with the following code:
37+
```python
38+
from praisonaiagents import Agent, MCP
39+
40+
whatsapp_agent = Agent(
41+
instructions="Whatsapp Agent",
42+
llm="gpt-4o-mini",
43+
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
44+
)
45+
46+
whatsapp_agent.start("Send Hello to Mervin Praison")
47+
```
48+
49+
Note: Replace `/path/to/whatsapp-mcp` with the actual path to your WhatsApp MCP server.
50+
</Step>
51+
52+
<Step title="Install Dependencies">
53+
Make sure you have the required packages installed:
54+
```bash
55+
pip install "praisonaiagents[llm]" mcp gradio
56+
```
57+
</Step>
58+
<Step title="Export API Key">
59+
```bash
60+
export OPENAI_API_KEY="your_api_key"
61+
```
62+
</Step>
63+
64+
<Step title="Run the Agent">
65+
Execute your script:
66+
```bash
67+
python whatsapp_message.py
68+
```
69+
</Step>
70+
</Steps>
71+
72+
<Note>
73+
**Requirements**
74+
- Python 3.10 or higher
75+
- WhatsApp MCP server set up and configured
76+
</Note>
77+
78+
## Multi-Agent Integration
79+
80+
You can also combine WhatsApp with other MCP tools, such as Airbnb search:
81+
82+
```python
83+
from praisonaiagents import Agent, Agents, MCP
84+
85+
airbnb_agent = Agent(
86+
instructions="""Search for Apartments in Paris for 2 nights on Airbnb. 04/28 - 04/30 for 2 adults""",
87+
llm="gpt-4o-mini",
88+
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
89+
)
90+
91+
whatsapp_agent = Agent(
92+
instructions="""Send AirBnb Search Result to 'Mervin Praison'""",
93+
llm="gpt-4o-mini",
94+
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
95+
)
96+
97+
agents = Agents(agents=[airbnb_agent, whatsapp_agent])
98+
99+
agents.start()
100+
```
101+
102+
## Alternative LLM Integrations
103+
104+
### Using Groq with WhatsApp
105+
106+
```python
107+
from praisonaiagents import Agent, MCP
108+
109+
whatsapp_agent = Agent(
110+
instructions="Whatsapp Agent",
111+
llm="groq/llama-3.2-90b-vision-preview",
112+
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
113+
)
114+
115+
whatsapp_agent.start("Send Hello to Mervin Praison")
116+
```
117+
118+
### Using Ollama with WhatsApp
119+
120+
```python
121+
from praisonaiagents import Agent, MCP
122+
123+
whatsapp_agent = Agent(
124+
instructions="Whatsapp Agent",
125+
llm="ollama/llama3.2",
126+
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
127+
)
128+
129+
whatsapp_agent.start("Send Hello to Mervin Praison. Use send_message tool, recipient and message are the required parameters.")
130+
```
131+
132+
## Gradio UI Integration
133+
134+
Create a Gradio UI for your WhatsApp and Airbnb integration:
135+
136+
```python
137+
from praisonaiagents import Agent, Agents, MCP
138+
import gradio as gr
139+
140+
def search_airbnb(query):
141+
airbnb_agent = Agent(
142+
instructions=query+" on Airbnb",
143+
llm="gpt-4o-mini",
144+
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
145+
)
146+
147+
whatsapp_agent = Agent(
148+
instructions="""Send AirBnb Search Result to 'Mervin Praison'. Don't include Phone Number in Response, but include the AirBnb Search Result""",
149+
llm="gpt-4o-mini",
150+
tools=MCP("python /path/to/whatsapp-mcp/whatsapp-mcp-server/main.py")
151+
)
152+
153+
agents = Agents(agents=[airbnb_agent, whatsapp_agent])
154+
155+
result = agents.start()
156+
return f"## Airbnb Search Results\n\n{result}"
157+
158+
demo = gr.Interface(
159+
fn=search_airbnb,
160+
inputs=gr.Textbox(placeholder="I want to book an apartment in Paris for 2 nights..."),
161+
outputs=gr.Markdown(),
162+
title="WhatsApp MCP Agent",
163+
description="Enter your booking requirements below:"
164+
)
165+
166+
if __name__ == "__main__":
167+
demo.launch()
168+
```
169+
170+
## Features
171+
172+
<CardGroup cols={2}>
173+
<Card title="WhatsApp Messaging" icon="message">
174+
Send messages to WhatsApp contacts directly from your AI agent.
175+
</Card>
176+
<Card title="Multi-Agent Support" icon="users">
177+
Combine WhatsApp with other MCP tools for complex workflows.
178+
</Card>
179+
<Card title="Multiple LLM Options" icon="brain">
180+
Use with OpenAI, Groq, Ollama, or other supported LLMs.
181+
</Card>
182+
<Card title="Gradio UI" icon="window">
183+
Create user-friendly interfaces for your WhatsApp integrations.
184+
</Card>
185+
</CardGroup>

docs/mcp/xai.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ flowchart LR
4848
<Step title="Install Dependencies">
4949
Make sure you have Node.js installed, as the MCP server requires it:
5050
```bash
51-
pip install praisonaiagents
51+
pip install "praisonaiagents[llm]"
5252
```
5353
</Step>
5454

docs/mint.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@
246246
"mcp/anthropic",
247247
"mcp/gemini",
248248
"mcp/mistral",
249+
"mcp/whatsapp",
250+
"mcp/perplexity",
249251
"mcp/ollama-python",
250252
"mcp/bravesearch",
251253
"mcp/custom",

examples/mcp/perplexity-mcp.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from praisonaiagents import Agent, MCP
2+
import os
3+
4+
api_key = os.getenv("PERPLEXITY_API_KEY")
5+
6+
agent = Agent(
7+
instructions="You are a helpful assistant that can search the web for information. Use the available tools when relevant to answer user questions.",
8+
llm="gpt-4o-mini",
9+
tools=MCP("uvx perplexity-mcp",
10+
env={"PERPLEXITY_API_KEY": api_key, "PERPLEXITY_MODEL": "sonar" })
11+
)
12+
result = agent.start("What is the latest news on AI?, Pass only the query parameter to the tool")
13+
14+
print(result)

examples/mcp/whatapp-groq-mcp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from praisonaiagents import Agent, MCP
2+
3+
whatsapp_agent = Agent(
4+
instructions="Whatsapp Agent",
5+
llm="groq/llama-3.2-90b-vision-preview",
6+
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
7+
)
8+
9+
whatsapp_agent.start("Send Hello to Mervin Praison")

examples/mcp/whatapp-mcp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from praisonaiagents import Agent, MCP
2+
3+
whatsapp_agent = Agent(
4+
instructions="Whatsapp Agent",
5+
llm="gpt-4o-mini",
6+
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
7+
)
8+
9+
whatsapp_agent.start("Send Hello to Mervin Praison")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from praisonaiagents import Agent, Agents, MCP
2+
3+
airbnb_agent = Agent(
4+
instructions="""Search for Apartments in Paris for 2 nights on Airbnb. 04/28 - 04/30 for 2 adults""",
5+
llm="gpt-4o-mini",
6+
tools=MCP("npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
7+
)
8+
9+
whatsapp_agent = Agent(
10+
instructions="""Send AirBnb Search Result to 'Mervin Praison'""",
11+
llm="gpt-4o-mini",
12+
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
13+
)
14+
15+
agents = Agents(agents=[airbnb_agent, whatsapp_agent])
16+
17+
agents.start()

examples/mcp/whatapp-ollama-mcp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from praisonaiagents import Agent, MCP
2+
3+
whatsapp_agent = Agent(
4+
instructions="Whatsapp Agent",
5+
llm="ollama/llama3.2",
6+
tools=MCP("python /Users/praison/whatsapp-mcp/whatsapp-mcp-server/main.py")
7+
)
8+
9+
whatsapp_agent.start("Send Hello to Mervin Praison. Use send_message tool, recipient and message are the required parameters.")

0 commit comments

Comments
 (0)