WhatsApp official API with Flowise: bridge and HTTP

Connect a Flowise flow to the official WhatsApp API via CRPRO Hub: the prediction API, the Agentflow V2 HTTP node and a short bridge that verifies signatures.

Flowise builds AI agents and flows, and CRPRO Hub gives that agent an official WhatsApp number. What joins them is HTTP at both ends: the Hub delivers the received message to a receiver, the receiver asks Flowise through the prediction API, and the answer goes back through the Hub. The Flowise documentation consulted describes the prediction API and the Agentflow V2 HTTP node, but not a webhook trigger. So this article uses a short bridge, and does not claim that Flowise receives the Hub webhook on its own.

How the connection is drawn

Short answer: customer's WhatsApp, Hub, your bridge, Flowise and back. The bridge receives and validates the webhook, calls Flowise POST /prediction/{id} with the question and sends the answer with POST /api/v1/channels/{id}/messages.

The bridge exists for two reasons. First, the Hub signs each delivery and checking it needs the raw body and code of your own. Second, the Hub wants a 2xx within 10 seconds, and an agent with a model and tools can take longer; answering 200 immediately and processing afterwards solves it. The same design appears in the Hub agent guide, which uses another model. Here the brain is your Flowise flow.

The Flowise prediction API

Short answer: it is a POST to /prediction/{id}, where id is the flow identifier, with a JSON body carrying question and, optionally, history and overrideConfig. The response brings text, chatId, chatMessageId and sessionId.

  • Authentication: Bearer token. Per the reference, an API key may be required depending on the flow settings; without it, the error is 401.
  • question: the customer's message. For Agentflow V2 there is also form, as an alternative.
  • history: a list of earlier messages, each with role apiMessage or userMessage and content. This is how you give the flow memory without depending on what Flowise stores.
  • overrideConfig: overrides the flow configuration and passes runtime variables.
  • streaming: default false. For WhatsApp, leave it false: the Hub sends the finished message.
  • Documented errors: 400, 401, 404, 413, 422 and 500.
The page lists sessionId only as a response field. The documentation lists no request field to pin the session, so the example below keeps the history in the bridge. The path prefix (for example /api/v1) depends on your instance: check the base URL of your installation.

The bridge step by step

Short answer: register the webhook with the bridge URL, validate the signature, answer 200, ask Flowise and send with an Idempotency-Key. The code below does that in about 70 lines of dependency-free Node.

  • Create the Hub key with messages:send and webhooks:write (authentication) and register the webhook with the call below; keep the whsec_.
  • Set the variables WEBHOOK_SECRET, CRPRO_API_KEY, FLOWISE_URL (your instance's API base URL), FLOWISE_FLOW_ID and FLOWISE_API_KEY.
  • Run the bridge behind HTTPS on port 443. The Hub only delivers over HTTPS, does not follow redirects and refuses hosts that resolve to a private IP.
  • Use POST /api/v1/webhooks/{id}/test to check the signature before connecting the flow.
curl -X POST https://crprohub.com/api/v1/webhooks \ -H "Authorization: Bearer hub_pk_EXEMPLO_NAO_REAL" \ -H "Content-Type: application/json" \ -d '{"name":"Recebimento","url":"https://bridge.example.com/webhooks/crprohub","event_types":["message.received"]}'import http from 'node:http' import { createHmac, timingSafeEqual } from 'node:crypto' const { WEBHOOK_SECRET, CRPRO_API_KEY, FLOWISE_URL, FLOWISE_FLOW_ID, FLOWISE_API_KEY } = process.env const historicos = new Map() // canal:contato -> [{ role, content }] const respostas = new Map() // message_id -> texto ja gerado const vistos = new Set() // ids de evento ja tratados function assinaturaValida(h, raw) { const assinado = h['x-hub-timestamp'] + '.' + h['x-hub-delivery-id'] + '.' + raw const esperado = createHmac('sha256', WEBHOOK_SECRET).update(assinado).digest('hex') const recebido = (h['x-hub-signature-256'] || '').replace('sha256=', '') return /^[0-9a-f]{64}$/.test(recebido) && timingSafeEqual(Buffer.from(recebido, 'hex'), Buffer.from(esperado, 'hex')) } async function perguntar(conversa, texto) { const r = await fetch(FLOWISE_URL + '/prediction/' + FLOWISE_FLOW_ID, { method: 'POST', headers: { Authorization: 'Bearer ' + FLOWISE_API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ question: texto, history: historicos.get(conversa) || [] }), }) if (!r.ok) throw new Error('flowise ' + r.status) return (await r.json()).text } async function tratar(ev) { if (ev.event !== 'message.received' || !ev.data.text || vistos.has(ev.id)) return vistos.add(ev.id) const conversa = ev.channel_id + ':' + ev.data.from let texto = respostas.get(ev.data.message_id) if (texto === undefined) { texto = await perguntar(conversa, ev.data.text) respostas.set(ev.data.message_id, texto) } const envio = await fetch('https://crprohub.com/api/v1/channels/' + ev.channel_id + '/messages', { method: 'POST', headers: { Authorization: 'Bearer ' + CRPRO_API_KEY, 'Content-Type': 'application/json', 'Idempotency-Key': 'flowise-' + ev.data.message_id, }, body: JSON.stringify({ to: ev.data.from, type: 'text', text: { body: texto.slice(0, 4096) } }), }) if (envio.ok) { const h = historicos.get(conversa) || [] historicos.set(conversa, [...h, { role: 'userMessage', content: ev.data.text }, { role: 'apiMessage', content: texto }].slice(-20)) } } http.createServer((req, res) => { let raw = '' req.setEncoding('utf8') req.on('data', (c) => (raw += c)) req.on('end', () => { if (!assinaturaValida(req.headers, raw)) { res.writeHead(401).end(); return } res.writeHead(200).end() // responde ja: o Hub espera um 2xx em ate 10 s tratar(JSON.parse(raw)).catch((e) => console.error(e)) }) }).listen(3000)

Three choices in the code deserve explanation. The 200 response goes before the heavy work, so the Hub does not retry. Deduplication uses the id in the event body, which stays the same on retry and replay. And the Flowise answer is stored by message_id: if the event is reprocessed, the text sent is the same, the Idempotency-Key is the same, and the Hub returns the original send instead of sending another message. If the text changed with the same key, the Hub would answer 409 IDEMPOTENCY_KEY_REUSED. In production, replace the Maps with a database, because they vanish on every restart.

Replying from the Agentflow V2 HTTP node

Short answer: you can send the message from inside the flow with the HTTP node, which accepts POST, a Bearer Token credential, headers, a JSON body and a JSON response. Then the bridge can just call the flow, and the flow replies to the customer.

According to the documentation, the HTTP node sends requests with GET, POST, PUT, DELETE and PATCH, uses Basic Auth, Bearer Token or API Key credentials, and accepts a JSON, Raw text, Form Data or x-www-form-urlencoded body. For the Hub: method POST, the channel URL, a Bearer credential with the Hub key, an Idempotency-Key header and a JSON body with to, type and text. The Custom Function node runs server-side JavaScript in Node.js and must return a string, which helps build the final text or truncate it to 4096 characters before sending.

The trade-off is idempotency. Inside the flow, a node retry can send twice if the key changes on every run. Pass the received message_id into the flow, for example in overrideConfig, and use it as part of the Idempotency-Key. When in doubt, keep the send in the bridge, where the key and the text stay under your control.

Limits and care

Short answer: sending is limited to 60 messages per minute per channel, and the organization to 120 requests per minute per credential. A slow AI flow and many customers at once can exceed that.

PointCare
Flowise latencyAnswer 200 to the Hub before calling the flow
HistoryKeep it to a few dozen messages, always starting with userMessage
Outside the service windowFree text needs a recent conversation; otherwise only a template
Non-text messageHandle an empty ev.data.text with a fixed reply
Consecutive failuresAfter 20, the Hub pauses the endpoint: reactivate with PATCH

To see what arrives in each event, read the webhooks page.

Frequently asked questions

Does Flowise receive the Hub webhook directly?

No. The documentation describes the prediction API and the Agentflow V2 nodes but not a webhook trigger. That is why the article uses a bridge.

Which Flowise endpoint do I call?

POST /prediction/{id}, with the flow id, Bearer authentication and a JSON body with question. The path prefix depends on the instance; check yours.

How do I give the flow conversation memory?

By sending history, a list of messages with role apiMessage or userMessage, stored per contact in the bridge. The documentation lists no request field to pin the session.

Can I send the reply from the Flowise HTTP node?

Yes, the HTTP node accepts POST, Bearer Token and a JSON body. Mind the Idempotency-Key so a node retry does not send twice.

Fontes

Documentação oficial da Meta, conferida em 31 de outubro de 2026.