https://discord.gg/botpress logo
Using bp.dialog.jumpTo in Hooks to Interrupt Auton...
# šŸ¤help
g
Context: My webapp sends custom events to Botpress, which I catch with an Advanced Trigger. I’m using an Autonomous Node as my ā€œrouter,ā€ but when the event arrives the node doesn’t break out - so the new flow never starts. Workaround so far: In an
after_incoming_middleware hook
I set
event.state.user.showPaymentFlag = true
(when the specific event is recieved) and in my Autonomous Node’s prompt I check that flag and call it to go to the transition tool if the flag is true. if it’s true. That forces the transition, but there’s still a ~3–4Ā s latency. (which is okay but not ideal) Main question: I’ve seen examples using
await bp.dialog.jumpTo(sessionId, event, 'main.flow.json', 'node_to_jump_to')
inside a hook to interrupt immediately. Is calling bp.dialog.jumpTo from an incoming hook still officially supported? Can it reliably interrupt an Autonomous Node mid‑execution, given Autonomous Nodes behave differently from standard flow nodes? Any caveats or best practices when jumping to nodes from hooks? Thanks in advance for any insights!
p
Hi Philip, did you find a good solution for this? I'm in a similar situation where I have an Autonomous Node which is chatting with the user, but I want to attach other nodes to triggers for custom events. At the moment the other nodes aren't used; the autonomou node just tries (and fails) to deal with the event even though it isn't connected to the trigger at all. Thanks in advance if you have any tips! Alex
g
Hi mate, so you cant use bp. because it requires you to import the botpress library which we cant do because we cant import any librares into botpress using the studio, apparently you can do this if you build bots using the cli (terminal). If i were you id use a before/after incoming hook to catch the event, use that to set a flag, and in your autonomous node tell it if this flag is ever true, go to the transition tool immediately and that should work
make sure to set the flag back to false afterwards
p
Thanks