APIs

Handover API

the handover functionality in kindly allows customer support agents to temporarily replace the bot as the user's conversation partner from the user's perspective, the conversation with the support agent takes place in the same chat window as the conversation with the bot while the support agent is in the chat, the bot will not respond to the user's messages, and when the support agent leaves the chat, the bot will return to the conversation support agent handover can be requested by the user by clicking on a handover request button, which can be easily added to a reply like any other button when a user requests a takover, customer support agents are notified in the platform, and can easily take over the conversation from the conversations section in kindly however, if your organization has a customer service center using a different platform, it is possible to set up a connection between your current platform and kindly to enable handover requests to be handled through your current platform as there does not exist a standarized protocol for this kind of functionality, you will need to do some development to create an intermediary service that can talk to both the kindly api and the customer support platform's api this document describes the protocol for communication between kindly and the intermediate service the handover api was previously named takeover api, and for backwards compatibility the event names still have these names the api paths api/v2/takeover/ and api/v2/handover/ are aliases for the same functions and you may use either architecture suggestions to handle the communication between kindly and your customer support platform, kindly can either communicate directly with the customer support platform or with a intermediary service that forwards messages between the platforms compatibility application compatibility plugin configuration you can find the handover configuration page on your workspace under settings > inbox > handover select external handover mode set the webhook url get api key set values for messages & business hours protocol the protocol is based on http requests between kindly and your service, where each type of request has a unique event name when kindly sends events to your service, they will all arrive at your webhook, and your service will have to decide how to handle them based on the event specified in the payload when you send events from your service to kindly, you can use different api endpoints for different events kindly will respond with a payload that includes an event field to confirm that the request was received and that the parameters were valid ➡️ requesting takeover when a user clicks on a request handover button in the chat, your service will receive a requesting takeover event your service should respond with 200 ok to kindly, then forward the request to the customer support platform example received payload { "event" "requesting takeover", "bot" { "id" 123, "name" "test bot" }, "chat" { " links" { "self" "https //bot kindly ai/api/v1/chats/5af029421a5ca5141a1ee117" }, "id" "5af029421a5ca5141a1ee117", "language" "en", "source" "web" }, "user" { "id" "53616c7465645f5f463b889c43950414f6e08e05442771013db5d3a3953bcedc4ede6c072f91f90f1c7dee18f232f478" } } ⬅️ transcript it is probably useful for the customer service agent to be able to read what the user wrote to the bot and what the bot replied preceding the handover request to get this info your service can post to api/v2/handover/transcript the api will respond with event transcript and contain the message history that you can then show to the agent example post to kindly curl request post \\ \ url https //bot kindly ai/api/v2/handover/transcript \\ \ header 'content type application/json' \\ \ header 'authorization bearer your api key' \\ \ data '{ "bot id" 123, "chat id" "5af029421a5ca5141a1ee117" }' response { "event" "transcript", "chat" { "id" "5af029421a5ca5141a1ee117", "bot id" 123 "messages" \[ ], } } ⬅️ summarized transcripts can be long and take some time for the agent to read and understand it's possible to ask kindly's summarization service to read the chat transcript ahead of the agent joining and provide a short summary of the gist of the conversation you can post to api/v2/handover/summarize to make a summary, the chat has to contain 2 or more user messages that in total contains more than 30 characters the summarization is a call to a large language model that happens on the fly when you make the request the request may take some time to process, and the result summary text may change between requests the model is hosted in the eu curl request post \\ \ url https //bot kindly ai/api/v2/handover/summarize \\ \ header 'content type application/json' \\ \ header 'authorization bearer your api key' \\ \ data '{ "bot id" 123, "chat id" "5af029421a5ca5141a1ee117" }' { "event" "summarized", "chat id" "5af029421a5ca5141a1ee117", "summary" "user interacted with the bot using button clicks to request information about pricing, services, and features of kindly bot provided information about kindly's services, pricing contact process, and customization options, and acknowledged the receipt of user's details " } ⬅️ takeover started when a customer service agent is ready to enter the chat, your service should post to api/v2/handover/start with the relevant bot id and chat id if the api key and the ids are valid, kindly will respond with event takeover started the bot will inform the user that an agent is entering the chat and will no longer respond to the user's messages, until handover is ended by the agent the "sender" field is optional and not be displayed in the legacy version of the chat bubble example post to kindly curl request post \\ \ url https //bot kindly ai/api/v2/handover/start \\ \ header 'content type application/json' \\ \ header 'authorization bearer your api key' \\ \ data '{ "bot id" 123, "chat id" "5af029421a5ca5141a1ee117", "sender" { "name" "customer support", "avatar" "https //ui avatars com/api?name=agent\&size=512" }, "supports attachment" true, }' response { "event" "takeover started", "chat id" "5af029421a5ca5141a1ee117", "chatmessage id" "5af17d2ee9ad1d7d0b3bf03b" } ⬅️ takeover ended when the customer service agent is ready to let the bot take over again, your service should post to api/v2/handover/end with the relevant bot id and chat id if the api key, and the ids are valid, kindly will respond with event takeover ended the bot will inform the user that the agent has left the chat, and will resume responding to the user's messages the "sender" field is optional and not be displayed in the legacy version of the chat bubble example post to kindly curl request post \\ \ url https //bot kindly ai/api/v2/handover/end \\ \ header 'content type application/json' \\ \ header 'authorization bearer your api key' \\ \ data '{ "bot id" 123, "chat id" "5af029421a5ca5141a1ee117", "sender" { "name" "customer support", "avatar" "https //ui avatars com/api?name=agent\&size=512" } }' response { "event" "takeover ended", "chat id" "5af029421a5ca5141a1ee117", "chatmessage id" "5af04d54fba4333215e4a3c7" } ⬅️ message sent to user messages from the support platform to the user can be forwarded to the user by posting to api/v2/handover/message/ in addition to the message, you should also send a name and an avatar in the sender field, indicating to the user that the message is from an agent, not from the bot optionally, you can also use buttons like in other api methods https //docs v2 kindly ai/application api#k sending and receiving , for instance to share a link with the user if the post to kindly was correct, kindly will respond with event message sent to user example post to kindly curl request post \\ \ url https //bot kindly ai/api/v2/handover/message/ \\ \ header 'content type application/json' \\ \ header 'authorization bearer your api key' \\ \ data '{ "bot id" 123, "chat id" "5af029421a5ca5141a1ee117", "message" "this is a message from a customer support agent ", "sender" { "name" "customer support", "avatar" "https //ui avatars com/api?name=agent\&size=512" } }' response { "event" "message sent to user", "chat id" "5af029421a5ca5141a1ee117", "chatmessage id" "5af04d48fba4333215e4a3c6" } ➡️ message from user when the chat is taken over, and the user sends a message, it will be forwarded to your webhook as a message from user event your service should respond 200 ok to kindly, then forward it to the customer support platform example received payload { "bot" { "id" 123, "name" "test bot" }, "chat" { " links" { "self" "https //bot kindly ai/api/v1/chats/5af029421a5ca5141a1ee117" }, "id" "5af029421a5ca5141a1ee117", "language" "en", "source" "web" }, "event" "message from user", "message" "hi!", "user" { "id" "53616c7465645f5f463b889c43950414f6e08e05442771013db5d3a3953bcedc4ede6c072f91f90f1c7dee18f232f478" }, "attachments" \[{ "name" "test jpg", "url" "https //chat kindlycdn com/test jpg", "type" "image/jpeg", "size kb" 100 }] } note the attachment field will be present only if you have started the handover with the supports attachment field set to true ➡️ user ended takeover in certain cases we can detect that the user has left the chat the user restarts the chat the user closes the tab or browser on a bot with the resume conversation if user leaves site and then comes back option set to never note for the last case, however, that if you are testing within the kindly platform this option is overridden and set to forever to test the chat as a user it is recommended to use the demo page in this case kindly will send a request to your service with the event user ended takeover the payload will thus be something like example received payload { "event" "user ended takeover", "bot" , "chat" , "user" } hmacs the messages that are sent from kindly are authenticated using hmacs signed with the same key you use when sending messages to kindly see checking webhook signatures (hmacs) docid\ wi3rdeis d7djwra gtm3 for more info about authenticating hmacs system messages it is also possible to use api/v2/handover/message/ for other messages than those being forwarded from the customer support agent for instance, you could have the service tell the user their place in the queue when it changes example request curl request post \\ \ url https //bot kindly ai/api/v2/handover/message/ \\ \ header 'content type application/json' \\ \ header 'authorization bearer your api key' \\ \ data '{ "bot id" 123, "chat id" "5af029421a5ca5141a1ee117", "message" "you are now number 3 in the queue ", "sender" { "name" "customer service queue", "avatar" "https //ui avatars com/api?name=queue\&size=512" } }'