Transtition to different node through custom action code

I have a use case, where I want to transition to different node from custom action code itself, that target node could be in same subflow as well as it could also be in different subflows also, I would know if that target node is in different subflow. How could I acheive it through code of custom action in botpress, Please help…

Hey Zakarian, let’s wait for somebody from Botpress to answer properly, but I don’t think that’s possible right now. What I do is set a boolean variable, and below the Code card, I add a transition that checks the value of the variable.

For example:

try {
 if (condition === true) {
  workflow.should_transition = true
 }
} catch {}

And in the transition’s condition you add:

shoud_transition === true

That way you can transition between nodes. I know it’s a bit cumbersome to have to create condition variables for each transition, but it’s the workaround while Botpress doesn’t add the feature you mentioned.

Cheers :wink:

1 Like

Thanks @devguilherm for your reply,
Actually I’m doing some computation inside action, which will take time, not sure how much, so if I follow your solution, then after starting my custom action code, botpress will do transition and at that time will check ‘should_transition’ variable, and after that if my previously running code gets completed and updates ‘should_transition’ variable value to true, would botpress than again check for condition and do transition to other node?
Could I do something like make botpress first run my custom action code after this code is completed only, then do transition to another node(check condition at that time).

If I understand you correctly. Add them into two different code blocks