Manage the listener to take the name of a link flow

Hello Community! I would like to retrieve on a Global Post-Listener the name of the last stream that was triggered in the current bot interaction, how can I do this? In my example I am using a flow link and I need the name of the flow that is called via the flow link and not the name of the starting flow.



The Global Post-Listener is not the correct place to retrieve all flows that are triggered in the current interaction, because this listener is in fact Post-matching listener, which is executed directly following by a trigger/transition condition is matched. To get all flows in the current interaction, you need to add the following code in Globals > Scripts > On top:

def flow = _.getTopFlow()
if(!lTriggeredFlows.contains( lTriggeredFlows <<

To run the code above you also need to define a global List variable called lTriggeredFlows. This variable will store all flows that are raised in the current transaction. Each flow will only be recorded once, for example, the currect transaction starts from Main flow 1, then links to Sub flow 1, then back to Main flow 1, and finally links to Main flow 2, the value of lTriggeredFlows will be [Main flow 1, Sub flow 1, Main flow 2]. You can use lTriggeredFlows[-1] to retrieve the last flow.

Finally, the variable lTriggeredFlows should be reset in the beginning of each transaction, so remember to put this line:

lTriggeredFlows = []

in Globals > Scripts > Pre-processing

Hope this can help,