DialogStateManager

DialogStateManager

The Dialog State Manager is in charge of keeping track of the state for all conversations. This is being used internally by the Dialog Engine but is also exposed publicly if you need to programmatically alter the state of some conversations.

Source:

Example

bp.dialogEngine.stateManager

Methods

(async, static) deleteState(stateId, substatesopt)

Deletes the state(s) and (optionally) the associated sub-states (for e.g. ___context sub-state)

Source:
Parameters:
Name Type Attributes Description
stateId

The state to delete

substates Array.<String> <optional>

Detaults to ['context']. If this is empty it will delete no substate

(async, static) getState(stateId) → {Object}

Returns the current state of the conversation

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

The conversation state

Example
const state = await bp.dialogEngine.stateManager.getState(event.user.id)

(async, static) setState(stateId, state) → {Object}

Overwrites the state of a current conversation

Source:
Parameters:
Name Type Description
stateId String
state Object

The conversation state

Returns:
Type:
Object

The new state