Conversation channels
A conversation channel is a webhook that receives messages from an
external system β WhatsApp, Telegram, Intercom, your company's app β and
answers through Kadu. The answer goes back by HTTP POST to the address you
set.
The channel only talks: it does not run tasks, because there is no person authenticated in Kadu on the other side. The answer comes from the AI model of the conversation tier, set by Kobana; the organization does not choose the tier. Each answer is billed as a conversation (see Usage).
Createβ
In Settings β Conversation channels, click New channel:
| Field | Rule |
|---|---|
| Name | identifies the channel. |
| Type | free label (webhook, whatsapp, telegramβ¦): lowercase letters, digits, _ and -. It does not change the behavior. |
| System prompt | the instructions of the assistant in this channel: tone, subject, what it may and may not say. |
| Outbound URL | optional. The answer is POSTed here. Without a URL it is only stored. Private or loopback addresses are rejected. |
| Outbound secret | optional. Sent in the Authorization: Bearer header of the answer. When editing, leave it blank to keep the current one, or check Remove the outbound secret. |
| Signing secret | optional. For providers that sign the body instead of sending the token: on WhatsApp, the Meta App Secret. See Signature. When editing, leave it blank to keep the current one, or check Remove the signing secret. |
| Mapping (JSON) | optional. Where the text and the conversation id are in the received payload, and the answer body. See Mapping. |
On save, the console shows the channel's Inbound URL (POST) and Token. The token is shown only once: copy it and store it in the system that will send the messages.
The table on the screen shows, for each channel, the name, type, inbound URL, number of conversations and the Active switch.
Sending messagesβ
The external system sends each message as JSON to the inbound URL:
POST https://api.kadu.ia.br/channels/{id}/inbound
Each POST authenticates in one of two ways: with the channel token or
with the body's signature. One of them matching is enough.
The token goes only in a header, one of these (all three are checked, so a
provider's own Authorization header does not hide the token sent in the
others):
Authorization: Bearer <token>;X-Channel-Token: <token>;- the header set in
config.inbound.tokenHeader, for providers that do not let you choose the name (Telegram sendsX-Telegram-Bot-Api-Secret-Token).
A token in the query string is rejected: the full URL ends up in CDN and load balancer logs.
curl -X POST "https://api.kadu.ia.br/channels/$CHANNEL_ID/inbound" \
-H "Authorization: Bearer $CHANNEL_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "When is my bank slip due?",
"conversation_id": "customer-4821",
"message_id": "msg-0001",
"sender": "Maria"
}'
The response is 202 as soon as the message is stored; the model's answer
leaves later, through the outbound URL:
{ "data": { "message_id": "β¦", "conversation_id": "β¦", "queued": true } }
| Response | When |
|---|---|
202 | message stored. With "duplicate": true, it was a redelivery (see below); with "ignored": true, the event was discarded; with "messages", the delivery carried several messages (see below) |
401 unauthorized | neither the token nor the signature matches |
403 channel_inactive | the channel is disabled |
404 not_found | the channel does not exist |
400 validation_failed | body that is not JSON, or whose reading was cut off midway |
413 payload_too_large | body over 256 KB |
422 conversation_unidentified | the message has text but neither a conversation id nor a sender: map inbound.externalThreadId or inbound.sender. Nothing is stored |
429 | more than 20 failed authentications per minute from the same IP on the channel; the IP stays blocked until the end of the minute, even with the right token |
An event without text (read receipt, status change, button click) is
discarded, even if it carries a conversation id, sender or message id: the
response is 202 with { "data": { "ignored": true } }, nothing is stored and
no conversation is created.
Several messages in one deliveryβ
Meta may batch several messages in a single POST
(entry[].changes[].value.messages[]), even from different people. Kadu splits
each item into its own message, each in its own conversation, up to 50 per
delivery. With more than one message, the 202 body carries one item per
message, in the order received:
{
"data": {
"messages": [
{ "message_id": "β¦", "conversation_id": "β¦", "queued": true },
{ "ignored": true }
]
}
}
Above 50, the extra items are discarded and the body also carries
"dropped" with how many. An item with nothing that identifies the
conversation comes back as { "ignored": true } and the others proceed.
With a single message, the body is the usual one. The split only happens when
the mapping does not set inbound.text.
Signatureβ
Some providers do not let you send a custom header and sign the body instead.
WhatsApp Cloud API works this way: each POST carries
X-Hub-Signature-256: sha256=<hex>, the HMAC-SHA256 of the raw body with the
Meta app's App Secret.
To accept these POSTs, save the App Secret in the channel's Signing
secret. Kadu computes the HMAC-SHA256 of the received body, byte for byte,
and compares it with the header. The header and prefix can be set in
inbound.signature of the mapping (default X-Hub-Signature-256 and
sha256=), for another provider that signs the same way.
Conversations and redeliveriesβ
Each conversation has its own history: the model receives the previous
messages of the same conversation. The conversation is identified by the
conversation id in the payload; without it, by the sender. Without either, the
message is refused with 422 conversation_unidentified β messages from
different people never mix. The message id is not enough: each message
would become a conversation with no history, outside the per-conversation
spending limit.
Resending the same message id in the same conversation answers 202 with
"duplicate": true and does not answer again. Send the provider's message
id whenever there is one: it is what makes a retry safe. If the original is
still waiting its turn, the queue is woken up; if it already used up its
attempts, it gets one more β at most 3 times, counting the automatic retries,
and only if no newer message has already been answered.
The messages of one conversation are answered one at a time, in the order they arrived: when one finishes, Kadu moves on to the next one of the same conversation. A question that fails is tried again up to 3 times, a few seconds apart, and the newer ones wait for it; once its attempts run out, the newer ones go ahead.
A question that failed all its attempts (the AI service down, for example) is picked up again about 15 minutes later, with one attempt, up to 3 times, as long as no newer message in the conversation has already been answered β answering after the later ones would be out of order. After that it stays unanswered. A message stuck for any other reason (processing restart, queue outage) is also picked up after about 15 minutes, under the same rule: if a newer message has already been answered, it stays unanswered. Waiting its turn in a conversation with many messages does not count as stuck.
Address verificationβ
For Meta's webhook verification (WhatsApp Cloud API), Meta sends a GET to
the inbound URL with hub.challenge and hub.verify_token. The verify token
is not the channel token: choose your own string (8 to 200 characters),
save it in inbound.verifyToken of the mapping and enter the same value in
Meta's dashboard. It travels in the query string, so it only serves for this
verification. Kadu returns hub.challenge when hub.verify_token matches;
without verifyToken configured, the verification answers 401.
The verifyToken is not shown once saved: reading the channel returns the
mapping without it and only says whether it exists (has_verify_token). When
changing the mapping, leave the field out to keep the current one, or send
null to clear it.
Mappingβ
Without a mapping, the channel recognizes the most common formats:
| Field | Where Kadu looks, in this order |
|---|---|
| Text | text, message, body, message.text (Telegram), messages.0.text.body, messages.0.text, entry.0.changes.0.value.messages.0.text.body (WhatsApp Cloud) |
| Conversation id | thread_id, conversation_id, conversation.id, message.chat.id (Telegram), chat.id, messages.0.from, entry.0.changes.0.value.messages.0.from (WhatsApp Cloud), from |
| Message id | message_id, message.message_id (Telegram), messages.0.id, entry.0.changes.0.value.messages.0.id (WhatsApp Cloud) |
| Sender | sender, user, message.from.id (Telegram), messages.0.from, entry.0.changes.0.value.messages.0.from (WhatsApp Cloud), from |
For another format, fill in Mapping (JSON) with the path of each field, in dot notation (a numeric index walks a list). The configured path is tried first; the common formats still work as a fallback.
A bare id at the root of the payload does not count as the message id:
it usually belongs to the customer or contact. If your provider's message id
is there, map it in inbound.externalMessageId ("externalMessageId": "id").
| Key | What it is |
|---|---|
inbound.text | path of the message text |
inbound.externalThreadId | path of the conversation id in the external system |
inbound.externalMessageId | path of the message id (avoids answering twice) |
inbound.sender | path of the sender |
inbound.tokenHeader | extra header that carries the channel token |
inbound.verifyToken | the verify token of Meta's verification (8 to 200 characters; see Address verification) |
inbound.signature.header, inbound.signature.prefix | header and prefix of the signature (default X-Hub-Signature-256 and sha256=) |
outbound.header | header that carries the outbound secret (default Authorization, with Bearer; another name carries the raw value). It cannot be a header the POST builds itself or that changes routing (host, content-type, content-length, transfer-encoding, connection, keep-alive, upgrade, te, trailer, proxy-authorization, proxy-connection, expect, cookie): a mapping with one of them is refused |
outbound.template | answer body (see Answer) |
Example: Telegramβ
Telegram sends the webhook's secret token in its own header. Register the
channel token as secret_token in the bot's setWebhook and set the header:
{
"inbound": {
"text": "message.text",
"externalThreadId": "message.chat.id",
"externalMessageId": "message.message_id",
"sender": "message.from.id",
"tokenHeader": "X-Telegram-Bot-Api-Secret-Token"
},
"outbound": {
"template": { "chat_id": "{{externalThreadId}}", "text": "{{text}}" }
}
}
With the outbound URL https://api.telegram.org/bot<bot-token>/sendMessage, the
answer reaches the same chat.
Example: WhatsApp Cloud APIβ
WhatsApp does not send the channel token: it authenticates with the signature. The payload paths are recognized without a mapping; the mapping carries the verify token and the answer body in the Graph API format:
{
"inbound": {
"verifyToken": "a-string-you-choose"
},
"outbound": {
"template": {
"messaging_product": "whatsapp",
"to": "{{sender}}",
"type": "text",
"text": { "body": "{{text}}" }
}
}
}
On the channel:
- Signing secret: the Meta app's App Secret.
- Outbound URL:
https://graph.facebook.com/<version>/<phone-number-id>/messages. - Outbound secret: Meta's access token.
In Meta's dashboard, enter the inbound URL as the Callback URL and the same
verifyToken as the Verify token.
Answerβ
With an Outbound URL, each answer from the model is POSTed as JSON.
Without outbound.template, the body is:
{ "text": "Your bank slip is due on the 10th.", "thread_id": "customer-4821", "in_reply_to": "msg-0001" }
With outbound.template, the body is the template, with these placeholders
replaced in any of its strings: {{text}} (the answer), {{externalThreadId}},
{{externalMessageId}} and {{sender}}.
The outbound secret goes in Authorization: Bearer <secret> or in the
outbound.header header. Delivery does not follow redirects, and a failure
(network error or status outside 2xx) is not resent.
Without an outbound URL, the answer is only stored in Kadu.
Rotate the token, disable and deleteβ
- Rotate token generates a new token and shows it once. The old one stops working right away: update the system that sends the messages at once.
- The Active switch turns the channel off without deleting it: the inbound
URL answers
403 channel_inactiveand nothing is answered until you turn it back on. - Delete makes the channel stop receiving messages. Conversations and usage stay recorded.
The raw payload the provider sends with each message (with phone number, name and the rest of the event) is erased after 90 days. The message text and the conversation stay.
Creating, editing, rotating the token and deleting depend on your role's channel permissions (rotating the token counts as editing).
Limitsβ
| Limit | Value |
|---|---|
| Failed authentications | 20 per minute per IP and channel (a channel address that does not exist counts in a quota of the IP alone, which applies only to those addresses); after that, 429 until the end of the minute. Authenticated deliveries have no per-IP limit: cost is bounded by each sender's messages-per-minute limit and the usage rules |
| Body size | 256 KB (413 above that) |
| Text size | 32,000 characters; the rest is cut |
| Messages per delivery | 50; the rest are discarded ("dropped" in the response) |
| History sent to the model | the 30 most recent messages of the conversation |
Usageβ
Each answered message is a conversation turn, measured and billed like the Slack bot conversations: tokens Γ the conversation tier's price, in the same monthly usage, the same credit allowance and the same monthly cap, with the same spending limit per conversation. Each sender has a limit of messages per minute: above it, the message is not refused β it waits for the next minute and is answered then.
Without a plan, allowance or balance, with the cap reached, with the
conversation's spending limit used up or with the channel or tier disabled,
the message is refused before calling the model: nothing is billed and no answer is sent.
In Analytics and in GET /v1/usage, these turns show up
with the source Channel conversations. See
Plan and costs.
Through the API and MCPβ
The same configuration is in the API: GET and POST on /v1/channels,
GET, PATCH and DELETE on /v1/channels/{id} and
POST /v1/channels/{id}/rotate-token (scope kadu/channels). The token is
only returned on create and on rotation. The signing secret goes in the
inbound_signature_secret field, which is never returned: the response only
says whether it exists (has_inbound_signature_secret). In MCP, these are the
kadu_channels_* tools (Conversation channels);
creating, deleting, rotating the token and changing the status, the outbound
side, the signing secret or the mapping ask for your confirmation.