Add the official WhatsApp API to your app with OpenAI Codex
Give OpenAI Codex the official WhatsApp Business API through one MCP entry in config.toml.
What you can ask Codex to do
- Add WhatsApp notifications or two-way messaging to your codebase and test with a real message.
- Create the Gambot account and guide you through the one browser step with Meta.
- Pick text vs. template from the 24-hour window, send, and confirm delivery.
- Register and test a webhook for incoming messages.
Requirements
- No Gambot account yet? Connect the server without a token and ask your agent to “set up WhatsApp with Gambot”. It creates a free-trial account for you (no API key needed) and hands you one link to connect your WhatsApp number to Meta in the browser — that single step must be done by a person. Prefer the browser? Create an account.
- After WhatsApp is connected, copy your API token (
gmbt_…) from Settings → General into an environment variable — never into the chat. Where the client supports it, sign in with OAuth on the hosted server instead and there is no token to copy. - Node.js 18+ (Codex starts the server with npx).
Setup
Add to config.toml
Put the block below in ~/.codex/config.toml (Codex CLI and IDE extension share it), or use: codex mcp add gambot -- npx -y gambot-mcp.
Provide the token (optional at first)
Leave GAMBOT_TOKEN out to start in onboarding mode; add it once WhatsApp is connected. Keep it in your shell environment rather than the file where possible.
Restart and check
Restart Codex and confirm the gambot tools are listed.
Ask
“Use Gambot to add the official WhatsApp API to this project.”
~/.codex/config.toml
[mcp_servers.gambot]
command = "npx"
args = ["-y", "gambot-mcp"]
# After WhatsApp is connected, add your token (from Settings → General):
# env = { GAMBOT_TOKEN = "gmbt_your_token_here" }Example prompts
You Set up WhatsApp for my app with Gambot and send a test message to my own number.
You Is the 24-hour window open for this customer, or do I need a template?
You List my approved WhatsApp templates and send the order_update template to this number.
You Register a webhook so my backend receives incoming WhatsApp messages, then send a test event.
Troubleshooting
- Tools not showing? Restart the client after editing its MCP config, then check its MCP/tools panel for “gambot”.
- AUTHENTICATION_REQUIRED? The token is missing or invalid. Copy a fresh one from Settings → General.
- CONVERSATION_WINDOW_CLOSED? The 24-hour window is closed — send an approved template instead. This is WhatsApp behavior, and the error tells the agent exactly that (
template_required: true). - Is the WhatsApp number connected? Ask the agent to run
gambot_setup_whatsapp_integration; it reports the exact state and the next step. - Codex versions differ in how they support remote (HTTP/OAuth) MCP servers. If yours does not, use the local npx server above; the hosted URL is
https://gambot-mcp.azurewebsites.net/mcpfor clients that support Streamable HTTP with OAuth.
Related
- WhatsApp MCP overview — the full server, tools and hosted option.
- Other clients: Claude Desktop, Claude Code, Cursor, Gemini CLI, ChatGPT, VS Code / Copilot, Windsurf, Replit, Lovable, Base44.
- Gambot Agent Skill — teach any compatible agent the whole WhatsApp integration path.
- Official API vs WhatsApp Web automation — why production should use the official API.
- REST API docs · gambot-mcp on GitHub · npm
Add WhatsApp to your app
One config entry, one account, one browser step with Meta — then your first WhatsApp message.
Frequently asked questions
How do I add the official WhatsApp API to my application using OpenAI Codex?
Add a [mcp_servers.gambot] entry with command "npx" and args ["-y", "gambot-mcp"] to ~/.codex/config.toml (or run codex mcp add gambot -- npx -y gambot-mcp), restart Codex, and ask it to set up WhatsApp with Gambot. Gambot is a Meta Business Solution Provider, so it is the official WhatsApp Business API.
Does Codex need a token to start?
No. Without GAMBOT_TOKEN the server runs in onboarding mode and can create the account. Add the token after WhatsApp is connected.
Is this WhatsApp Web automation?
No. There is no QR code or linked-device session. Messages go through Meta’s WhatsApp Business (Cloud) API.