botpress / v12

Botpress OSS – v12
https://v12.botpress.com
GNU Affero General Public License v3.0
78 stars 87 forks source link

[BUG] before_session_timeout hooks not being invoked #1597

Closed hacheybj closed 2 years ago

hacheybj commented 2 years ago

Describe the bug Hooks created in the before_session_timeout event hooks are not being invoked.

To Reproduce Steps to reproduce the behaviour:

  1. Create a before_session_timeout hook
  2. Add a bp.logger.debug or console.log (whatever really just to get confirmation it was invoked or not)
  3. Start a conversation
  4. Let the conversation timeout (setting the configuration to a few seconds rather than the default 30m speeds things up)
  5. Check the DB table dialog_sessions for confirmation the session was cleared (row deleted)
  6. You see no logs confirming the execution of the hook

Expected behaviour For the hook to run before the session is cleared from the DB

Screenshots N/A

Environment (please complete the following information):

Additional context N/A

laurentlp commented 2 years ago

As discussed with @hacheybj, the issue comes from the fact that there are configurations on both the Botpress config and the bot config. The ones on the bot config have precedence over those on the Botpress config.

This means that if you set a sessionTimeoutInterval in your Botpress config lower than the default timeoutInterval (5min) of the bot config, the before_session_timout hook or Timeout flow are never triggered. All this because the session is deleted before it times out.

We should consider displaying a warning to the user when those values conflict. Something like:

[<BOT_ID>] Your timeout interval (source: <bot.config|botpress.config>) is greater than your session timeout (source: <bot.config|botpress.config>). This will prevent 'before_session_timeout' hooks and Timeout flows from being executed.

github-actions[bot] commented 2 years ago

Available on v12.26.13

github-actions[bot] commented 2 years ago

Available on