This site is no longer updated.Go to new Conversational Cloud docs

$context


A structure which represents the current runtime context of the request.

The $context object contains references to all the other built-in variables with the same names, but without the $ prefix:

$context.parseTree = $parseTree
$context.client = $client

Additional fields

  • currentState is the path to the current state where the script is executed.
  • contextPath is the current context path. It can be different from currentState if the noContext flag is used.
  • testContext is the test execution context. This object is defined only in test mode and cannot be modified.

When using CAILA NLU, these fields are also available:

  • intent is the intent activated in the state.
  • entities are entities found in the phrase.
  • nluResults is an array of NLU results.

How to use

  • Clearing the session and client data at the start of the conversation.
state: Welcome
    q!: $regex</start>
    a: Hello! I’m your online assistant.
    script:
        $context.session = {};
        $context.client = {};
    go!: /ChooseCity
  • Saving the path to the last triggered state in the postProcess handler.
init:
    bind("postProcess", function($context) {
        $context.session.lastState = $context.currentState;
    });