Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

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.

The blue diamonds represent responses from Alexa and correspond to Say nodes. The responses that can have a Yes or No answer are I heard you need help, is that correct? and Is this an emergency?

The State defines the context/session in which the next intent is triggered.

As you can see by the flow, a Yes utterance to I heard you need help, is that correct? produces a different response than a Yes Utterance to Is this an emergency? The same is true for a No utterance.

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.

For any flow that requires a certain utterance to continue, you need to account for those utterances that are not expected and query the user until you receive an expected answer. You can do this using a None Intent with the state set.

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.

In the interaction diagrammed above, assuming the user must reply either Yes or No when asked if this an emergency, you can set the state to emergency in the Say node that asks that question. You include a YesIntent and NoIntent to account for the expected answers for this state. You also use a None Intent, which accounts for answers other than those expected for this State.

If there is no None Intent for the current state, the system looks for a None Intent defined at a global level. That is the one that is not defined for a particular state. The same is true for the following Intents:

  • CancelIntent

  • HelpIntent

  • StopIntent

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.

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 over.

Some intent but one intent has the state “AnyState”, the other has the State “Survey”

If you create an intent with a state of AnyState, and the same intent with the State “Survey”

Note:

  1. The intent node with State=Survey will take priority over AnyState, if in the state Survey when an intent fires.

  2. AnyState includes noState. If you have 2 nodes, one with AnyState, and another with noState, and you are in the state noState, then the intent node State=noState will execute.

  3. The say node has a check box,  “Disable Any State Check For Next Request” Let's say you are in a flow doing a survey, and you do not want an intent that has AnyState to fire. For example, you probably would have the Answer Group intent node state=AnyState. An utterance that would have triggered the Answer Group intent does not instead it triggers the none intent, this would cause the flow manager to repeat the question.

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. That makes the Say node a perfect place to do this.

The state can be found in the Intent Request node and Say node.

The Say node has a field for the state. The default is No State, which means that any intent can run next.

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. 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.

  1. Create an Intent Request node (or nodes) that will only fire for a specific state.

  2. Create or choose the intent.

  3. Choose the value of the State.

  4. Continue creating the intent by adding slots and utterances.

  5. Click Done

Note what the Intent Request node you just created looks like. It lists the skill, the intent, and the state. Reading this as it applies to the State Demo flow, this is the YesIntent for MySkill that only fires when the state is set to help.

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

msg.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

  • No labels