{"id":547,"date":"2026-10-28T16:07:36","date_gmt":"2026-10-28T16:07:36","guid":{"rendered":"https:\/\/vectalk.com.br\/blog\/chatgpt-whatsapp-business-api\/"},"modified":"2026-10-28T16:07:40","modified_gmt":"2026-10-28T16:07:40","slug":"chatgpt-whatsapp-business-api","status":"publish","type":"post","link":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/","title":{"rendered":"How to connect ChatGPT to the official WhatsApp Business API (tutorial with code)"},"content":{"rendered":"\n<p><em>Updated on October 28, 2026<\/em><\/p>\n\n\n\n<p>To connect ChatGPT to the official WhatsApp Business API, you receive the customer&#8217;s message through the webhook, send that conversation&#8217;s history to OpenAI&#8217;s Responses API (<code>POST https:\/\/api.openai.com\/v1\/responses<\/code>) and deliver the generated text back with a Cloud API send call. Free-form replies can only go out inside the 24-hour window opened by the customer, and Meta&#8217;s policy requires a clear path to a human agent. Using AI to support your own business&#8217;s customer service is allowed; offering a &#8220;general-purpose ChatGPT&#8221; as a product on WhatsApp falls under separate rules in Meta&#8217;s terms.<\/p>\n\n\n\n<p>This tutorial is the hands-on part: full Node.js code, per-contact history, window checks, human handoff and cost. The general architecture (queue, deduplication, states) is covered in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-cloud-api-en\/\">WhatsApp Cloud API: what it is, how it works and what it costs<\/a> and in the bot tutorials linked below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What you need before you start<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A phone number connected to the official API, with a webhook set up. If you are not there yet, start with the Cloud API guide linked above.<\/li>\n\n\n<li>An OpenAI API key (<code>OPENAI_API_KEY<\/code>), created in the OpenAI dashboard.<\/li>\n\n\n<li>Node.js 18 or later (the example uses native <code>fetch<\/code> and the official <code>openai<\/code> SDK).<\/li>\n\n\n<li>A database to store conversation history and state. The example keeps everything in memory for simplicity.<\/li>\n\n<\/ul>\n\n\n\n<p>Nothing on the WhatsApp side changes because you use ChatGPT: the Cloud API has no idea which model wrote the text. What governs the use case is Meta&#8217;s terms, covered further down.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The flow in 5 steps<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Step<\/th><th>What happens<\/th><th>Where<\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>The customer sends a message and Meta fires the webhook<\/td><td>Meta \u2192 your server (directly or through a provider)<\/td><\/tr><tr><td>2<\/td><td>Your server returns 200 right away and queues the event<\/td><td>Webhook<\/td><\/tr><tr><td>3<\/td><td>The worker loads the history for that <code>wa_id<\/code> and decides whether the bot replies<\/td><td>Database + router<\/td><\/tr><tr><td>4<\/td><td>The worker calls the Responses API with instructions and history<\/td><td>OpenAI<\/td><\/tr><tr><td>5<\/td><td>The text goes back to the customer via <code>POST \/messages<\/code><\/td><td>Cloud API<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Step 2 is where rushed integrations break. The model can take a few seconds to answer, and the webhook cannot wait. On Vectalk, for example, the endpoint must return HTTP 200 within 20 seconds or the event is resent, according to the <a href=\"https:\/\/docs.vectalk.com.br\/concepts\/webhooks\">webhook documentation<\/a>. Retries without deduplication become duplicate replies and double cost.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Responses API or Chat Completions?<\/h2>\n\n\n\n<p>OpenAI has two APIs for generating text. The <a href=\"https:\/\/developers.openai.com\/api\/docs\/guides\/text\" target=\"_blank\" rel=\"noreferrer noopener\">text generation guide<\/a> recommends the <strong>Responses API<\/strong> for new applications, and that is what we use here. The minimal call is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">curl https:\/\/api.openai.com\/v1\/responses \\\n  -H \"Authorization: Bearer $OPENAI_API_KEY\" \\\n  -H \"Content-Type: application\/json\" \\\n  -d '{\n    \"model\": \"YOUR_MODEL\",\n    \"instructions\": \"You are the assistant for Example Store. Answer in up to 3 sentences.\",\n    \"input\": \"How long does shipping to Austin take?\"\n  }'<\/code><\/pre>\n\n\n\n<p>Three parameters matter for a WhatsApp bot:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>instructions<\/code><\/strong>: the bot&#8217;s behavior (tone, scope, what it will not do). It applies only to the current request, so send it every time.<\/li>\n\n\n<li><strong><code>input<\/code><\/strong>: the question, or a list of <code>user<\/code> and <code>assistant<\/code> messages with the history.<\/li>\n\n\n<li><strong><code>model<\/code><\/strong>: pick one from OpenAI&#8217;s models page. Keep it in an environment variable so you can switch without touching code.<\/li>\n\n<\/ul>\n\n\n\n<p>In the official SDKs, the final text is in <code>response.output_text<\/code>. Do not read <code>output[0]<\/code> directly: the output can contain other items before the text, such as tool calls.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Per-contact history: three options<\/h2>\n\n\n\n<p>ChatGPT does not remember the conversation on its own. With every message, you have to supply the context. OpenAI&#8217;s <a href=\"https:\/\/developers.openai.com\/api\/docs\/guides\/conversation-state\" target=\"_blank\" rel=\"noreferrer noopener\">conversation state guide<\/a> describes three options:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Option<\/th><th>How it works<\/th><th>Where history lives<\/th><th>When to use it<\/th><\/tr><\/thead><tbody><tr><td>Manual history<\/td><td>You send the latest messages in <code>input<\/code><\/td><td>Your database<\/td><td>Recommended default for customer service: you control size, retention and auditing<\/td><\/tr><tr><td><code>previous_response_id<\/code><\/td><td>You send only the new message plus the previous response ID<\/td><td>OpenAI (response objects are kept for 30 days by default)<\/td><td>Prototypes; tokens from earlier responses are still billed as input<\/td><\/tr><tr><td>Conversations API<\/td><td>You create a conversation and pass its ID in <code>conversation<\/code><\/td><td>OpenAI, without the 30-day limit<\/td><td>When you want durable state on OpenAI&#8217;s side<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For customer service, manual history is usually the easiest choice to justify: the data stays in your database, you decide how long to keep it, and you can set <code>store: false<\/code> so OpenAI does not save the response. The history key is the customer&#8217;s <code>wa_id<\/code> (the <code>from<\/code> field of the incoming message).<\/p>\n\n\n\n<p>If the conversation includes personal data, privacy law applies to what you send to the AI provider. In Brazil that is the LGPD (Lei Geral de Prote\u00e7\u00e3o de Dados, Brazil&#8217;s data protection law); see <a href=\"https:\/\/vectalk.com.br\/blog\/en\/lgpd-whatsapp-en\/\">LGPD and WhatsApp<\/a>. This article is not legal advice.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Full Node.js code<\/h2>\n\n\n\n<p>The example uses Express, the <code>openai<\/code> SDK and sending through Vectalk, which accepts the same payload as the Cloud API. With an instance token, the sender number is resolved automatically; with an organization token, include <code>phone_number_id<\/code> in the body, per the <a href=\"https:\/\/docs.vectalk.com.br\/api-reference\/messages\/send\">send reference<\/a>. If you integrate directly with Meta, change the URL to <code>https:\/\/graph.facebook.com\/&lt;version&gt;\/&lt;PHONE_NUMBER_ID&gt;\/messages<\/code> and use your Meta token.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">npm install express openai<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-js\">import express from 'express';\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI(); \/\/ reads OPENAI_API_KEY from the environment\nconst MODEL = process.env.OPENAI_MODEL;\nconst SEND_URL = 'https:\/\/apis.vectalk.com.br\/api\/messages';\nconst TOKEN = process.env.VECTALK_TOKEN; \/\/ instance token\nconst WINDOW_MS = 24 * 60 * 60 * 1000;\nconst MAX_TURNS = 20;\n\nconst INSTRUCTIONS = `You are Example Store's virtual assistant on WhatsApp.\n- Answer in English, in at most 3 short sentences.\n- Only talk about the store's orders, shipping, returns and products.\n- Never make up prices, deadlines or policies: use only the data provided.\n- If you don't know, if the customer asks for a person, or the topic is a\n  complaint, cancellation or billing dispute, reply exactly: HANDOFF`;\n\nconst app = express();\napp.use(express.json());\n\nconst queue = [];\nconst processed = new Set();   \/\/ handled wamids (use Redis\/a database in production)\nconst chats = new Map();       \/\/ wa_id -&gt; { state, history, lastInbound }\n\n\/\/ 1. Webhook: queue and return 200 immediately\napp.post('\/webhook', (req, res) =&gt; {\n  for (const entry of req.body.entry ?? []) {\n    for (const change of entry.changes ?? []) {\n      for (const msg of change.value?.messages ?? []) queue.push(msg);\n    }\n  }\n  res.sendStatus(200);\n});\n\n\/\/ 2. Send to WhatsApp\nasync function send(body) {\n  const r = await fetch(SEND_URL, {\n    method: 'POST',\n    headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application\/json' },\n    body: JSON.stringify({ messaging_product: 'whatsapp', ...body }),\n  });\n  if (!r.ok) throw new Error(`Send failed: ${r.status} ${await r.text()}`);\n  return r.json();\n}\n\n\/\/ 3. Call OpenAI (Responses API)\nasync function askModel(history) {\n  const response = await openai.responses.create(\n    {\n      model: MODEL,\n      instructions: INSTRUCTIONS,\n      input: history,           \/\/ [{ role: 'user' | 'assistant', content: '...' }]\n      max_output_tokens: 300,   \/\/ short answers cost less\n      store: false,             \/\/ do not store the response at OpenAI\n    },\n    { timeout: 15000 },\n  );\n  return response.output_text.trim();\n}\n\n\/\/ 4. Worker\nasync function handle(msg) {\n  if (processed.has(msg.id)) return;\n  processed.add(msg.id);\n\n  const c = chats.get(msg.from) ?? { state: 'bot', history: [], lastInbound: 0 };\n  c.lastInbound = Number(msg.timestamp) * 1000;\n  chats.set(msg.from, c);\n\n  if (c.state !== 'bot') return; \/\/ a human took over: the bot stays quiet\n\n  if (msg.type !== 'text') {\n    await send({ to: msg.from, type: 'text', text: { body: 'I can only read text here. Could you type your question?' } });\n    return;\n  }\n\n  await send({ status: 'read', message_id: msg.id }); \/\/ mark as read\n\n  c.history.push({ role: 'user', content: msg.text.body });\n  c.history = c.history.slice(-MAX_TURNS);\n\n  let text;\n  try {\n    text = await askModel(c.history);\n  } catch (e) {\n    console.error('OpenAI failed', e);\n    text = 'HANDOFF'; \/\/ when in doubt, hand off to a person\n  }\n\n  if (text === 'HANDOFF') return handOff(msg.from, c);\n  if (Date.now() - c.lastInbound &gt; WINDOW_MS) return; \/\/ window closed: template only\n\n  await send({ to: msg.from, type: 'text', text: { body: text } });\n  c.history.push({ role: 'assistant', content: text });\n}\n\nasync function handOff(waId, c) {\n  c.state = 'human';\n  await send({ to: waId, type: 'text', text: { body: \"I'm bringing in someone from our team. They'll pick it up here shortly.\" } });\n  \/\/ Notify your support tool (ticket queue, CRM, Slack).\n}\n\nsetInterval(async () =&gt; {\n  const msg = queue.shift();\n  if (!msg) return;\n  try { await handle(msg); } catch (e) { console.error(e); }\n}, 50);\n\napp.listen(3000, () =&gt; console.log('Bot listening on port 3000'));<\/code><\/pre>\n\n\n\n<p>To run it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">export OPENAI_API_KEY=\"sk-...\"\nexport OPENAI_MODEL=\"model-chosen-from-the-models-page\"\nexport VECTALK_TOKEN=\"your-instance-token\"\nnode bot.mjs<\/code><\/pre>\n\n\n\n<p>To test locally, expose port 3000 with a tunnel and register the URL as your webhook; see <a href=\"https:\/\/vectalk.com.br\/blog\/en\/test-whatsapp-webhook-locally\/\">how to test the WhatsApp webhook locally<\/a>. If your webhook receives events directly from Meta, validate each request&#8217;s signature before processing it: see <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-signature-validation\/\">how to validate X-Hub-Signature-256<\/a>.<\/p>\n\n\n\n<p>While the model is thinking, the Cloud API lets you show &#8220;typing&#8230;&#8221; in the same call that marks the message as read by adding <code>\"typing_indicator\": { \"type\": \"text\" }<\/code>. According to the <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/typing-indicators\" target=\"_blank\" rel=\"noreferrer noopener\">typing indicators documentation<\/a>, it disappears when you reply or after 25 seconds, whichever comes first, and Meta recommends showing it only when you are actually going to reply.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What the example covers and what is missing<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Covers:<\/strong> instant webhook acknowledgement, deduplication by <code>wamid<\/code>, per-contact history with a size cap, OpenAI timeout, window check and handoff state.<\/li>\n\n\n<li><strong>Missing for production:<\/strong> a persistent queue with retries, a database for history and state, send-rate control (throughput), per-conversation cost tracking and a dashboard so agents can hand the conversation back to the bot.<\/li>\n\n<\/ul>\n\n\n\n<p>Complete bots without the AI part are in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-bot-nodejs-express\/\">WhatsApp bot with Node.js<\/a> and <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-bot-python-fastapi\/\">WhatsApp bot with Python<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The 24-hour window: ChatGPT cannot start a conversation<\/h2>\n\n\n\n<p>The model&#8217;s reply is a free-form message. The <a href=\"https:\/\/business.whatsapp.com\/policy\" target=\"_blank\" rel=\"noreferrer noopener\">WhatsApp Business Messaging Policy<\/a> allows replies without a template only inside the 24-hour customer service window, which opens and resets with every customer message. Outside it, only approved templates.<\/p>\n\n\n\n<p>In practice:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>The bot is reactive.<\/strong> It cannot send &#8220;Hi, still interested?&#8221; two days later with ChatGPT-generated text. That is what templates are for.<\/li>\n\n\n<li><strong>Check the window right before sending<\/strong>, not only when the message arrives. If the model stalled, the queue lagged or the worker crashed, the window can close mid-flight.<\/li>\n\n\n<li><strong>Do not use the model to &#8220;fill in&#8221; a template.<\/strong> Templates have approved text and variables; variable values should come from your system&#8217;s data.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Handing off to a human<\/h2>\n\n\n\n<p>Meta&#8217;s policy allows automation inside the window but requires clear escalation paths, such as a handoff to a human agent in the chat, a phone number, email, web support or a support form. In the code above, three situations trigger a handoff:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The model replies <code>HANDOFF<\/code> because it does not know, the customer asked for a person or the topic is sensitive (the instructions say so).<\/li>\n\n\n<li>The OpenAI call fails or times out.<\/li>\n\n\n<li>You can add your own triggers, such as keywords or a &#8220;Talk to an agent&#8221; button.<\/li>\n\n<\/ol>\n\n\n\n<p>After the handoff, the conversation state becomes <code>human<\/code> and the bot stays silent until an agent hands it back. If the number uses coexistence, the agent can reply from the WhatsApp Business app, and messages sent from the app reach your system as echo events; you can use them to mark the conversation as <code>human<\/code> automatically.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What it costs: Meta + OpenAI<\/h2>\n\n\n\n<p>There are two separate bills.<\/p>\n\n\n\n<p><strong>WhatsApp (Meta).<\/strong> Bot replies inside the window are service messages. Since October 1, 2026, each number gets 1,000 free service messages per month, and billing starts at the 1,001st. For recipients in Brazil, the service rate is BRL 0.0350 per delivered message, according to <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/pricing\" target=\"_blank\" rel=\"noreferrer noopener\">Meta&#8217;s pricing page<\/a>; other countries have their own rates on the same page. Templates are charged at their category&#8217;s rate whether sent inside or outside the window (in Brazil, marketing BRL 0.3217; utility and authentication BRL 0.0350); since October 1, 2026, that includes utility templates sent inside the window.<\/p>\n\n\n\n<p><strong>OpenAI.<\/strong> You pay for input and output tokens, at a price that depends on the model. Check OpenAI&#8217;s pricing page before estimating.<\/p>\n\n\n\n<p>Three tweaks cut both bills at once:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>One reply per question.<\/strong> Three short messages count as three service messages once the free tier is used up. Ask the model for a single reply.<\/li>\n\n\n<li><strong>Short history.<\/strong> Every old message sent in <code>input<\/code> is billed again as input tokens. Keep the last few turns and, if needed, a summary.<\/li>\n\n\n<li><strong><code>max_output_tokens<\/code>.<\/strong> Caps reply length and avoids long walls of text nobody reads on a phone.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What Meta allows: a &#8220;general-purpose ChatGPT&#8221; is a different case<\/h2>\n\n\n\n<p>The <a href=\"https:\/\/www.facebook.com\/legal\/Meta-Terms-for-WhatsApp-Business-Platform\" target=\"_blank\" rel=\"noreferrer noopener\">Meta Terms for WhatsApp Business Platform<\/a>, updated on September 23, 2026, address &#8220;AI Providers&#8221; in section 4.7: providers and developers of AI or machine learning technologies, such as large language models, generative AI platforms and general-purpose AI assistants. They are prohibited from using the platform to offer those technologies when they are the primary functionality, rather than incidental or ancillary, as Meta determines. The terms allow exceptions in certain countries.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Scenario<\/th><th>How the terms read<\/th><\/tr><\/thead><tbody><tr><td>A store uses an OpenAI model to answer questions about orders<\/td><td>AI supporting the business&#8217;s own customer service; not what the clause targets<\/td><\/tr><tr><td>A clinic uses AI to book and confirm appointments<\/td><td>Same: AI is a tool of the service, not the product<\/td><\/tr><tr><td>A company offers &#8220;chat with an AI about anything&#8221; on WhatsApp<\/td><td>This is the AI Provider case; it depends on country rules<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Brazil is one of those countries. The <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/pricing\/ai-providers\" target=\"_blank\" rel=\"noreferrer noopener\">AI Providers pricing page<\/a>, updated on October 15, 2026, says that since March 11, 2026, AI Providers can send service messages to users with +55 numbers, at their own rates, always in response to the user (the customer service window still applies). For those messages, the status webhook shows the <code>general_purpose_ai<\/code> category. The same page lists other markets and dates. The rule applies only to AI Providers; pricing for other businesses does not change.<\/p>\n\n\n\n<p>The terms also prohibit using platform data to build, train or improve AI models, with an exception for fine-tuning a model used exclusively by the business that is not used for other models. In practice: review how your AI provider handles retention and training, and do not reuse WhatsApp conversations to train third-party models.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to do it with Vectalk<\/h2>\n\n\n\n<p>Vectalk is a proxy for the official Cloud API: your bot receives the same webhooks Meta sends and sends with the same payloads, changing only the base URL and the token. In the code above, that is the <code>SEND_URL<\/code> constant and <code>VECTALK_TOKEN<\/code>. You register the bot URL with <code>POST \/api\/webhooks<\/code> and can add more than one URL per instance, for example one for the bot and one for your customer service system. You don&#8217;t add a card at Meta: each delivered message is deducted from your prepaid Vectalk balance, and coexistence lets your human team reply from the app when the bot hands off. Get started at <a href=\"https:\/\/apps.vectalk.com.br\/register\">apps.vectalk.com.br\/register<\/a> and read the <a href=\"https:\/\/docs.vectalk.com.br\/quickstart\">quickstart<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need Meta&#8217;s permission to use ChatGPT on WhatsApp?<\/h3>\n\n\n\n<p>For a customer service bot for your own business, the documentation we reviewed does not describe any extra registration: you use the official API as usual. If your product is a general-purpose AI assistant, read section 4.7 of the terms and the AI Providers page before launching.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I use the ChatGPT app or an off-the-shelf &#8220;ChatGPT for WhatsApp&#8221; tool?<\/h3>\n\n\n\n<p>This tutorial uses OpenAI&#8217;s API on your server, connected to the official WhatsApp API. Tools that connect WhatsApp by scanning a QR code use unofficial channels and risk bans; see <a href=\"https:\/\/vectalk.com.br\/blog\/en\/official-vs-unofficial-whatsapp-api\/\">official vs unofficial WhatsApp API<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can the bot send the first message?<\/h3>\n\n\n\n<p>Not with model-generated text. To start or resume contact outside the 24-hour window, you need an approved template.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I make ChatGPT answer voice notes?<\/h3>\n\n\n\n<p>The webhook delivers the media ID. Download the file through the media API, transcribe it with the service of your choice and send the text to the model. Downloading is covered in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/download-media-whatsapp-webhook\/\">how to download media customers send<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Responses API or Chat Completions?<\/h3>\n\n\n\n<p>Both work with WhatsApp, because the integration is plain HTTP. OpenAI recommends the Responses API for new applications, and that is what the example uses.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Official sources checked on October 28, 2026:<\/strong> <a href=\"https:\/\/developers.openai.com\/api\/docs\/guides\/text\" target=\"_blank\" rel=\"noreferrer noopener\">OpenAI: text generation<\/a>, <a href=\"https:\/\/developers.openai.com\/api\/docs\/guides\/conversation-state\" target=\"_blank\" rel=\"noreferrer noopener\">OpenAI: conversation state<\/a>, <a href=\"https:\/\/www.facebook.com\/legal\/Meta-Terms-for-WhatsApp-Business-Platform\" target=\"_blank\" rel=\"noreferrer noopener\">Meta Terms for WhatsApp Business Platform<\/a> (updated September 23, 2026), <a href=\"https:\/\/business.whatsapp.com\/policy\" target=\"_blank\" rel=\"noreferrer noopener\">WhatsApp Business Messaging Policy<\/a> (updated September 23, 2026), <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/pricing\/ai-providers\" target=\"_blank\" rel=\"noreferrer noopener\">AI Providers pricing<\/a> (updated October 15, 2026), <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/pricing\" target=\"_blank\" rel=\"noreferrer noopener\">WhatsApp Business Platform pricing<\/a>, <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/typing-indicators\" target=\"_blank\" rel=\"noreferrer noopener\">Typing indicators<\/a>, <a href=\"https:\/\/docs.vectalk.com.br\/concepts\/webhooks\">Vectalk: webhooks<\/a>, <a href=\"https:\/\/docs.vectalk.com.br\/api-reference\/messages\/send\">Vectalk: sending messages<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Node.js tutorial that wires the official WhatsApp API webhook to OpenAI&#8217;s Responses API, with per-contact history, the 24-hour window and human handoff.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-547","post","type-post","status-publish","format-standard","hentry","category-blog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ChatGPT + WhatsApp Business API: Tutorial | Vectalk<\/title>\n<meta name=\"description\" content=\"Connect ChatGPT to the WhatsApp Business API: webhook, OpenAI Responses API, per-contact history, 24-hour window, human handoff and Meta&#039;s AI rules.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ChatGPT + WhatsApp Business API: Tutorial | Vectalk\" \/>\n<meta property=\"og:description\" content=\"Connect ChatGPT to the WhatsApp Business API: webhook, OpenAI Responses API, per-contact history, 24-hour window, human handoff and Meta&#039;s AI rules.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Vectalk\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-28T16:07:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-28T16:07:40+00:00\" \/>\n<meta name=\"author\" content=\"wanderleyfcunha\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"wanderleyfcunha\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/\"},\"author\":{\"name\":\"wanderleyfcunha\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\"},\"headline\":\"How to connect ChatGPT to the official WhatsApp Business API (tutorial with code)\",\"datePublished\":\"2026-10-28T16:07:36+00:00\",\"dateModified\":\"2026-10-28T16:07:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/\"},\"wordCount\":2063,\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/\",\"url\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/\",\"name\":\"ChatGPT + WhatsApp Business API: Tutorial | Vectalk\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#website\"},\"datePublished\":\"2026-10-28T16:07:36+00:00\",\"dateModified\":\"2026-10-28T16:07:40+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\"},\"description\":\"Connect ChatGPT to the WhatsApp Business API: webhook, OpenAI Responses API, per-contact history, 24-hour window, human handoff and Meta's AI rules.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/chatgpt-whatsapp-business-api\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to connect ChatGPT to the official WhatsApp Business API (tutorial with code)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/\",\"name\":\"Blog Vectalk\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\",\"name\":\"wanderleyfcunha\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g\",\"caption\":\"wanderleyfcunha\"},\"sameAs\":[\"https:\\\/\\\/vectalk.com.br\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ChatGPT + WhatsApp Business API: Tutorial | Vectalk","description":"Connect ChatGPT to the WhatsApp Business API: webhook, OpenAI Responses API, per-contact history, 24-hour window, human handoff and Meta's AI rules.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/","og_locale":"en_US","og_type":"article","og_title":"ChatGPT + WhatsApp Business API: Tutorial | Vectalk","og_description":"Connect ChatGPT to the WhatsApp Business API: webhook, OpenAI Responses API, per-contact history, 24-hour window, human handoff and Meta's AI rules.","og_url":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/","og_site_name":"Blog Vectalk","article_published_time":"2026-10-28T16:07:36+00:00","article_modified_time":"2026-10-28T16:07:40+00:00","author":"wanderleyfcunha","twitter_card":"summary_large_image","twitter_misc":{"Written by":"wanderleyfcunha","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/#article","isPartOf":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/"},"author":{"name":"wanderleyfcunha","@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b"},"headline":"How to connect ChatGPT to the official WhatsApp Business API (tutorial with code)","datePublished":"2026-10-28T16:07:36+00:00","dateModified":"2026-10-28T16:07:40+00:00","mainEntityOfPage":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/"},"wordCount":2063,"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/","url":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/","name":"ChatGPT + WhatsApp Business API: Tutorial | Vectalk","isPartOf":{"@id":"https:\/\/vectalk.com.br\/blog\/#website"},"datePublished":"2026-10-28T16:07:36+00:00","dateModified":"2026-10-28T16:07:40+00:00","author":{"@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b"},"description":"Connect ChatGPT to the WhatsApp Business API: webhook, OpenAI Responses API, per-contact history, 24-hour window, human handoff and Meta's AI rules.","breadcrumb":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vectalk.com.br\/blog\/en\/chatgpt-whatsapp-business-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vectalk.com.br\/blog\/"},{"@type":"ListItem","position":2,"name":"How to connect ChatGPT to the official WhatsApp Business API (tutorial with code)"}]},{"@type":"WebSite","@id":"https:\/\/vectalk.com.br\/blog\/#website","url":"https:\/\/vectalk.com.br\/blog\/","name":"Blog Vectalk","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vectalk.com.br\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b","name":"wanderleyfcunha","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g","caption":"wanderleyfcunha"},"sameAs":["https:\/\/vectalk.com.br\/blog"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/comments?post=547"}],"version-history":[{"count":1,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/547\/revisions"}],"predecessor-version":[{"id":550,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/547\/revisions\/550"}],"wp:attachment":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/media?parent=547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/categories?post=547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/tags?post=547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}