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 or Chat experiences

Agents like Flow, Surveys, manage state, but it important to understand how to manage state in Experience designer.

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.

...

A None Intent fires if a user says something that maps to an Intent that is not valid for the current state, such as answering orange to a yes or no query.

Note: Alexa/Google maps everything a user says to an Intent.

...

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

See this video explaining states with the intent node

You can also create an intent node with a state of AnyState, which means no matter where in the flow the user currently is if the intent occurs (that is, no matter what the Last state was set to, or if the last state was set to No State), this intent node will fire.

For example, you can use AnyState in a scenario in which the voice application lets a user pick from a list of menu options. You can create intents for the available options with the state set to whatever the user chooses, plus an intent with the state set to AnyState that returns the user to the Main Menu.

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 overUnless

  1. There is no last state, and there is an intent node that matche the intent with No State set.

  2. There is another intent node on the canvas that has the state selector set to the current state.

  3. The last Say node has the check box “Disable Any State Check for Next Request” checked.

...

Example: In this example will add 3 intent nodes for the intent test, that respond by the utterance “test”
1st node State = “No State”
2nd node State = “Any State”
3rd node State = “t0”

...

  1. User types--> “TEST” -- > the intent with State = “No State” will fire. This will set the Last State value to “t0”

  2. The user again types → “Test” → the intent with State = “t0” i.e the one connected to the debug node “State equal” will fire. This will set the Last State value to “t1”

  3. The user again types → “Test” → the intent with State = “Any State” i.e the one connected to the debug node “anyState” will fire. This will set the Last State value to “t2”

    Next:

  4. Delete the intent node, with State = “No State”

...

  1. Refresh the chatBot, so there is no state in the session.
    The user again types → “Test” → the intent with State = “Any State” will fire. This will set the Last State value to “t2”

    If that Say node with the state set to “t2” also has:

    Image Added

    Then only an Intent node with Intent Test and State = T2 will fire. If one does not exist, then the None Intent will fire.

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

The best place to set a 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.

To create State values in an Intent Request node:

...

Open an Intent Request node in the flow.

...

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

...

Click Update to save your changes.

...

The Set State drop-down list is populated by intent names and the launch node State comma-separated list.

...

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.

...

The state is stored in a session LastIntent. You can also set the state via a function.

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 = "experience-manageressential"