https://discord.gg/botpress logo
Do "Workflow Variables" transfer in the "Exit" nod...
# 🤝help
b
I'm trying to transfer a workflow variable. - from a subworkflow - to the main workflow I've tried puttin the variable (@workflow.KBquestion) in the "Educator's" card (located in the main workflow) but I'm still unable to use it I know it may sound dumb not to use an User variable, but I haven't opened myself to that perspective, as I'm trying to: - get client question - pass the question from the Educator workflow to the KBSearch workflow - get an answer variable - and store both variables (question variable and answer variable) for later usage and I'm trying to use some principles from the "Advanced Bot building tutorial" (

https://www.youtube.com/watch?v=-N4OoKg_w4I▾

- "Routing to other workflows") https://cdn.discordapp.com/attachments/1380248238954778775/1380248239155974294/image_2025-06-05_115947874.png?ex=684c6a57&is=684b18d7&hm=021934037a87c0d33d9cf2178d2084ba774464f6f40af04e1932e95e8240d41a& https://cdn.discordapp.com/attachments/1380248238954778775/1380248239420477553/image_2025-06-05_120052732.png?ex=684c6a58&is=684b18d8&hm=cdeb47565f1dd065e66d3e9c158d5572c725f7bddd03b5541ad54c9ef52ff195&
p
The way to access a subWorkflow variable is workflow.subWorkflow.variableName
b
Thank you
p
No worries!
f
I think about trying a similiar thing like routing from AN (1) to another AN (2) so the main AN (1) executes the "main" workflows like contacting a human, answering questions and the AN (2) is a specific "agent" with specific workflows. For this I need to pass workflow variables from the main workflow to the "subworkflows" like from the AN (1) > Workflow X with AN (2) > workflow Y. Is this a good idea or even possible or should I just put ALL worklows inside one AN and instruct the AN properly how to use the workflows and in what order?
p
Yeah you can pass variables as input to a subworkflow by toggling them on the entry node of the subworkflow. You can take a look at the docs about this here: https://botpress.com/docs/learn/reference/variables/pass-between-workflows#pass-variables-between-workflows However, I'm not sure I understand why you would want to use the two ANs. Feel free to elaborate on that.
f
I thought using 2 ANs would be a little bit better because I can "group" the workflows / tasks and do not "overload" 1 AN. So instead of having 20 workflows inside one AN, create a new AN for specific group of workflows and transition from the 1st AN to the 2nd AN if the user intents to use a workflow inside the 2nd AN. But that also means way more work for passing all the variables through 2 workflows But if its best practise to use only one AN I change it and just instruct the AN on how and when to use the workflows I would have grouped with the 2nd AN. Im also not sure whats the best practise for workflows: - Using many workflows for every simple task like "getting contact details" and "send a http request to my database with the user data" or "search knowledgebase" OR - Using less but more complex workflows and group tasks (= getting contact details + sending to database) inside 1 workflow. My key goal is to have a agent / chatbot as conversational and flexibel as possible and avoiding users getting stuck inside a workflow Hope thats understandable 🙂 Would be great if you could tell me what way its is "right" or better
p
Botpress is a customizable platform that is meant to be tailored to your needs. Thus, all of the above options can be done. That being said I would probably advise against using one AN for everything unless the instructions are extra clear. However, your transition instruction and scenario must also be unambiguous for the multiple AN to transition properly. In terms of the workflows, its entirely up to you! Since the nodes in workflows are usually standard nodes, the cards are ran sequentially which allows you to add as many as you want. The cases where I would recommend using different workflows is if the same set of actions (e.g. sending to database) is done across multiple of your workflows, then having the set of cards in each of the workflows would be redundant and you could instead add the workflow card to a sub-workflow. To avoid getting stuck in a workflow, do not se an AN inside them. Hope this helps, Happy Bot Building!!
2 Views