1

We have an application that has multiple choice options that then route to other tasks. Currently, we are using samples, but in places where we want strict matching, wrong answers are being selected rather than repeating the question event though the confidence is low. e.g. Samples/Acceptable options: "Option 1","Option 2","Option 3","Option 4"; User answer: "Option 6" which ends up matching "Option 3" instead of re-asking the question. It would be nice to be able to set strict confidence on Samples. Is there a simple way to do this outside of using Functions?

We're programmatically generating schemas and wonder if there is a scalable way to generate functions to meet these needs. Programmatically generating Javascript functions sounds like a nightmare.

Scott
  • 21
  • 5

1 Answers1

0

Twilio developer evangelist here.

Sounds like you need to use Collect for this, with a validate property that ensures the answer is among your list of answers.

For example, this would ask for an option between 1 and 4 and only accept the answers "Option 1", "Option 2", "Option 3" or "Option 4":

{
  "actions": [
    {
      "collect": {
        "name": "collect_options",
        "questions": [
          {
            "question": "Please choose an option from 1 to 4",
            "name": "option",
            "validate": {
              "allowed_values": {
                "list": [
                  "Option 1",
                  "Option 2",
                  "Option 3",
                  "Option 4"
                ]
              },
              "on_failure": {
                "messages": [
                  {
                    "say": "Sorry, that's not a valid option."
                  }
                ],
                "repeat_question": true
              },
              "on_success": {
                "say": "Good choice!"
              },
              "max_attempts": {
                "redirect": "task://having-trouble",
                "num_attempts": 3
              }
            }
          }
        ],
        "on_complete": {
          "redirect": "https://example.com/collect"
        }
      }
    }
  ]
}

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • thanks for your response. We looked into this, but we want our multiple choice options to lead to different tasks similar to how "listen" works with samples. Is there an easy way to route to several different tasks using collect without having to create functions? – Scott May 26 '20 at 12:27
  • Hmmm... OK. This would work if you used a function to do the redirect after the result, but we can try to work without that. Have you tried training the incorrect option ("Option 5") to not feed to option 3 but to trigger a fallback task which asks again? – philnash May 27 '20 at 06:15
  • We're creating large numbers of chatbots with different questions and answers. There's not a scalable way to train all of the bots to respond strictly to the samples. It'd be great if there were out of the box options for matching such as "strict" that would force matching to adhere to a certain task confidence level. For now, we're planning on using number or letter prefixes for users to enter instead of the answer since "A" is not matching "M" out of the box, but longer answers such as "Option 5" are matching "Option 3" because relatively it's a closer match. Lmk if you know a simpler way. – Scott May 27 '20 at 15:20
  • 1
    For exact answers, the simpler way is validating collect answers. You will need a dynamic reponse on the end of your redirect, but that's the best way to deal with this in Autopilot. – philnash May 28 '20 at 23:23