简体   繁体   English

如何在自动驾驶仪中添加侦听或超时功能?

[英]How to add in a listen or timeout function in autopilot?

I have a syntax issue I believe in getting my autopilot response to work. 我有一个语法问题,我相信我的自动驾驶仪响应可以正常工作。 My program works but after the autopilot asks the question, it does not give much time for the user to say the response before stopping/hanging up the call. 我的程序可以运行,但是在自动驾驶仪问了问题之后,用户没有太多时间在停止/挂断电话之前说出响应。

Is there a way to add in a timeout or pause? 有没有办法添加超时或暂停? I have tried the syntax for this but it does not work. 我已经尝试过为此语法,但它不起作用。 This is what I have: 这就是我所拥有的:

    "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......"
                    }
                }
            }
        }
    ]
}

When I add below 当我在下面添加

 {
            "listen":true
        }

anywhere in this syntax it does not work and gives me an error of: .actions[0].collect.questions[0] should NOT have additional properties 此语法中的任何地方均不起作用,并给我以下错误:.actions [0] .collect.questions [0]不应具有其他属性

I have also tried timeout: 3 and it does not work either. 我也尝试了超时:3,它也不起作用。

I have tried 我努力了

 {
            "listen":true
        }

and

"listen": {

before my task 在我的任务之前

Twilio developer evangelist here. Twilio开发人员布道者在这里。

You can't use the Listen attribute in a Collect flow, and there is no easy way to add a timeout or pause. 您不能在“ Collect流中使用“ Listen属性,并且没有简单的方法来添加超时或暂停。 You can, however, add on a Validate action to your Collect flow like so and increase the number of max_attempts so your Autopilot bot repeats the question or asks the user to try again/say their response again. 但是,您可以像这样将“ Validate操作添加到您的“ Collect流程中,并增加max_attempts的数量,以便您的Autopilot机器人重复该问题或要求用户重试/再次说出他们的回答。

I'm wondering why this is happening because when I use my bots via phone call, the call stays open for quite a long time waiting for the user's response. 我想知道为什么会这样,因为当我通过电话使用我的机器人时,电话会保持打开状态很长一段时间,以等待用户的响应。

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);
};

Let me know if this helps at all! 让我知道这是否有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM