Integrate WhatsApp with OpenAI

To integrate WhatsApp with OpenAI, calls go out through its Function calling (tools) and events come back through its Your own relay - the model has no inbound trigger; authentication is The relay holds the Wapito token server-side; the model never sees it, and the setup below takes about 45 minutes. No official connector is involved: groups, Channels, status posts and template-free sends all go through one plain HTTPS call.

AI

What you can do with OpenAI

Setup in OpenAI

Authentication
The relay holds the Wapito token server-side; the model never sees it
Time to first call
About 45 minutes
  1. Write a small relay service - a handful of routes in any language - that holds both the Wapito token and the OpenAI key. Neither credential should ever be in a prompt.

  2. Register a webhook in Wapito pointing at the relay, verify the signature on every delivery, and answer with a 2xx immediately before doing any model work.

  3. Define a small set of tools the model may call, such as send a message, create a group or check a number, each with a strict JSON schema and a narrow purpose.

  4. Execute tool calls in the relay against Wapito, not in the model, and validate every argument - especially recipients - before the call goes out.

  5. Send the model's reply back through Wapito with a typing time, so the answer arrives at a human pace rather than instantly.

Example flows

Answer customer questions in a chat

The relay receives a message event, asks the model for a reply grounded in your documents, and sends the answer to the chat id. A confidence threshold routes anything uncertain to a human instead of guessing.

POST /messages/text Send a text message

curl --request POST \
  --url https://api.wapito.com/v1/messages/text \
  --header 'Authorization: Bearer wpt_YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{"to":"+15551234567","body":"Your order #4182 has shipped. Track it here: https://acme.example/t/4182","typing_time":3}'

Let the model open a group for an escalation

A create-group tool is exposed with a fixed participant list drawn from your rota, so the model decides when to escalate but never decides who is in the room. The group id is stored against the ticket.

POST /groups Create a group

curl --request POST \
  --url https://api.wapito.com/v1/groups \
  --header 'Authorization: Bearer wpt_YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{"subject":"Acme Launch Team","participants":["+15551234567","+15559876543"],"description":"Coordination for the Q3 launch. Keep it on topic."}'

Summarise a group thread on demand

When someone mentions the bot, the relay pulls recent messages, asks the model for a summary, and posts it back into the group. Recency limits keep the context window - and the cost - predictable.

GET /messages/list/{chat_id} List messages in a chat

Beta

curl --request GET \
  --url 'https://api.wapito.com/v1/messages/list/15551234567@s.whatsapp.net?count=50&offset=0&from_me=true&time_from=1789372800000&time_to=1789459200000' \
  --header 'Authorization: Bearer wpt_YOUR_TOKEN'

Validate a number the model extracted

Before acting on a phone number the model read out of a message, the relay checks it and refuses the tool call if no account exists, so a hallucinated digit never turns into a message to a stranger.

GET /contacts/{id}/exists Check one number for WhatsApp

curl --request GET \
  --url 'https://api.wapito.com/v1/contacts/+15551234567/exists' \
  --header 'Authorization: Bearer wpt_YOUR_TOKEN'

Receiving events

In OpenAI the inbound side is the Your own relay - the model has no inbound trigger: it gives you the URL to register in Wapito.Every event Wapito delivers — an inbound message, a delivery receipt, a member joining a group, a number disconnecting — is one HTTPS POST to a URL you register, signed with the webhook's secret in the X-Wapito-Signature header. Verify that header against the raw request body before you act on anything, answer with a 2xx within the retry window, and do slow work afterwards.

Webhooks guide: events, envelope and signature Your own relay - the model has no inbound trigger documentation

Step-by-step recipes for OpenAI

What the official connector does instead

OpenAI publishes no WhatsApp connector, and there is no inbound trigger in the API - a model cannot subscribe to a webhook. Every integration therefore runs through a relay you control, which is also the only safe place to hold both credentials and to enforce limits on what the model may do.

Wapito is an independent product. It is not affiliated with, endorsed by, sponsored by or certified by WhatsApp or Meta Platforms, Inc. WhatsApp is a trademark of Meta Platforms, Inc.

Frequently asked questions

Can the model call Wapito directly?

No, and it should not. Tool calls are executed by your code, not by the model, which is exactly what lets you validate arguments, enforce per-conversation limits and keep the token server-side. A model that could call the API directly could also be talked into messaging anyone.

How do I stop prompt injection reaching the API?

Treat every inbound message as untrusted input rather than as instructions. Keep the tool list small and each schema strict, validate recipients against your own records before sending, and never let a tool take a free-form URL or an arbitrary phone number straight from the conversation.

What does this cost to run?

Two meters: model tokens per turn and your Wapito plan for the messaging. Keeping the context window short - recent messages plus a retrieved snippet, not the whole thread - is usually the single biggest lever on the model side, and it improves answer quality as well.

Related

Try it on your own number

Create a channel, link a WhatsApp number by QR or pairing code, and call the API in a couple of minutes. The Sandbox plan is free and needs no card.