1

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

Eddy Alleman
  • 1,096
  • 2
  • 10
  • 21
clearuser
  • 11
  • 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 Sep 02 '19 at 08:21

1 Answers1

0

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!

lizziepika
  • 3,231
  • 1
  • 14
  • 23
  • Thank you for that help and comments. The issue is it drops the call if we do not speak fast enough. For example: within 2 to 3 seconds if you do not say the whole input it will hang up. We are looking for a phone number and some people delay before saying it and others taker longer to say the number. The syntax you sent worked for the validate but it seems it happening still. It does give me the response of whatever I have under on_success and then the on_complete function. – clearuser Sep 04 '19 at 22:23
  • Another possibility is that the fallback or collect failure defaults are not set. What's your SID? We can look up the events to figure out what's happening! – lizziepika Sep 04 '19 at 23:26