copyright: years: 2017, 2023 lastupdated: "2023-01-06"
Defining actions and states
The IBM® Voice Gateway API provides action tags and state variables that you define within the dialog in the IBM Watson™ Assistant service. Action tags initiate actions that Voice Gateway takes during a conversation session, and state variables define Voice Gateway characteristics that persist throughout the conversation unless otherwise changed.
Editing JSON in the Watson Assistant dialog response
Both actions and states are defined within the Watson Assistant service in a dialog node response in JSON format. To edit the JSON code, you need to open the JSON editor.
- From the IBM® Cloud dashboard, select your Watson Assistant service instance.
- Launch the Watson Assistant tool.
- Click the workspace that contains the dialog you want to edit.
- Go to the Dialog tab, and select the node where you want to set an action or state.
- In the response, click the Advanced response icon (⋮), and select Open JSON editor.
Within the JSON editor, you can define actions on the output property and states on the context property as described in the following sections.
Setting states
To indicate a change of state that remains between conversation turns, Voice Gateway exchanges state variables with the configured Watson Assistant service. These state variables are defined on a dialog node as context variables in JSON format.
For a full list of state variables, see Action tags and state variables in the Voice Gateway API.
For example, the following state variable tells Voice Gateway that starting from this node response, failed call transfers don't end the call but instead force a new conversation turn so a different action can be taken.
{
"context": {
"vgwDisconnectCallOnTransferFailure": "No"
}
}
Voice Gateway assumes that Watson Assistant is stateless and that all state is maintained at Voice Gateway between exchanges with Watson Assistant. This means that for each turn within a single call, the state is passed to Watson Assistant and
received back from Watson Assistant in the context section of the REST messages.