DialogEngine

DialogEngine

The Dialog Engine (or Dialog Manager) is the component that handles the flow logic. It it responsible for executing flows, including executing the actions and flowing to the nodes, redirections etc.

Source:

Example

bp.dialogEngine.processMessage(...)

Methods

(async) endFlow(stateId)

Ends the flow for a specific stateId if there's an active flow, otherwise does nothing.

Source:
Parameters:
Name Type Description
stateId string

[description]

(async) getCurrentPosition(stateId) → {Object}

Get the current flow and node for a specific stateId

Source:
Parameters:
Name Type Description
stateId string
Returns:
Type:
Object

Returns the current flow and node

(async) jumpTo(stateId, flowName, nodeNameopt)

Make the stateId jump to the specified flow and node regardless of if there was already an active flow or not in execution. If there was already an active flow executing, this will override it. Note that by default, the current state will be preserved; if you wish to reset the state as well, set resetState to true. Note that this will not continue processing, i.e. the user must send a message or you should call BotEngine#processMessage manually to continue execution.

Source:
Parameters:
Name Type Attributes Default Description
stateId string

The stateId of the user/channel/group to make jump.

flowName string

The name of the flow, e.g. main.flow.json

nodeName string <optional>
null

The name of the node to jump to. Defaults to the flow's entry point.

options.resetState boolean <optional>
false

Whether or not the state should be reset

Example
// inside a bp.hear (...)
bp.dialogEngine.jumpTo(stateId, 'main.flow.json')
bp.dialogEngine.processMessage(stateId, event) // Continue processing

(async) processMessage(stateId, event) → {Promise.<State>}

Process a new incoming message from the user. This will execute and run the flow until the flow ends or gets paused by user input

Source:
Parameters:
Name Type Description
stateId string

The Id of the state. This is usually unique per user/group/channel, depending on the platform.

event BPIncomingEvent

The incoming event (message)

Returns:
Type:
Promise.<State>

Returns a promise that resolves with the new state when the flow is done processing

(async) registerFunctions(fnMap, overwriteopt) → {Promise.<void>}

Introduce new functions to the Flows that they can call.

Source:
Parameters:
Name Type Attributes Default Description
fnMap Object
overwrite bool <optional>
false

Whether or not it should overwrite existing functions with the same name. Note that if overwrite is false, an error will be thrown on conflict.

Returns:
Type:
Promise.<void>