在 twilio 中处理呼叫结束 [英] Handle call end in twilio

查看:30
本文介绍了在 twilio 中处理呼叫结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Twilio 和 Node.js 构建一个对话式语音机器人.每当通话结束时,我都需要将收集到的数据(在 Twilio autopilot Memory 对象中收集)发送到数据库.如果用户使用机器人完成整个问答会话,我就可以将数据发送到数据库.但是如果用户在中间挂断电话,函数的执行就会完全停止.为了处理这个问题,我在 Twilio 控制台中使用CALL STATUS CHANGES"在调用端触发一个函数(称为 callEnd.js)执行.但是 callEnd 参数中提供的事件对象不包含 Memory 对象.我该如何处理?

I am building a conversational voice bot with Twilio and Node.js. Whenever a call ends, I need to send collected data(collected in Twilio autopilot Memory object) to a database. If the user completes the entire question-answer session with the bot, I am able to send the data to a DB. But if the user hangs up the call in between, the execution of functions stops completely. To handle this, I am triggering a function(called callEnd.js) execution on call-end using 'CALL STATUS CHANGES' in the Twilio console. But the event object provided in callEnd parameter does not contain the Memory object. How do I handle this?

我的目标是将部分收集/全部收集的数据推送到数据库.

My objective is to push partially collected/full collected data to DB.

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

如果您的问题分布在多个函数中,并且无论用户通过对话进行多远,您都希望永久存储收集到的数据,那么我建议您在每次收到来自 Autopilot 更新数据库的 webhook 时存储答案以及当时 event.Memory 中的所有内容.

If your questions are distributed over several functions and you want to permanently store the collected data no matter how far through the conversation the user gets, then I recommend that you store the answers each time you receive a webhook from Autopilot updating your database with everything that is in event.Memory at that point.

这样您的数据库就会收集数据,并且无论呼叫到达多远,它都将始终包含用户提供的所有答案.

That way your DB will collect the data and it doesn't matter how far the call gets, it will always have all the answers that the user provided.

这篇关于在 twilio 中处理呼叫结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