Recipes · R11
Take over a conversation from the bot, then hand it back
When a customer needs a person, your system assigns the conversation, turns the bot off for it, replies, and turns the bot back on when the case is done.
Goal: A person answers without the bot talking over them, and the bot picks up again afterwards.
What starts it
Your own code or webhook
Your own rule decides a person must step in (a keyword, a VIP customer, an escalation in your helpdesk) and calls your code with the conversation.
Your values
The conversation to take over, for example from a `message.received` event.
The staff member who takes over.
What the person says first.
- Step 1
See whether a bot would answer
GETSee whether the bot answers a conversation
`will_answer` and `why` say whether a bot answers the customer's next message, and why.
curl -X GET 'https://api.wa-api.cloud/v1/conversations/77410/bot' \ -H "Authorization: Bearer $API_KEY"
Passes on: will_answer (from will_answer)
- Step 2
Give the conversation to the person
Assigning a conversation never stops the bot, so the next step turns it off.
curl -X PUT 'https://api.wa-api.cloud/v1/conversations/77410/assignment' \ -H "Authorization: Bearer $API_KEY" \ -H 'Content-Type: application/json' \ -d '{ "staff_id": "1203" }' - Step 3
Turn the bot off for this conversation
PUTTurn the bot off or on for a conversation
The inbox's **Chatbot Enabled** switch. Sending the state it already has changes nothing (`changed: false`).
curl -X PUT 'https://api.wa-api.cloud/v1/conversations/77410/bot' \ -H "Authorization: Bearer $API_KEY" \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: takeover-77410-off' \ -d '{ "enabled": false }' - Step 4
Reply as the person
POSTSend a message in a conversation
The reply window must be open (the customer wrote in the last 24 hours on WhatsApp).
curl -X POST 'https://api.wa-api.cloud/v1/conversations/77410/messages' \ -H "Authorization: Bearer $API_KEY" \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: takeover-77410-reply' \ -d '{ "type": "text", "text": "Hi, this is Priya from our team. I'\''m looking at your question now." }'Passes on: message_id (from message_id)
- Step 5
Hand the customer back to the bot
PUTTurn the bot off or on for a conversation
Run this when the case is done. The bot answers the customer's next message again.
curl -X PUT 'https://api.wa-api.cloud/v1/conversations/77410/bot' \ -H "Authorization: Bearer $API_KEY" \ -H 'Content-Type: application/json' \ -H 'Idempotency-Key: takeover-77410-on' \ -d '{ "enabled": true }'
Good to know
Turning the bot off stops new customer messages from reaching it. The step it last reached stays, and a timed bot step that is already pending may still run.
Needs a key with
mcp:read,inbox:write,bots:writeandmessaging:write.
Validated against the API spec on every build