0
votes

I'm attempting to write a "trivia quiz" skill, like many others that already exist, but I would like the user to be able to give actual answers rather than "a/b/c" or "1/2/3". So the conversation will go like this:

  • Alexa: Which planet is closest to the Sun: Mercury or Venus?
  • User: Mercury
  • Alexa: That's correct! You have one point. Which company makes the Corvette, Cadillac or Chevrolet?
  • User: Chevrolet
  • Alexa: That's right! You have two points. What were George Washington's false teeth made from? Wood or ivory?

...etc...

Since each question has its own set of answers, I'm happy to create one custom slot type per question, so I'd have a LIST_Q1_ANSWERS slot of ["Mercury", "Venus"] and a LIST_Q2_ANSWERS slot of ["Cadillac", "Chevrolet"], and that's all fine. However, I do not know how to tell my skill that answers should come from this particular custom slot only.

I can of course create a specific Intent for each question, so I create Q1Intent, I start a Dialog, and I Elicit my Q1Intent. However, this doesn't work out, because in my response to their filling in the required LIST_Q1_ANSWERS slot, I have to say "correct" and also ask the next question, which means that I have to Elicit the Q2Intent... and that's not allowed; I'd have to end the Dialog first, and then start a new one. (So the conversation would go "Which planet...?" "Mercury" "Correct! Do you want the next question?" "Yes" "OK. Which company..." and that's no good.)

I may be over-complicating things here. Perhaps there's an easier way to model the voice interface that I want. I can of course define all the different answers in one big custom slot, and then just have one single AnswerIntent, but then people can answer Chevrolet to the planets question and that's silly. (I know that I have to cope with any answers to a question, not just the ones in the slot, but I'd like to bias the question towards choosing answers from the slot; that's what slots are for.)

So, how should I be doing this? Dialogs won't work, I don't think.

2

2 Answers

1
votes

That is a very reasonable request, IMO, but it is still not possible with Alexa. With some other bot/AI platforms you can specify a context that causes it to try to match the user response against a subset of your skills intents (usually just 1, I would think).

Here is a popular Alexa feature request that gets at the same point:

Allow temporarily disabling intents/utterances based on application state
https://forums.developer.amazon.com/content/idea/40045/allow-temporarily-disabling-intentsutterances-base.html

-1
votes

Yes, I believe that you can do exactly what you want. I did something similar in my "Who's On First?" baseball skit skill.

There are probably many other ways to accomplish this also, but I took the following approach:

  1. Create an intent for each user response. For example, in the above example you stated, "mercury" and "chevrolet" would each be intents.
  2. Pass information forward in the session object. A database could be used, but the session works well in this case. This information will allow your intent handlers to identify the question that was asked. This isn't really necessary if every answer is unique, but it allows multiple questions to have the same answer. For example, maybe the answer "mercury" is an answer to both questions "name a planet" as well as "name a liquid metal".
  3. Since there will be more possible incorrect answers than correct answers, it might make sense to use slots for the incorrect answers. Alternatively, you might just handle unmatched intents as incorrect answers, and use the question ID passed in the session to identify which question was incorrect.
  4. You can put together the response string programmatically. So if the answer is correct, prepend "Correct, the next question is " to the beginning of the next question your skill says.

I hope this gives you an idea for how to proceed. A lot is possible with Alexa. We just need to get creative sometimes.