> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# WhatsApp 工具

## 代码

```python cookbook/tools/whatsapp_tools.py theme={null}
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()],
)

# 示例：发送模板消息
# 注意：将 '''hello_world''' 替换为你的实际模板名称
agent.print_response(
    "使用英文模板 '''hello_world''' 向 +91 1234567890 发送模板消息"
)
```

## 用法

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="设置 WhatsApp Business API">
    1. 前往 [Meta for Developers](https://developers.facebook.com/docs/whatsapp/cloud-api/get-started)
    2. 创建一个 Meta 应用并设置 WhatsApp Business API。
    3. 获取你的手机号码 ID 和一个永久性的系统用户访问令牌。
  </Step>

  <Step title="设置你的 API 密钥和标识符">
    ```bash theme={null}
    export WHATSAPP_ACCESS_TOKEN=xxx
    export WHATSAPP_PHONE_NUMBER_ID=xxx
    export OPENAI_API_KEY=xxx # 或你偏好的 LLM API 密钥
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U agno openai google-generativeai # 添加任何其他必要的 WhatsApp SDK
    ```
  </Step>

  <Step title="运行 Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/tools/whatsapp_tools.py
      ```

      ```bash Windows theme={null}
      python cookbook/tools/whatsapp_tools.py
      ```
    </CodeGroup>
  </Step>
</Steps>
