Add the official WhatsApp API to your app with VS Code and GitHub Copilot
Use GitHub Copilot agent mode in VS Code with the Gambot MCP server to wire the official WhatsApp Business API into your project.
What you can ask Copilot to do
- Create a Gambot account and walk you through connecting WhatsApp with Meta.
- Generate and test the server-side code that sends WhatsApp messages and templates.
- Receive incoming messages through a webhook and verify the endpoint.
- Explain and recover from errors using Gambot’s machine-readable error fields.
Requirements
- A VS Code version with MCP support and Copilot agent mode enabled for your account/organization (MCP availability can be controlled by your admin).
- 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.
Setup
Create .vscode/mcp.json
Use the hosted server (OAuth, no secret in the file) or the local npx server.
Start the server
Open the file in VS Code and use the Start action above the server entry, or the MCP: List Servers command. Sign in when prompted (hosted).
Open Copilot chat in Agent mode
Pick Agent mode and confirm the gambot tools are enabled in the tools picker.
Ask
“Add the official WhatsApp API to this app using Gambot.”
.vscode/mcp.json (hosted, OAuth)
{
"servers": {
"gambot": {
"type": "http",
"url": "https://gambot-mcp.azurewebsites.net/mcp"
}
}
}.vscode/mcp.json (local, token from a prompt so it is never stored in the file)
{
"inputs": [
{ "id": "gambot_token", "type": "promptString", "description": "Gambot API token (optional at first)", "password": true }
],
"servers": {
"gambot": {
"type": "stdio",
"command": "npx",
"args": ["-y", "gambot-mcp"],
"env": { "GAMBOT_TOKEN": "${input:gambot_token}" }
}
}
}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.
Related
- WhatsApp MCP overview — the full server, tools and hosted option.
- Other clients: Claude Desktop, Claude Code, Cursor, OpenAI Codex, Gemini CLI, ChatGPT, 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
Create the account, connect your number with Meta, and send your first WhatsApp message from VS Code.
Frequently asked questions
How do I add the official WhatsApp API to my application using VS Code and GitHub Copilot?
Create .vscode/mcp.json with a "gambot" server (type "http" and the URL https://gambot-mcp.azurewebsites.net/mcp for OAuth, or stdio with npx -y gambot-mcp), start it, switch Copilot chat to Agent mode, and ask it to set up WhatsApp with Gambot.
Where do I keep the token?
Use OAuth on the hosted server, or the promptString input shown above so the token is never written to the file.
Is this the official WhatsApp API?
Yes. Gambot is a Meta Business Solution Provider; messages go through the WhatsApp Business (Cloud) API, not WhatsApp Web automation.