"to" property controls

The to property can support an object that:

  • sends data back to the agent

  • uses conditional logic, depending on the values set by the user in the widget’s controls

Send data to an agent

The sendMessage property indicates that a datapass must be returned to the agent. The object defined by sendMessage is sent in the messageData field of the message object that is normally sent to NDEP when the client sends a message.

In addition, if the root of the object contains a displayText key, then the value of this key is sent as messageText and displayed in the transcript.

Tip: Have a value for displayText, because it communicates to the user that the widget interaction was successful, and that information was sent back to the agent.

A sendMessage object typically is:

{
    "displayText": "text",
    "key1": "value1",
    "key2": "value2"
}

Values can be text or references to values entered by the user in controls. References to user-entered values are prefaced by a # symbol, and they follow this pattern:

#nodeID.controlID.property, with the property name varying by widget type.

Conditional logic

The to property can evaluate logical conditions using the guard property. This property accepts either a single object or an array of objects.

In transitions, guard objects contain three properties:

  • condition—The engine executes the condition specified in the guard object. If there are multiple guard objects, the automaton engine executes each condition until a condition becomes true.

  • onTrue—If the condition is true, this is the node ID to which the automaton engine navigates in the widget.

  • onFalse—If the condition is false, this is the node ID to which the automaton engine navigates in the widget.

Conditional logic example

{
    "name": "TransitionOne",
    "from": "view1",
    "trigger": "EventOne",
    "to": {
        "guard": {
            "condition": "(!(is_empty(#view1.customerName.text))) && (#view2.terms.item.0.isChecked == true)",
            "onTrue": "view3"
        }
    }
} {
    "name": "TransitionOne",
    "from": "view1",
    "trigger": "EventOne",
    "to": {
        "guard": [{
                "condition": "(!(is_empty(#view1.customerName.text))) && (#view2.terms.item.0.isChecked == true)",
                "onTrue": "view3"
            }, {
                "condition": "(!(is_empty(#view1.customerName.text))) && (#view2.terms.item.0.isChecked == true)",
                "onTrue": "view3",
                "onFalse": "view4"
            }
        ]
    }
}