Skip to content

Commit

Permalink
Merge pull request #2842 from botpress/ya-fix-dialog
Browse files Browse the repository at this point in the history
fix(core): user is stuck when a transition is missing
  • Loading branch information
allardy committed Jan 21, 2020
2 parents 2f05161 + 9159657 commit 0a98133
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/bp/core/services/dialog/dialog-engine.ts
Expand Up @@ -58,8 +58,7 @@ export class DialogEngine {
// End session if there are no more instructions in the queue
if (!instruction) {
this._debug(event.botId, event.target, 'ending flow')
event.state.context = {}
event.state.temp = {}
this._endFlow(event)
return event
}

Expand All @@ -77,7 +76,8 @@ export class DialogEngine {
} else if (result.followUpAction === 'transition') {
const destination = result.options!.transitionTo!
if (!destination || !destination.length) {
this._debug(event.botId, event.target, 'ending flow, because no transition destination defined? (red port)')
this._debug(event.botId, event.target, 'ending flow, because no transition destination defined (red port)')
this._endFlow(event)
return event
}
// We reset the queue when we transition to another node.
Expand Down Expand Up @@ -189,6 +189,11 @@ export class DialogEngine {
return this.processEvent(sessionId, event)
}

private _endFlow(event: IO.IncomingEvent) {
event.state.context = {}
event.state.temp = {}
}

private initializeContext(event) {
const defaultFlow = this._findFlow(event.botId, 'main.flow.json')
const startNode = this._findNode(event.botId, defaultFlow, defaultFlow.startNode)
Expand Down

0 comments on commit 0a98133

Please sign in to comment.