1

im trying to implement a selector for twilio using the Autopilot and Functions.

I'm trying to achieve a text that asks "which one" -

Hello, which one do you like better? 1. Apple, 2. Grape..

i tried everything using the collect.

"collect": {
                        "name": 'preferences',
                        "questions": [
                            {
                                "question": questionText,
                                "name": "selected_option",
                                "type": "Twilio.YES_NO",
                                "voice_digits": {
                                    "mapping": {
                                        "1": "Apple",
                                        "2": "Grape"
                                    },
                                } 
....

In this option i would like to text the field selected_option to be Apple if the user responds with 1

Ishai A.
  • 103
  • 1
  • 6
  • 1
    You have the question type set to `Twilio.YES_NO` but you are asking about fruit. Is that intentional? – philnash Nov 18 '21 at 00:16

1 Answers1

0

I believe you're getting in a little bit of trouble after copying code from the following URL: https://www.twilio.com/docs/autopilot/actions/collect#example-7-collect-a-yes-or-no-response. The code below (copied from that URL) is to collect a Yes/No response:

"question": "Are you a customer? Press or say 1 if you are and 2 if you are not a customer.",
"name": "customer",
"voice_digits": {
    "num_digits": 1,
    "finish_on_key": "#",
    "mapping": {
        "1": "Yes",
        "2": "No"
    }
}

In order to adapt this to a generic question, we'll remove the question type, update the mapping, and substitute the values from your question:

"question": questionText,
"name": "selected_option",
"voice_digits": {
    "num_digits": 1,
    "finish_on_key": "#",
    "mapping": {
        "1": "Apple",
        "2": "Grape"
    }
}
drnugent
  • 1,545
  • 9
  • 22