Triggering flows Dynamically

A frequently used pattern in Flow XO is to organize your conversations into multiple flows. This approach can simplify your life tremendously by letting your group related logic into individual flows and then delegating to those flows based on how users answer certain questions, eliminating the need for complicated filters in each step of your flow, which tends to happen when you try to cram a complex conversational workflow into a single flow. Usually, when triggering one flow from another, you will directly specify the flow you intend to trigger from a list of your active flows. However, sometimes it makes more sense to trigger your subflow dynamically, using a keyword or phrase, and this article shows how to do that.

TLDR: If you prefer to jump right into a sample, please see these three flows which demonstrate the concepts taught in this article:

1. Main Menu Flow - this flow will present a menu and trigger other flows depending on the users selection

2. New Trigger Flow - this flow can only be triggered manually by another flow, and is will run when the first menu item is chosen from the previous sample

3. New Message Flow - this flow can be triggered by another flow OR by messages sent by the user

If you prefer to learn visually through a video, this video demonstrates building the samples presented below step by step



Alright - with that out of the way, lets get started!

When triggering additional flows in Flow XO, your main tool is the "Trigger a Flow" action:

To trigger a flow dynamically, choose "Match by Keyword" as the trigger type, and enter the word or phrase that you want to use in the Word or Phrase configuration.

When this action is executed, it will cause any flow that either has a New Message trigger configured to respond to the phrase (in the example above it would be "thing one") or that has a New Trigger trigger configured to exactly match that same phrase. You can find the New Trigger trigger type in the trigger menu when creating a new flow:

Here is an illustration that shows the relationship between the New Trigger action and the New Message Trigger or New Trigger trigger:

In the example above, we used a specific phrase, "thing one" in our Trigger a Flow step. But usually you will want to use a dynamic trigger based on the answer to a previous question, and trigger different flows depending on what your user selected. This is also very easy to do. Lets suppose you have a simple menu, implemented as "Ask a Question", that looks like this:

This will present the question text to your user with two buttons, one labeled "Do Thing 1" and the other labeled "Do Thing 2". When the user clicks "Do Thing 1" you want one flow to run, but when they click "Do Thing 2" you want a different flow to run. You would adjust your "Trigger a Flow" step to use the output of this question like so:

After creating the menu step, you will then create two new flows. One you can call "Triggered Thing One" and the other you can call "Triggered Thing Two". The first flow will demonstrate linking to a New Trigger, and the other will demonstrate linking to a New Message trigger.

Here is what the trigger configuration should look like for "Triggered Thing One":

And here's the configuration for the trigger in "Triggered Thing Two":

And that is really all there is to it. Pretty easy, and very flexible! As a bonus, you can use these concepts to return your user to the main menu when they have finished going through any specific flow. All you need to do is add a "Trigger a Flow" step to the end of each subflow and use whatever keyword triggers your main menu:

If you want to jump right in and start playing with these ideas, you can install the three sample flows linked below:

1. Main Menu Flow - this flow will present a menu and trigger other flows depending on the users selection

2. New Trigger Flow - this flow can only be triggered manually by another flow, and is will run when the first menu item is chosen from the previous sample

3. New Message Flow - this flow can be triggered by another flow OR by messages sent by the user

You can also review this video, which walks through building out this example from scratch, including linking the user back to the main menu:

And that's it! Please let us know at support@flowxo.com if you have any questions or comments regarding this or any other aspect of Flow XO. Happy flowing!

Still need help? Contact Us Contact Us