这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@davidvitora
Copy link
Contributor

This PR fixes the conversation timeout behavior with the following items:

  • Saves the state and context so if there are any jumps during the timeout flow or timeout hook the conversation can be continued (If there is no jump, only the state will be persisted)

image

  • Allows timeout hook to be executed even if there is no timeout flow (I think this is a bug)

image

  • Adds infinite loop detection for timeout (Easily reproducible when using timeout nodes)

2023-01-19_21-34

image

@vercel
Copy link

vercel bot commented Jan 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
botpress-v12-docs ✅ Ready (Inspect) Visit Preview Jan 20, 2023 at 0:42AM (UTC)

@davidvitora davidvitora requested a review from EFF January 20, 2023 00:42
Copy link
Contributor

@EFF EFF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine from 10000 meters above, I'm not so familiar with dialogue engine, I'd like to get @allardy's eye on it . Plus it might be useful for his current work

// if there is no jump, so we don't want the timeout event to process the previous queue
// The reason to return the event is to persist any changes made to session state or context
// in the session timeout hook
fakeEvent.state.context = { ...session.context, queue: undefined } as IO.DialogContext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so familiar with dialog engine, should queue be an empty array instead of undefined ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be undefined, an empty query will generate an error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the queue is undefined, the dialog engine will use the active flow/node to build the instruction queue


this.fillContextForTransition(event, { currentFlow, currentNode, nextFlow: timeoutFlow, nextNode: timeoutNode })

// Process the event with the new context, return to persist state changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there is no timeoutNode/timeoutFlow ? we don't throw anymore >

Copy link
Contributor Author

@davidvitora davidvitora Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will not throw an error since that, in my opinion, it can't be considered an error to not have a timeout flow/node; instead,

  • if there is no jump (transition), return the event to have its state saved (If we modify the state in the timeout hook for example)
  • if there was a jump in the timeout hook or timeout flow/node, process the event and save the state (including the context, which will make it possible to continue the conversation if desired).

The previous logic created an bug where changes made in the timeout hook to session state would not be saved unless we had a timeout node/flow

@davidvitora davidvitora requested review from EFF and allardy January 23, 2023 19:57
Copy link
Member

@allardy allardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I didn't test it out but the logic make sense

// if there is no jump, so we don't want the timeout event to process the previous queue
// The reason to return the event is to persist any changes made to session state or context
// in the session timeout hook
fakeEvent.state.context = { ...session.context, queue: undefined } as IO.DialogContext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the queue is undefined, the dialog engine will use the active flow/node to build the instruction queue

@davidvitora davidvitora merged commit 21d4bc0 into master Feb 7, 2023
@davidvitora davidvitora deleted the dv_fix_timeout branch February 17, 2023 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants