WhatsApp official API with Dify: workflow and HTTP
Connect a Dify workflow to the official WhatsApp API through CRPRO Hub: the Webhook trigger to receive, the HTTP Request node to reply, and the trigger limits.
Dify has the two blocks this connection needs: a Webhook trigger, which receives the Hub event, and an HTTP Request node, which calls the API to reply. A language model node fits between them, and that is the typical design of a support agent. What does not exist, as far as could be confirmed, is a ready-made CRPRO Hub connector in Dify, and the trigger documentation does not describe signature verification. Both facts shape what follows.
The three points of contact between Dify and the Hub
Short answer: there are three, and you can use just one. The Webhook trigger receives Hub events. The HTTP Request node sends messages through the Hub API. And Dify's service API, at https://api.dify.ai/v1 on the cloud, lets your own system call the Dify app with a Bearer token.
Dify's documentation warns that the service API key should only be used from the backend, because in frontend code it can be extracted and abused. For WhatsApp that means the Hub never talks to that API directly: your server or the workflow itself does. This article covers the first two points, which live inside the workflow. The chat route body fields of the service API are not detailed here; see the Dify service API reference.
How to receive the event with the Webhook trigger
Short answer: create a Workflow app, add Start > Webhook Trigger, set the method and Content-Type to match what the Hub sends, declare the parameters you want to extract and register the generated URL in the Hub. Triggers only exist in Workflow apps.
- Under Add Node > Start > Webhook Trigger, choose method POST and Content-Type application/json. If the method or type do not match, Dify rejects the request.
- Declare the body parameters. Each extracted item becomes an output variable, and the name must equal the request key. Declare event as String and data as Object; the Object type is accepted in application/json.
- Mark as Required only what the flow needs. If a required parameter is missing, the workflow does not fire.
- Copy the test URL, register it in the Hub and click "Run this step" so the trigger captures the request. Then check the sample in the Last Run tab, under Input.
- When the flow is right, publish and swap the test URL for the production one in the Hub, so test data does not mix with real data.
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://YOUR-DIFY-TRIGGER-URL","event_types":["message.received"]}'{
"id": "6f1f0f6a-3b2c-4d1e-9a8b-0c1d2e3f4a5b",
"event": "message.received",
"channel_id": "9f6a9c1e-2f3d-4a5b-8c7d-1e2f3a4b5c6d",
"occurred_at": "2026-08-21T12:00:00.000Z",
"data": {
"message_id": "wamid.EXEMPLO123",
"from": "5521999999999",
"type": "text",
"text": "Oi, ainda tem em estoque?"
}
}The trigger's default response is 200 OK, which fits the Hub requirement of a 2xx within 10 seconds. You can set another status between 200 and 399 and a JSON or text body. Errors 400, 404, 413 and 500 are fixed by the system and cannot be customized. The page documents no timeout, so do not assume a long workflow answers within the Hub's 10 seconds; if the model is slow, the risk is a retry and a duplicate reply.
How to reply with the HTTP Request node
Short answer: add an HTTP Request node with method POST, the channel URL, API Key authentication of the Bearer type, an Idempotency-Key header and a JSON body with to, type and text. The API returns 202 with status accepted.
- Under Authentication, choose API Key and the Bearer subtype. Dify builds Authorization: Bearer with the token you paste, and the key needs the messages:send scope (authentication).
- Store the key as a secret-type environment variable: Dify masks those values in run logs and in the node log.
- Use workflow variables with {{variable}}. For nested values, the documentation shows the pattern {{api_response.data.items[0].id}}.
- Add the Idempotency-Key header pointing to the event id or the received message_id. Without it, the Hub rejects the send.
- Choose a JSON body and build to, type and text. Truncating the text to 4096 characters avoids size rejections, as the Hub agent guide example does. See the quickstart for the full request.
curl -X POST https://crprohub.com/api/v1/channels/CHANNEL_UUID/messages \
-H "Authorization: Bearer hub_pk_EXEMPLO_NAO_REAL" \
-H "Idempotency-Key: 4a50df76-d6c5-49f3-90a4-13907579d924" \
-H "Content-Type: application/json" \
-d '{"to":"5521999999999","type":"text","text":{"body":"Olá"}}'{
"to": "{{trigger.data.from}}",
"type": "text",
"text": { "body": "{{llm.text}}" }
}Retries, errors and duplicates
Short answer: the HTTP Request node can repeat the call up to 10 times, with a maximum interval of 5000 ms, and has an alternative path for failures. With a fixed Idempotency-Key per message, repeating is safe.
Repeating is only safe because of the key: resending the same Idempotency-Key with the same body returns the original response instead of sending another message. If the body changes between attempts, the Hub answers 409 IDEMPOTENCY_KEY_REUSED. So generate the model text once and reuse the same variable on every attempt. Dify also separates connect, read and write timeouts, but the page does not give default values; set them explicitly.
On the error path, the node's status code variable lets you decide what to do: 429 or 5xx deserve a wait and a retry, validation 4xx do not. The errors the Hub returns are listed in the API reference.
| Situation | What the Hub does | What to do in Dify |
|---|---|---|
| Trigger answered 2xx | Delivery complete | Nothing |
| Trigger took over 10 s or failed | Retries up to 9 times over about 4 days | Deduplicate by the body id |
| 20 consecutive failures | Pauses the endpoint | Reactivate with PATCH /api/v1/webhooks/{id} |
| Send rejected by a limit | Returns a rate error | Wait and repeat with the same key |
What is missing in security and how to compensate
Short answer: the Webhook trigger documentation describes no authentication, signature verification or IP restriction, only the method and Content-Type check and the fact that the URL is public. Without verification, anyone who discovers the URL can fire the workflow.
The Hub signs each delivery with HMAC SHA-256 over timestamp.delivery_id.body, and the X-Hub-Signature-256, X-Hub-Timestamp and X-Hub-Delivery-Id headers reach your URL. Dify's trigger can extract headers into variables, turning hyphens into underscores, but checking the signature needs the raw body and a constant-time comparison, and the trigger documentation does not cover that. If the workflow runs something with a cost, like calling a paid model, the safe alternative is a service of your own in front, which validates with the code on the webhooks page and only then calls Dify.
On Dify cloud, the Sandbox account is limited to two triggers per workflow, and you can pause a published trigger in the Access Point tab: while it is off, events are ignored. Treat this like a turned-off Zap: also pause the Hub endpoint so it keeps the delivery history.
Frequently asked questions
Does Dify have a ready-made CRPRO Hub integration?
None was found and none is claimed. The connection uses the Webhook trigger to receive and the HTTP Request node to send, both documented by Dify.
Does Dify's Webhook trigger validate the Hub signature?
The trigger documentation describes no signature verification or authentication. To validate the HMAC, use a service of your own before Dify.
Can I use the trigger in any Dify app?
No. Triggers are a kind of Start node available only in Workflow apps.
How many times can the HTTP Request node retry?
According to the documentation, up to 10 times, with a maximum interval of 5000 ms. Use a fixed Idempotency-Key per message so the retry does not send twice.
Fontes
Documentação oficial da Meta, conferida em 31 de outubro de 2026.