botpress / v12

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

Make user state available in outgoing middleware #1652

Closed coatesap closed 1 year ago

coatesap commented 2 years ago

Is your feature request related to a problem? Please describe. A common use of outgoing middleware is to filter a series of options/choices presented to a user, based on some previously-collected attribute of the user. Currently the outgoing middleware doesn't have any convenient access to the user state, which makes this difficult.

Describe the solution you'd like One solution might be to provide access to state via sdk.IO.OutgoingEvent, in a similar fashion to how the incoming middleware has access via sdk.IO.IncomingEvent.state.user.

Describe alternatives you've considered A partial workaround was suggested in botpress/v12#1582 that involved potentially multiple database queries to derive the user state from the outgoing event. However, this feels very awkward, and potentially slow from a performance perspective.

davidvitora commented 1 year ago

Not planned, you can use the KVS to store the desired data and get it on the hook