我想知道如何在自动驾驶聊天机器人中使用twilio对话api。因此,用户开始与bot聊天,在回答了bot的一些问题后,用户被移交给真实的agent,并继续与他们聊天。我已经使用twilio对话api和使用自动驾驶的聊天机器人进行了对话。现在我想知道如何集成它们。
发布于 2021-03-19 00:46:33
Twilio开发者的布道者在这里。
Twilio Autopilot没有对话作为支持的频道,只有可编程聊天。对于这些用例中的大多数,我建议使用Autopilot + Studio +Flex--这样你就可以构建任何东西了!
以下解决方法来自Twilio Supportability工程师Adam Taylor:
listen的情况下命中任务),您可以handoff到另一个小工具。您可以在自动驾驶的内存中添加一个"sendToAgent“指示器,然后使用"Split Based On”小工具检查此指示器,只在适当的时候关闭。
那么Autopilot告别任务示例可能如下所示
{
"actions": [
{
"say": "Great. Please reach out again if you have any questions. I'm sending you to an agent to finish up."
},
{
"remember": {
"sendToAgent": true
}
}
]
}中查找您的工作室flow SID


exports.handler = function(context, event, callback) {
const client = context.getTwilioClient();
const conversationSid = event.ConversationSid;
client.conversations
.conversations(conversationSid)
.webhooks.create({
"configuration.flowSid": "FWxxxxxxxxxxxxxxxx", //update your flow sid here
"configuration.replayAfter": 0,
target: "studio"
})
.then(webhook => {
let responseObject = { "conversationSid": conversationSid, "webhookSid": webhook.sid };
callback(null, responseObject);
})
.catch(err => {
callback(error);
});
};



exports.handler = function(context, event, callback) {
const client = context.getTwilioClient();
const conversationSid = event.ConversationSid;
const webhookSid = event.WebhookSid;
client.conversations
.conversations(conversationSid)
.webhooks(webhookSid)
.remove()
.then(()=> {
let responseObject = { "conversationSid": conversationSid, "webhookSid": webhookSid };
callback(null, responseObject);
})
.catch(err => {
callback(error);
});
};和另一个将参与者添加到会话中的函数
exports.handler = function(context, event, callback) {
const client = context.getTwilioClient();
const conversationSid = event.ConversationSid;
const handoffTo = event.HandoffTo;
client.conversations
.conversations(conversationSid)
.participants
.create({
'messagingBinding.address': handoffTo, // the phone number or whatsapp address you want to handoff messaging conversation to
'messagingBinding.proxyAddress': '+14156632326' // the phone number attached to your messaging service
})
.then(participant => {
let responseObject = { "participantSid": participant.sid, "conversationSid": conversationSid };
callback(null, responseObject);
})
.catch(err => {
callback(error);
});
};最后,添加Studio小部件来运行这些函数并完成交接。

第一个小部件是RunFunction - removeStudioWebhook

函数参数包括ConversationSid: {{trigger.message.ConversationSid}}和WebhookSid: {{trigger.message.WebhookSid}},第二个小部件是RunFunction - addToConversation

函数参数包括ConversationSid:{{trigger.message.ConversationSid}}和WebhookSid: +15555551212 (the number you want to handoff to),第三个参数发送消息

小部件配置:MessageBody: Customer {{contact.channel.address}} is connected with Agent Adam. (replace with your Agent Name)和Send Message To: +15555551213 (replace with the number you want to handoff to)。
Conversations API描述将“基本的自动响应和聊天机器人功能”作为一些自动化功能,“这意味着您可以在Conversations API的帮助下构建自己的聊天机器人。”
如果这有帮助,请让我知道!
https://stackoverflow.com/questions/66672232
复制相似问题