Tiledesk Docs
Search…
Chatbot to Human handoff
Move a conversation to a human
This article is about transfering a conversation from the initial chatbot to a human using Tiledesk external-chatbot technology. This feature is named chatbot to human handoff.
In this example, after the initial greeting message the chatbot proposes you to move to an agent. If you reply "yes" the handoff will occur.
image
You can handoff to human agents from any Tiledesk chatbot (native or external) simply sending the \agent text as the last line of any message. This message tells Tiledesk to remove the chatbot from the current conversation and invite a human in its place. As soon as Tiledesk sees this command in the text it will remove the current chatbot from the current conversation and will try to invite a human, following the current department rules. If no agents are available the conversation will wait in the “unassigned” queue from where it can be pulled by an agent as soon as one becomes available again.
We wrote a full Node.js repl.it example that you can fork or copy.
Here follows the source code of index.js file in the example:
1
const express = require('express');
2
const bodyParser = require('body-parser');
3
const { TiledeskChatbotClient } = require('@tiledesk/tiledesk-chatbot-client');
4
5
const app = express();
6
app.use(bodyParser.json());
7
8
app.get('/', (req, res) => {
9
res.send("Tiledesk External-Chatbot to Human handoff Tutorial");
10
});
11
12
app.post('/bot', (req, res) => {
13
res.status(200).send({"success":true});
14
const tdclient =
15
new TiledeskChatbotClient(
16
{
17
request: req,
18
APIKEY: '__APIKEY__'
19
});
20
if (tdclient.text === "\\start") {
21
tdclient.sendMessage({
22
text: 'Cheers! Need operator?'
23
});
24
}
25
else if (tdclient.text === "yes") {
26
tdclient.sendMessage({text: 'Moving you to an operator...'}, (err) => {
27
tdclient.sendMessage(
28
{
29
text: '\\agent',
30
attributes: {
31
subtype: 'info' // widget-hidden message
32
}
33
});
34
});
35
}
36
else {
37
tdclient.sendMessage({text: 'Not trained for this'});
38
}
39
});
40
41
app.listen(3000, () => {
42
console.log('server started');
43
});
Copied!
Just note that if you send the '\agent' command it will be visible to the end-user in the Widget. If you want to hide this command-message you must send it as an "info" message. Info messages are always hidden from the end-user conversation.
In the example you see the code sending a first message to indicate the start of the "Agent switching" operation ('Moving you to an operator...'). As soon as this message is sent we send the handoff command ('\agent') as hidden (attributes.subtype = 'info'). This message will start the handoff operation.
image
Do you have suggestions on this article? Please send us your feedback writing an email to [email protected]
Last modified 3d ago
Copy link