Skip to main content

$jsapi.getStates

The method returns the script structure: detailed information about each state and theme.

Syntax

The method is called without arguments.

$jsapi.getStates();

Return value

The method returns an object.

Each field is a full path to a state or theme. The value is an object with detailed information about this state or theme.

{
"/": {},
"/Start": {},
"/Start/Hello": {
"path": {},
"loadOrder": 3,
"noContext": false,
"modal": false,
"reactions": [],
"tags": [],
"tag": {},
"name": "Hello",
"locator": {}
},
"/NoMatch": {}
}

Here:

  • path is an object with information about the path to the state or theme.

  • loadOrder is the sequence number of the state or theme in the script.

  • noContext is the value of the noContext parameter.

  • modal is the value of the modal parameter.

  • reactions is an array with parameters and properties of the reaction tags that are nested in the state.

  • tags is an array with the names of the tags that are nested in the state.

  • tag is an object that incudes parameters and properties:

    • Of the state or theme.
    • Of all the tags that are nested in the state.
  • name is the name of the state or theme.

  • locator is an object with information about where the state or theme is declared in the file.

Example

A script:

theme: /

state: Start
q!: $regex</start>
a: Let’s start.
script:
log($jsapi.getStates())

state: NoMatch
event!: noMatch
a: I do not understand. You said: {{$request.query}}

For this script, the $jsapi.getStates() method will return an object:

