How to do agent handoff in the chatbot
What is agent handoff?
Agent handoff is a feature often used in chatbots when a user wants to connect with a human agent. When a user requests to talk to an agent, we can collect more details like their email, the nature of their issue, and any extra information they can provide. This information is then used to generate a support ticket for a live agent to assist them.
How to implement agent handoff in the chatbot flow?
- We need to create a Custom reply. Follow the instructions here to create an agent handoff custom reply.
Example of an agent handoff custom reply:
- We need to add Decision and User Input nodes after the "Send answer to chat" node. Learn more about creating nodes here.
- For the "Send answer to chat" node we need to add an expression.
In this JavaScript code we are adding a condition by checking if ctx.playgroundAnswer.source includes "agent_handoff".
"agent_handoff" is a name of the custom reply we added earlier and for each custom reply it will be different.
if (ctx.playgroundAnswer.source.includes('agent_handoff')) {
return 2;
}
Learn more about expressions here
- To the first decision node that we created, we need to add a request to send a question "Please provide your email address:" to the chat.
Here you can find an example of creating a request that sends a message to the chatbot.
- To the next User Input node we need to create new variables.
You can copy and paste the JSON from the existing "User input (ML Answer NOT Given)" node and change the variables as we did it here on step 5.
- To the next decision node we need to add a request that sends a message to the chatbot.
We can send a message like "Thank you for the provided information. Our agent will reach out to you as soon as possible.".
Here you can find an example of creating a request that sends a message to the chatbot.
After sending a message to the chatbot you can also add requests to create a ticket to your ticketing system. Click here to learn more about creating requests.
If you don't want the text field to be shown after the last message in the chatbot you can add this "showTextField": false
inside the content object in the request.
- For the last node in agent handoff we need to set the "Resolution type" to "AGENT_FALLBACK" so it could show the accurate data in analytics in the future.
- All done! Now we need to test the chatbot.