Tools
Claude Code, WhatsApp Cloud API, Python
Price
Free kit; Claude API, Meta and hosting pay-as-you-go
Time
Half a day
Level
Intermediate

A restaurant, a tradesperson, a shop: customers message on WhatsApp at 10pm to ask about opening hours, a price, availability. Nobody answers until the next day, and some of them have already gone elsewhere. I have already shown how to build such an agent with n8n, a visual automation tool, in this article. Here the angle is different: no tool in the middle, Claude Code writes the program, and you own all of it.

How it works

When a customer writes, Meta sends the message to a web address of yours, a webhook. Your server checks that it really comes from Meta, looks up that customer's history, asks Claude for a reply through the API, then sends it back through the WhatsApp Cloud API. Three rules from Meta's documentation shape the code:

  • the address must use HTTPS with a valid certificate (self-signed certificates are refused);
  • each delivery carries an X-Hub-Signature-256 signature, computed with your Meta app secret: your server must check it;
  • if your server does not answer 200, Meta retries delivery for up to 7 days, which can create duplicates.

Before you start

  • A Meta app with WhatsApp, an access token and the phone number ID: the Meta-side steps are covered in my WhatsApp agent article, and they do not change.
  • An Anthropic API key: the agent in production calls the API, billed per use, separately from your Claude subscription.
  • Python 3.11 or later, and hosting that serves your server over HTTPS.

Build the agent with the kit

WhatsApp AgentKit is an open-source kit (MIT licence, updated in August 2026) that holds almost no code: it is a set of instructions Claude Code reads to interview you about your business, then write the server. Signature checks and duplicate handling are already part of it. It is written in Spanish, hence the first setting below.

  1. Install Claude Code (official method)
    Terminal
    curl -fsSL https://claude.ai/install.sh | bash
  2. Get the kit and read its two key filesOpen start.sh and CLAUDE.md before running anything: the first checks Python and creates the .env file, the second describes what Claude will do.
    Terminal
    git clone https://github.com/Hainrixz/whatsapp-agentkit.git
    cd whatsapp-agentkit
    bash start.sh
  3. Start Claude Code and set your languageType claude, then this message before the /build-agent command:
    Prompt to copy
    Answer me in English for the whole setup. The agent you build must answer customers in English, politely, and say in its first message that it is an AI assistant. It never gives a firm price or a job date: it hands over to a human. I choose the direct Meta Cloud API connection. Do not ask for my keys in the conversation: I will paste them into the .env file myself.
  4. Answer the interviewType /build-agent. Claude asks about your business, your hours, your tone, and picks up your documents (prices, FAQ) from the knowledge/ folder. It then writes the server, the per-customer memory and the agent's instructions.
  5. Test without WhatsAppClaude also generates a simulator in the terminal: play the customer, ask a simple question, an off-topic one, an urgent one.
    Terminal
    python tests/test_local.py
  6. Connect MetaIn your Meta app, WhatsApp then Configuration: paste your live server's address and the verify token chosen in .env (META_VERIFY_TOKEN), and subscribe to the messages field. Fill in META_APP_SECRET: according to the kit itself, without that secret the server accepts every message without checking the signature.

Without the kit: the prompt to start from scratch

If you would rather not depend on any kit, ask Claude Code directly, in an empty folder:

Prompt to copy
Write a small Python (FastAPI) server for a WhatsApp agent, following the official Meta WhatsApp Cloud API and Claude API documentation:
1. GET /webhook: check hub.verify_token and return hub.challenge.
2. POST /webhook: check the X-Hub-Signature-256 signature with the App Secret, answer 200 straight away, process the message in the background.
3. Ignore duplicates using the message ID, and notifications that are not text messages.
4. Keep each number's history in SQLite.
5. Call claude-sonnet-5-5 with my instructions as a cached system prompt.
6. Read every secret from .env, never from the code.
Also write a local test that simulates a customer, and explain each file to me.

Limits, cost and guardrails

  • The 24-hour window: the agent can reply freely within 24 hours of the customer's last message. Writing first requires a message template approved by Meta, which is billed.
  • Cost: the Claude API is billed per token, and each reply sends the instructions and history again; prompt caching and a shorter history keep it down. Add hosting and, outside the 24-hour window, Meta's messages.
  • A human behind it: complaints, emergencies and quote requests must reach you, not be handled by the AI. Read the conversations every week at first.
  • Maintenance: a server of your own also means updates to apply. If nobody can look after it, a tool like n8n is easier to hand over.

Security. The kit is published by an individual, not by Meta or Anthropic: read its files before running them and review the code Claude writes. Its .claude/settings.local.json file pre-approves Claude to write files and run git, docker or pip install without asking: remove the lines you are not comfortable with before starting. The permanent Meta token can write on behalf of your business and the Anthropic key drives your bill: they go in .env, checked as ignored by git (git check-ignore .env), never in a message or a screenshot.

Sources

Want this agent without building it yourself, with the instructions, guardrails and follow-up? That is what I deliver in my custom AI agents work.