The flow service helps you to control flows, such as allowing you to trigger one flow from within another, or repeating actions within the same flow.

Learn how to properly design complex workflows using subflows here.
Want to see a step-by-step guide to using labels to repeat a question? Try our goto a label tutorial.
Building a navigation or menu system for your bot? See our article on our Menu feature.

Controlling the workflow with Subflows

Trigger a Flow (action)

Launch one flow from within another.

The "Trigger a Flow" action is a very powerful tool to help you organize, simplify and consolidate the logic of your bot into components that accomplish a single task. It is much easier to build and maintain a complex bot that is composed of self-contained pieces than when you try to cram all your logic into a single workflow.  Please see a tutorial on designing and building your bots using subflows here.

To trigger one flow from another, add a new action to your Flow:

Then configure which flow you want to trigger, and how the current flow should behave afterwards.

Selecting the flow you want to trigger

There are two main ways you can choose the flow that should be triggered, which you can control with the Trigger Type configuration option.

1. Choose a Specific Flow. You simply pick the exact flow that should be run from a picklist. This is the simplest method, and it is also the default. If you want to trigger the same subflow every time your flow runs, you should use this method.
2. Match by Keyword. You provide a 'Word or Phrase' that will trigger any matching flow that has that exact word or phrase configured in its New Message trigger, or its New Trigger trigger configuration. This is a more advanced method, and is necessary when you might want to trigger one of several options based on the state of your current flow. For example, imagine you have 5 categories of products, and the user has chosen the category they are interested in. Each category has a different flow that controls how the conversation should be managed for that category. You can trigger the correct flow using Match by Keyword and insert the 'Category' variable as the Word or Phrase into your Trigger a Flow step, which will then trigger the correct flow for each user based on their selection. See our article on dynamically triggering flows for more information on how to use this feature.

Passing Metadata

A common pattern when using subflows is to consolidate some common logic, such as interacting with an external service or onboarding a user who hasn't yet registered with your bot, and then re-use that logic in several other flows. This pattern will often require certain data be passed to the subflow, such as a record ID, or maybe an email address you have collected. You can pass that data by adding Metadata. Metadata is just a set of named variables that you configure using the "+ Add" button in the metadata section. Any variables you add here will be passed to the triggered flow and available the Metadata of its trigger.

Wait Behavior

When you trigger a subflow, either one of two things can happen:

* Wait  - The current flow will pause, waiting for the triggered flow to complete. If the triggered flow runs successfully, the output of the Trigger a Flow task will be the output of the last step in the triggered flow, allowing you to use the results in the remainder of your current flow. If the triggered flow fails, the current flow will also fail. This options treats the subflow as just a continuation, or branch, of the current flow.
* Continue - The current flow will immediately continue to the next step. The triggered flow will run at the same time. Use this option if the subflow is doing some additional work that is not interacting with the user, OR if you are handing control completely to the new flow and the current flow will no longer be interacting with the user because the new flow will be taking control.

Specifying the Response Path

Advanced: If you want to trigger a flow for another user than the current user interacting with the bot, OR you want to trigger a flow for a user from a non-interactive flow, like a webhook flow, you can specify the response path of the user that the flow should be triggered for. Combined with the "wait" trigger behavior, you could use this feature to design "approval" flows where a different chat user is required to provide some input before the current user continues with the conversation.

New Trigger (trigger)

This will trigger when a Trigger a Flow action is run with a matching word/phrase. If more than one trigger is found with the word/phrase, then they will all trigger.

Metadata may have been passed across, and if so, will be available as a data output. If a bot response path was selected in the action, a set of bot related outputs will be available to your flow too.

See dynamically triggering flows for more information on how to use this feature.

Controlling the Workflow with Labels

Want to see a step-by-step guide to using labels to repeat a question? Try our goto a label tutorial.

Goto a Label

The Label and Goto a Label actions allow you to set a position in the flow (using Label), and then move the flow back/forward to that action (using Goto a Label).

After using Goto a Label, your next action will have available any metadata sent along with the action itself (as an output of Label), and the outputs of the trigger and any actions prior to it in the flow.

Label (action)

This action is simply a placeholder/marker to define a position within a flow, so that you're able to go back (or forward) to it using the Goto a Label action. Assign a word or phrase that will be used to reference it with Goto a Label.

Metadata may have been passed across, and if so, will be available as a data output. Note that it's not possible to add filters to this action, as they wouldn't be useful.

Goto a Label (action)

Using this action will cause the flow to go to the first matching Label action found. You can pass information into the Label action using the Metadata field, which will then be available as an output.

It's important to understand how going back and forward in flows affects the outputs you have to work with:

  • If you go back, the action that runs after the label will have all the same output data available to it as when it was first ran, and every time thereafter, in addition to the latest metadata you send using Goto a Label. If you need to use any info you collected further along in the flow, you should send it as metadata.
  • If you go forward, the action that runs after the label will have all the output data you collected up until Goto a Label, in addition to metadata sent along with it, but the outputs of any actions that were skipped will be empty.

As a precaution against infinite loops, the Goto a Label action may be used 20 times (in total) during the course of a flow.

Controlling the Workflow with Menus

Flow XO includes an entire feature for building navigation menus for your bot that work alongside your flows. See our article on our Menu feature.

That's it! Please reach out to support@flowxo.com if you have any questions or feedback.

Happy flowing!

Still need help? Contact Us Contact Us