Script structure
{
// Information about the “/” theme
"/": {
"path": {
"parents": [],
"components": [
""
],
"name": "",
"parent": "/",
"outOfRoot": false
},
"loadOrder": 0,
"noContext": false,
"modal": false,
"reactions": [],
"tags": [],
"tag": {
"nameLocator": {
"filename": "fake",
"line": -1,
"col": -1,
"storageType": "RUNTIME"
},
"commentsValues": []
},
"name": "",
"locator": {
"filename": "fake",
"line": -1,
"col": -1,
"storageType": "RUNTIME"
}
},
// Information about the “/Start” state
"/Start": {
"path": {
"parents": [
"/"
],
"components": [
"",
"Start"
],
"name": "Start",
"parent": "/",
"outOfRoot": false
},
"loadOrder": 2,
"noContext": false,
"modal": false,
// Reaction tag parameters and properties
"reactions": [
{
"name": "answer",
"parameters": {
"value": "Let’s start."
},
"tag": {
"td": {
"name": "a",
"hasColon": true,
"mainValueType": "MultilineString",
"innerDataType": "MultilineData",
"parameters": [
{
"name": "lang",
"type": "String",
"required": false
},
{
"name": "ttsEnabled",
"type": "Boolean",
"required": false
},
{
"name": "tts",
"type": "String",
"required": false
},
{
"name": "alexaVoiceEnabled",
"type": "Boolean",
"required": false
},
{
"name": "alexaVoice",
"type": "String",
"required": false
},
{
"name": "htmlEnabled",
"type": "Boolean",
"required": false
},
{
"name": "html",
"type": "String",
"required": false
}
],
"tagString": "a:"
},
"name": "a",
"value": "Let’s start.",
"valueLocator": {
"filename": "src/main.sc",
"line": 5,
"col": 12,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 5,
"col": 9,
"storageType": "RUNTIME"
},
"commentsValues": []
},
"value": "Let’s start.",
"locator": {
"filename": "src/main.sc",
"line": 5,
"col": 9,
"storageType": "RUNTIME"
}
},
{
"script": {
"id": "src/main_sc_6_9",
"body": "log($jsapi.getStates())",
"locator": {
"filename": "src/main.sc",
"line": 7,
"col": 13,
"storageType": "RUNTIME"
}
},
"locator": {
"filename": "src/main.sc",
"line": 6,
"col": 9,
"storageType": "RUNTIME"
},
"name": "script"
}
],
"tags": [
"q!",
"a",
"script"
],
// Parameters and properties of the “/Start” state and of all nested tags
"tag": {
"td": {
"name": "state",
"hasColon": true,
"mainValueType": "String",
"innerDataType": "Tags",
"parameters": [
{
"name": "noContext",
"type": "Boolean",
"required": false
},
{
"name": "modal",
"type": "Boolean",
"required": false
},
{
"name": "sessionResult",
"type": "String",
"required": false
},
{
"name": "sessionResultColor",
"type": "String",
"required": false
}
],
"tagString": "state:"
},
"name": "state",
"value": "Start",
// Nested tags
"inner": [
{
"td": {
"name": "q!",
"hasColon": true,
"mainValueType": "MultilineString",
"innerDataType": "MultilineData",
"parameters": [],
"tagString": "q!:"
},
"name": "q!",
"value": "$regex</start>",
"parameters": {
"fromState": {
"name": "fromState",
"value": "/"
},
"toState": {
"name": "toState",
"value": "."
}
},
"valueLocator": {
"filename": "src/main.sc",
"line": 4,
"col": 13,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 4,
"col": 9,
"storageType": "RUNTIME"
},
"commentsValues": []
},
{
"td": {
"name": "a",
"hasColon": true,
"mainValueType": "MultilineString",
"innerDataType": "MultilineData",
"parameters": [
{
"name": "lang",
"type": "String",
"required": false
},
{
"name": "ttsEnabled",
"type": "Boolean",
"required": false
},
{
"name": "tts",
"type": "String",
"required": false
},
{
"name": "alexaVoiceEnabled",
"type": "Boolean",
"required": false
},
{
"name": "alexaVoice",
"type": "String",
"required": false
},
{
"name": "htmlEnabled",
"type": "Boolean",
"required": false
},
{
"name": "html",
"type": "String",
"required": false
}
],
"tagString": "a:"
},
"name": "a",
"value": "Let’s start.",
"valueLocator": {
"filename": "src/main.sc",
"line": 5,
"col": 12,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 5,
"col": 9,
"storageType": "RUNTIME"
},
"commentsValues": []
},
{
"td": {
"name": "script",
"hasColon": true,
"mainValueType": "MultilineString",
"innerDataType": "MultilineData",
"parameters": [],
"tagString": "script:"
},
"name": "script",
"value": "log($jsapi.getStates())",
"valueLocator": {
"filename": "src/main.sc",
"line": 7,
"col": 13,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 6,
"col": 9,
"storageType": "RUNTIME"
},
"commentsValues": []
}
],
"valueLocator": {
"filename": "src/main.sc",
"line": 3,
"col": 12,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 3,
"col": 5,
"storageType": "RUNTIME"
},
"commentsValues": []
},
"name": "Start",
"locator": {
"filename": "src/main.sc",
"line": 3,
"col": 5,
"storageType": "RUNTIME"
}
},
// Information about the “/NoMatch” state
"/NoMatch": {
"path": {
"parents": [
"/"
],
"components": [
"",
"NoMatch"
],
"name": "NoMatch",
"parent": "/",
"outOfRoot": false
},
"loadOrder": 3,
"noContext": false,
"modal": false,
// Reaction tag parameters and properties
"reactions": [
{
"name": "answer",
"parameters": {
"value": "I do not understand. You said: {{$request.query}}"
},
"tag": {
"td": {
"name": "a",
"hasColon": true,
"mainValueType": "MultilineString",
"innerDataType": "MultilineData",
"parameters": [
{
"name": "lang",
"type": "String",
"required": false
},
{
"name": "ttsEnabled",
"type": "Boolean",
"required": false
},
{
"name": "tts",
"type": "String",
"required": false
},
{
"name": "alexaVoiceEnabled",
"type": "Boolean",
"required": false
},
{
"name": "alexaVoice",
"type": "String",
"required": false
},
{
"name": "htmlEnabled",
"type": "Boolean",
"required": false
},
{
"name": "html",
"type": "String",
"required": false
}
],
"tagString": "a:"
},
"name": "a",
"value": "I do not understand. You said: {{$request.query}}",
"valueLocator": {
"filename": "src/main.sc",
"line": 11,
"col": 12,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 11,
"col": 9,
"storageType": "RUNTIME"
},
"commentsValues": []
},
"value": "I do not understand. You said: {{$request.query}}",
"locator": {
"filename": "src/main.sc",
"line": 11,
"col": 9,
"storageType": "RUNTIME"
}
}
],
"tags": [
"event!",
"a"
],
// Parameters and properties of the “/NoMatch” state and of all nested tags
"tag": {
"td": {
"name": "state",
"hasColon": true,
"mainValueType": "String",
"innerDataType": "Tags",
"parameters": [
{
"name": "noContext",
"type": "Boolean",
"required": false
},
{
"name": "modal",
"type": "Boolean",
"required": false
},
{
"name": "sessionResult",
"type": "String",
"required": false
},
{
"name": "sessionResultColor",
"type": "String",
"required": false
}
],
"tagString": "state:"
},
"name": "state",
"value": "NoMatch",
// Nested tags
"inner": [
{
"td": {
"name": "event!",
"hasColon": true,
"mainValueType": "String",
"innerDataType": "None",
"parameters": [],
"tagString": "event!:"
},
"name": "event!",
"value": "noMatch",
"parameters": {
"fromState": {
"name": "fromState",
"value": "/"
},
"toState": {
"name": "toState",
"value": "."
}
},
"valueLocator": {
"filename": "src/main.sc",
"line": 10,
"col": 17,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 10,
"col": 9,
"storageType": "RUNTIME"
},
"commentsValues": []
},
{
"td": {
"name": "a",
"hasColon": true,
"mainValueType": "MultilineString",
"innerDataType": "MultilineData",
"parameters": [
{
"name": "lang",
"type": "String",
"required": false
},
{
"name": "ttsEnabled",
"type": "Boolean",
"required": false
},
{
"name": "tts",
"type": "String",
"required": false
},
{
"name": "alexaVoiceEnabled",
"type": "Boolean",
"required": false
},
{
"name": "alexaVoice",
"type": "String",
"required": false
},
{
"name": "htmlEnabled",
"type": "Boolean",
"required": false
},
{
"name": "html",
"type": "String",
"required": false
}
],
"tagString": "a:"
},
"name": "a",
"value": "I do not understand. You said: {{$request.query}}",
"valueLocator": {
"filename": "src/main.sc",
"line": 11,
"col": 12,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 11,
"col": 9,
"storageType": "RUNTIME"
},
"commentsValues": []
}
],
"valueLocator": {
"filename": "src/main.sc",
"line": 9,
"col": 12,
"storageType": "RUNTIME"
},
"nameLocator": {
"filename": "src/main.sc",
"line": 9,
"col": 5,
"storageType": "RUNTIME"
},
"commentsValues": []
},
"name": "NoMatch",
"locator": {
"filename": "src/main.sc",
"line": 9,
"col": 5,
"storageType": "RUNTIME"
}
}
}