Skip to content

Commit 237245f

Browse files
committed
Refactor WhatsApp chat agent to use DuckDuckGo for web searches
- Replaced YFinanceTools with DuckDuckGoTools for improved search capabilities. - Updated agent description to reflect the new functionality and interaction style. - Removed duplicate webhook URL export from README for clarity.
1 parent edb891a commit 237245f

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

cookbook/examples/apps/whatsapp_chat_agent/agents.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from agno.agent import Agent
55
from agno.models.openai import OpenAIChat
66
from agno.storage.agent.sqlite import SqliteAgentStorage
7+
from agno.tools.duckduckgo import DuckDuckGoTools
78
from agno.tools.whatsapp import WhatsAppTools
8-
from agno.tools.yfinance import YFinanceTools
99
from dotenv import load_dotenv
1010

1111
# Configure logging
@@ -42,20 +42,13 @@ def get_whatsapp_agent() -> Agent:
4242
model=OpenAIChat(id="gpt-4o"),
4343
tools=[
4444
whatsapp,
45-
YFinanceTools(
46-
stock_price=True,
47-
analyst_recommendations=True,
48-
stock_fundamentals=True,
49-
historical_prices=True,
50-
company_info=True,
51-
company_news=True,
52-
),
45+
DuckDuckGoTools(),
5346
],
5447
storage=SqliteAgentStorage(
5548
table_name="whatsapp_agent", db_file=AGENT_STORAGE_FILE
5649
),
5750
add_history_to_messages=True,
5851
num_history_responses=3,
5952
markdown=True,
60-
description="You are a financial advisor and can help with stock-related queries. You will respond like how people talk to each other on whatsapp, with short sentences and simple language. don't add markdown to your responses.",
53+
description="You are a whatsapp chat agent. You will respond like how people talk to each other on whatsapp, with short sentences and simple language. If user asks you something which requires a web search, use the DuckDuckGoTools to search the web.",
6154
)

cookbook/examples/apps/whatsapp_chat_agent/readme.md

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export WHATSAPP_PHONE_NUMBER_ID=your_phone_number_id
4343
export WHATSAPP_RECIPIENT_WAID=phone_number_with_country_code # e.g. +1234567890
4444
export WHATSAPP_WEBHOOK_URL=your_webhook_url
4545
export WHATSAPP_VERIFY_TOKEN=your_custom_verify_token # Can be any string you choose
46-
export WHATSAPP_WEBHOOK_URL=your_webhook_url
4746
export OPENAI_API_KEY=your_openai_api_key
4847
```
4948

libs/agno/agno/tools/whatsapp.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _log_config_status(self):
7575
"Optional settings": {
7676
"default_recipient": bool(self.default_recipient),
7777
"api_version": self.version,
78-
"async_mode": self.async_mode
78+
"async_mode": self.async_mode,
7979
},
8080
}
8181
logger.debug(f"WhatsApp toolkit configuration status: {json.dumps(config_status, indent=2)}")
@@ -225,7 +225,9 @@ def send_template_message_sync(
225225
logger.error(f"Failed to send WhatsApp template message: {e}")
226226
raise
227227

228-
async def send_text_message_async(self, text: str = "", recipient: Optional[str] = None, preview_url: bool = False) -> str:
228+
async def send_text_message_async(
229+
self, text: str = "", recipient: Optional[str] = None, preview_url: bool = False
230+
) -> str:
229231
"""Send a text message to a WhatsApp user (asynchronous version).
230232
231233
Args:

0 commit comments

Comments
 (0)