botpress / v12

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

[FEATURE] Add a for loop #1613

Open bassamtantawi-botpress opened 2 years ago

bassamtantawi-botpress commented 2 years ago

Is your feature request related to a problem? Please describe. I got many questions from an API and want to loop into them and make the bot ask them in sequence?

Describe the solution you'd like (https://success.outsystems.com/Documentation/11/Developing_an_Application/Implement_Application_Logic/Use_a_For_Each_to_Iterate_a_List)

Describe alternatives you've considered Built it manual

laurentlp commented 2 years ago

Hey @bassamtantawi-botpress, not sure I understand where you would want to add a for loop? In a hook or action? Or maybe the flow-editor? If it's the latter, can you please add details mentioning that it targets the flow-editor.

ptrckbp commented 2 years ago

@laurentlp I think he meant the flow editor. We can use for loops in actions and hooks already. There's a comment in one of our videos asking about this too https://www.youtube.com/watch?v=IV__Pq-euzs&list=PLlJHGGklthGmFnbXHI6--kgJO3ZyFS9mD&index=6 and I was trying to do this in the past. I think it's just a dev reflex. The flow editor is a visual representation of code, so I would expect it to have for loops as a language feature, just like if we have if / else statements and async / await.

Maybe an flow editor implementation would look something like a skill that does this : Requires name of element (like temp.purchaseItem) and name of array (like session.shoppingCart.purchaseItems). @enterNode: setCurrentElement (for of or equivalent) @transitions 1) looping 2) done 3) onError

The looping elements would need to loop back to this node.

davidvitora commented 2 years ago

@bassamtantawi-botpress @ptrckbp @laurentlp I added the mentioned flow-utils module to the public solutions repository: https://github.com/botpress/solutions/tree/master/custom%20modules/flow-utils

damiendidi commented 2 years ago

Hey, thank you so much for the infos and the explanations.