Channels
Messaging channels
Voice and web chat carry conversations today. WhatsApp and Viber are on the list and are not in the first release; the API says which is which rather than letting you find out by trying.
Paths, field names, enum values, headers and error codes in these samples are the real ones, checked against the API's own specification when this page is built. The ids, amounts and names in them are illustrative. `$WETALK_API_KEY` and `$AGENT` are shell variables you set yourself.
Four media, two facts each
`availability` is a fact about wetalk: `open` means the medium can be switched on at all, `waitlisted` means it cannot, and `waitlist_reason` says why. `state` is a fact about your workspace — whether you have connected it. Reading them as one value is how a console ends up offering a button that cannot work.
- voice — open. Connected on Numbers & SIP or on the agent's Channels tab, not here.
- web_chat — open. Add your site's address, then paste the snippet.
- whatsapp — waitlisted.
- viber — waitlisted.
curl https://api.wetalk.io/v1/messaging/media \
-H "Authorization: Bearer $WETALK_API_KEY" Connecting one
Binding a medium to an agent is one request. It is refused with `409` for a waitlisted medium and for `voice` — numbers and SIP trunks are the Numbers and SIP surface, and binding a number in two places is how one of them ends up wrong. The refusal says which of the two it is.
For web chat the body also needs `site_origin` — the address of the website the chat goes on (`https://host[:port]`; plain `http` only for `localhost`) — which becomes the widget's first allowed site; without it the request is refused with `400 origin_invalid`. A voice agent that already has a widget gets it back, re-enabled, with the address added (`200`); otherwise a new one is made (`201`).
For web chat the binding id **is** the widget key. It is pasted into your own page, carries no scope and is not a secret, which is the only shape a public identifier can safely have. Paste `snippet` exactly as it comes back, before `</body>`; a site with a Content-Security-Policy adds the lines in `content_security_policy`.
curl https://api.wetalk.io/v1/messaging/media/web_chat/connection \
-X POST \
-H "Authorization: Bearer $WETALK_API_KEY"
-H "Content-Type: application/json" \
-H "Idempotency-Key: 0199f1c2-6b46-7b58-9299-7e5f0a81c376" \
-d '{
"voice_agent_id": "0199f1c2-6b40-7a11-9d3e-6c1b5f0a2e77",
"site_origin": "https://www.romapizzeria.example"
}' {
"data": {
"channel_binding_id": "0199f1c2-6b47-7c69-83aa-8f601b92d487",
"medium": "web_chat",
"kind": "web_chat_widget",
"voice_agent_id": "0199f1c2-6b40-7a11-9d3e-6c1b5f0a2e77",
"voice_agent_name": "Roma orders",
"widget": {
"channel_binding_id": "0199f1c2-6b47-7c69-83aa-8f601b92d487",
"voice_agent_id": "0199f1c2-6b40-7a11-9d3e-6c1b5f0a2e77",
"voice_agent_name": "Roma orders",
"widget_key": "0199f1c2-6b47-7c69-83aa-8f601b92d487",
"state": "answering",
"enabled": true,
"voice_enabled": false,
"allowed_origin": ["https://www.romapizzeria.example"],
"snippet": "<script src=\"https://webrtc.wetalk.io/v1/widget/chat.js\" data-widget-key=\"0199f1c2-6b47-7c69-83aa-8f601b92d487\" data-accent=\"…\" data-position=\"right\" async></script>",
"content_security_policy": {
"text": ["script-src https://webrtc.wetalk.io", "connect-src https://webrtc.wetalk.io wss://webrtc.wetalk.io"],
"voice": ["frame-src https://webrtc.wetalk.io"]
}
}
}
} Allowed sites and voice in the widget
The widget answers only on the sites you list, at most 20. The list is replaced whole; an empty list while the chat or its voice is on is refused with `422 origin_list_empty`, so removing the last site cannot switch the chat off everywhere by accident. A site check stops the widget being put on somebody else's page; it is not a password.
Turn the widget's voice on and a visitor can talk to the agent from the same bubble, in the browser. The typed and the spoken parts are one conversation, and the spoken part is billed at your website voice rate.
curl https://api.wetalk.io/v1/messaging/media/web_chat/widgets/$WIDGET/origins \
-X PUT \
-H "Authorization: Bearer $WETALK_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "allowed_origin": ["https://www.romapizzeria.example", "https://romapizzeria.example"] }' curl https://api.wetalk.io/v1/messaging/media/web_chat/widgets/$WIDGET \
-X PATCH \
-H "Authorization: Bearer $WETALK_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "voice_enabled": true }' Turning one off
Disconnecting stops the agent answering on that medium and keeps the history. Conversations already in flight are not cut off, for the same reason publishing a version does not cut off a call.
curl https://api.wetalk.io/v1/messaging/media/web_chat/disconnection \
-X POST \
-H "Authorization: Bearer $WETALK_API_KEY" Everything that is not a phone call
Messaging conversations are read from their own list, filtered the same way and paginated the same way as voice. A conversation is a conversation whatever carried it: the same metered unit, the same concurrency limit, the same transcript.
Messaging is billed by active time at your text rate, never per message.
curl -G https://api.wetalk.io/v1/messaging/conversations \
-H "Authorization: Bearer $WETALK_API_KEY"
--data-urlencode "limit=25"