[英]How to add in a listen or timeout function in autopilot?
我有一个语法问题,我相信我的自动驾驶仪响应可以正常工作。 我的程序可以运行,但是在自动驾驶仪问了问题之后,用户没有太多时间在停止/挂断电话之前说出响应。
有没有办法添加超时或暂停? 我已经尝试过为此语法,但它不起作用。 这就是我所拥有的:
"actions": [
{
"collect": {
"name": "user_input",
"questions": [
{
"question": "Welcome to the modem status check line?",
"name": "search",
"type": "Twilio.NUMBER"
}
],
"on_complete": {
"redirect": {
"method": "POST",
"uri": "https://website......"
}
}
}
}
]
}
当我在下面添加
{
"listen":true
}
此语法中的任何地方均不起作用,并给我以下错误:.actions [0] .collect.questions [0]不应具有其他属性
我也尝试了超时:3,它也不起作用。
我努力了
{
"listen":true
}
和
"listen": {
在我的任务之前
Twilio开发人员布道者在这里。
您不能在“ Collect
流中使用“ Listen
属性,并且没有简单的方法来添加超时或暂停。 但是,您可以像这样将“ Validate
操作添加到您的“ Collect
流程中,并增加max_attempts
的数量,以便您的Autopilot机器人重复该问题或要求用户重试/再次说出他们的回答。
我想知道为什么会这样,因为当我通过电话使用我的机器人时,电话会保持打开状态很长一段时间,以等待用户的响应。
exports.handler = function(context, event, callback) {
const responseObject = {
"actions": [
{
"collect": {
"name": "collect_clothes_order",
"questions": [
{
"question": "What is your first name?",
"name": "first_name",
"type": "Twilio.FIRST_NAME"
},
{
"question": "What type of clothes would you like?",
"name": "clothes_type",
"type": "CLOTHING",
"validate": {
"on_failure": {
"messages": [
{
"say": "Sorry, that's not a clothing type we have. We have shirts, shoes, pants, skirts, and dresses."
}
],
"repeat_question": true
},
"on_success": {
"say": "Great, I've got your the clothing type you want."
},
"max_attempts": {
"redirect": "task://collect_fallback",
"num_attempts": 3
}
}
}
],
"on_complete": {
"redirect": "https://rosewood-starling-9398.twil.io/collect"
}
}
}
]
};
callback(null, responseObject);
};
让我知道这是否有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.