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

Switching states


A chat bot script is defined in a text file with a tree structure. This means some elements are nested in other ones. These elements are states of the system it can switch to in the course of a conversation. They are called system states. Generic states include more specific states.


Switching to a state

A state is switched in the following cases:

  • The client’s request falls under one of the global tags: q!, e!, eg! or intent!.

Activation rules for patterns, intents and groups of examples in a script are processed for the following objects in descending priority: q!, eg!, intent!.

The conversation can switch to a global tag state from any other state. A local tag is only active in the context of the conversation; you can switch to this state from one of the nearest parent or child states.

  • The client’s request falls under the q tag pattern.
  • From the parent state, if the client’s request falls under a nested state.
  • From any state, if the fromState state is specified for the q tag. This flag defines the state from which a switch based on this pattern is possible.
  • When a go! or go tag is activated.

Processing activation rules

When the system is in a state, rules associated with that state and all its parents are activated. Activation rules associated with that state have the highest priority.

Therefore, identical activation rules can be declared in different states, but they are processed depending on the current state of the system.

Consider the following script:

patterns:
    $Yes = (yes|of course)
    $No = (no|not|no way)

theme: /
    state: Start
        q!: $regexp</start>
        go!: ../morning exercise

    state: morning exercise
        a: Do you do morning exercise?

        state: every day
            q: * $Yes *
            a: Do you do morning exercise every day?

            state:
                q: * $Yes *
                a: Good!

            state:
                q: * $No *
                a: Morning exercise has to become your habit!

        state:
            q: * $No *
            a: Morning exercise helps your body and brain wake up, work on yourself!

This script shows how a client’s yes/no answers are processed depending on the active state.

Let us have a look at how this script is processed:

  1. The script is started, go! redirect the client to the morning exercise state.
  2. The bot asks Do you do morning exercise? from the morning exercise state.
  3. The system will then remain the current state where the patterns are active: q: * $Yes *, q: * $No *.
  4. The client answers yes and the system switches to the morning exercise/every day state. The bot then asks Do you do morning exercise every day?, and the system activates the next set of patterns.
  5. The system will interpret the next answer of the client in the morning exercise/every day context. Responses activate nested state patterns as they have a higher priority.