Quick overview
This workflow receives WhatsApp Cloud API webhook events, transcribes incoming voice notes with OpenAI Whisper, generates a reply with OpenAI GPT-4o, and sends the response back to the sender via the WhatsApp Graph API while also handling plain text messages.
How it works
- Receives WhatsApp webhook requests for verification (GET) and incoming messages (POST) from the Meta WhatsApp Cloud API.
- Validates the webhook verify token and returns the hub challenge to complete Meta webhook verification.
- Parses the inbound webhook payload to extract the sender number, phone number ID, message type, and either text content or an audio media ID.
- For voice notes, calls the WhatsApp Graph API to resolve the media ID to a temporary download URL, downloads the audio file, and transcribes it to text with OpenAI Whisper.
- For text messages, uses the incoming text directly as the user prompt.
- Sends the message text to OpenAI GPT-4o with a system prompt to generate a concise reply in the same language.
- Posts the generated reply back to the user using the WhatsApp Graph API messages endpoint and returns an OK response to the webhook.
Setup
- Create a Meta app with WhatsApp Cloud API enabled, configure a WhatsApp Business phone number, and set the webhook callback URL to this workflow’s production webhook URL.
- Set the Meta webhook verify token in the Meta App Dashboard and replace the placeholder value in the token check so verification succeeds.
- Add an HTTP Header Auth credential for the WhatsApp Graph API using a permanent access token (Authorization: Bearer <token>) and use it on the Graph API HTTP requests.
- Add an OpenAI API credential for the Whisper transcription and GPT-4o reply generation nodes.
- Customize the GPT-4o system prompt to match your assistant persona, business context, and reply style.