Code

cookbook/tools/whatsapp_tools.py
from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.whatsapp import WhatsAppTools

agent = Agent(
    name="whatsapp",
    model=Gemini(id="gemini-2.0-flash"),
    tools=[WhatsAppTools()],
)

# Example: Send a template message
# Note: Replace '''hello_world''' with your actual template name
agent.print_response(
    "Send a template message using the '''hello_world''' template in English to +91 1234567890"
)

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.

python3 -m venv .venv
source .venv/bin/activate
2

Set up WhatsApp Business API

  1. Go to Meta for Developers
  2. Create a Meta App and set up the WhatsApp Business API.
  3. Obtain your Phone Number ID and a permanent System User Access Token.
3

Set your API keys and identifiers

export WHATSAPP_ACCESS_TOKEN=xxx
export WHATSAPP_PHONE_NUMBER_ID=xxx
export OPENAI_API_KEY=xxx # Or your preferred LLM API key
4

Install libraries

pip install -U agno openai google-generativeai # Add any other necessary WhatsApp SDKs
5

Run Agent

python cookbook/tools/whatsapp_tools.py