1
votes

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

I have also tried timeout: 3 and it does not work either.

I have tried

 {
            "listen":true
        }

and

"listen": {

before my task

1
Hi there! Welcome to StackOverflow :D How you are testing your bot? When I test mine in the simulator in the console, the phone call does not end for quite some time and keeps asking me (the user) to repeat, try again, "say that again", and then it starts over with the initial greeting task.lizziepika

1 Answers

0
votes

Twilio developer evangelist here.

You can't use the Listen attribute in a Collect flow, and there is no easy way to add a timeout or pause. 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.

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!