Reputation: 671
I have a workflow that asks different Yes/No questions. Using the Amazon built in Yes and No intents, how can I use them for multiple questions.
Here is an example of the flowchart.
I create a state called "Injury" in order have different handlers for this flow. When the use says "No" to the first question, the AMAZON.NoIntent
emits the BurnIntent
question. At this point if the user says "No", it loops back to the BurnIntent
. How can I determine inside the Yes and No intents which intent to move on to? Is there a way to track which question I'm on to determine which intent to emit?
Upvotes: 0
Views: 2129
Reputation: 41
An alternative way is to make custom yes no slots and use it for each question if your flow isn't too big. This post explains how to do it.
Upvotes: 0
Reputation: 5929
One of the ways would be to keep the state or a question in the self.attributes
. That is some kind of session variables which is shared between intents and wiped out once the user ends using a skill.
For example, you can store there the last question you have asked the user by self.attrbiutes["lastQuestionID"] = questionId
or a current "level". Then, once your "Yes/No" intent has been triggered you can use that value and decide what to do next.
My assumption is that you are using Node.js SDK. But I'm pretty sure there is something similar for other languages.
You can also read a little bit more about state management in the Tips on State Management at Three Different Levels article.
Upvotes: 2