Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
excludeRelated Articles

How the State is used in voice experiences

Starting with an example, the following flowchart depicts user interaction with Alexa in which Yes and No are valid utterances to two questions. (An utterance is the word or phrase used by a user when speaking to Alexa.) For this flow to work correctly, there needs to be a way to differentiate the Yes responses, which is done by setting the state.

...

When Alexa responds to a Yes or No utterance, you set the state in that Say node. You will then need Intent nodes with a state corresponding to the state set in the Say node for the flow to continue.

Accounting for unexpected responses

When building a flow, it’s important to account for responses that do not fit into the model you create.

...

Note: Inheritance is the notion that the flow will first look for state-specific None, Cancel, Help, and Stop intents and, not finding one, will look for non-state-specific, or global None, Cancel, Help, and Stop.

Accounting for any state

You can also create an intent with a state of AnyState, which means no matter where in the flow the user currently is (that is, no matter the state), this intent will fire.

...

Another example is to create a CancelIntent with the state set to AnyState that lets a user get out of whatever flow they are in and start over.

How to use the state to affect the logical flow of the voice experience

The best place to set state in a flow is after an interaction with Alexa. That makes the Say node a perfect place to do this.

...

The drop-down for the Say node lists all possible states you can set. The list shows a number of the possible choices that are intents; either Amazon-specific intents such as YesIntent or intents you created. However, in the Sandbox State Demo, there are also values on this list like help and emergency, which are not intents but state names that are created in intents.

State values created in intents

The proper flow of the State Demo relies on knowing where a user is in a flow. In other words, the flow needs to know if is the user responding Yes that help is needed or Yes that this is an emergency. These two states need to be defined in the flow. This is done in the Intent Request node.

...

  1. Open an Intent Request node in the flow.

  2. Click Edit (pencilicon) beside the Skill Name drop-down box.

  3. In the State field, enter the values of the State relevant to this flow.

  4. Click Update to save your changes.

Setting state in a flow

When you have states to choose from (whether those noted in this flow or all intents available in your skill), you can use them to direct the logic of the flow.

...

Code Block
nodevar orbita = msg.orbita;
orbita.session.LastIntent = ‘stateX’;
return msg;

State examples

Use case 1: a project with many yes or no questions.

  • If the last question is Do you want to quit the survey? with the say node having state = quit.

  • If the user utterance is Yes, then YesIntent is triggered if the node has intent = Yes, and the State = quit.

Use case 2: a project only one help intent node.

  • If you want the HelpIntent to execute no matter what state you are in, you can set the HelpIntent node parameter state to AnyState. In this case, the help intent would respond no matter what the LastIntent is set to.

Use case 3: several Help nodes on the canvas.

  • Consider the parameter state in Say node is set to abcState. A HelpIntent node whose parameter state is set to Any State and another HelpIntent whose parameter state is set to abcState. When the user utterance is help, the HelpIntent with parameter state = abcState would execute; not the HelpIntent node parameter state to Any State.

See also

State Demo, which was included in your Orbita sandbox, demonstrates the flowchart above. It includes documentation specific to the flow.

Related Articles

Filter by label (Content by label)
showLabelsfalse
max5
showSpacefalse
cqllabel = "essential"