Skip to content

Navigation

Whilst setting up a Cloud Function element in a flow, a Continue To target has to be specified. This is so as to ensure the user is not left hanging at the end of the execution of the cloud function.

However, there might be cases wherein you might want to override the navigation target you have specified in the UI. This is where you can use the Navigation element.

Navigation is a top level class that will trigger navigation to another flow and/or flow element in your bot.

import { Navigation } from "@stackchat/dynamic-content-toolkit";

const navigation = new Navigation();
navigation.continueTo = "Flow One:*";

return [ navigation ];

The continueTo property accepts a flow and/or a flow element in the following syntax:

<Flow>:<Flow Element>
/**
 * For demonstration purpose, let us assume we have a bot
 * with flows as `Flow One`, `Flow Two` and `Flow Three`. Further
 * more, let us assume each of the above flows have three elements
 * therein named as `Element One`, `Element Two` and `Element Three`.
 *
 * The structure would be as follows:
 * {
 *      'Flow One': [ `Element One`, `Element Two`, `Element Three ~ default` ],
 *      'Flow Two': [ `Element One`, `Element Two ~ default`, `Element Three` ],
 *      'Flow Three': [ `Element One ~ default`, `Element Two`, `Element Three` ]
 * }
 *
 * We are assuming that `Element 2` inside `Flow 2` is the element
 * that triggered our cloud function execution.
 *
 * On the above basis, the following are valid `continueTo` values:
 */
const possibleValues = [
  "Flow One:*", // Continue to the default element of `Flow One`, i.e `Element Three`,
  "_:*", // Continue to the default element of the current flow i.e. `Flow Two, Element Two`,
  "_:Element Three", // Continue to the `Element Three` of current flow, i.e. `Flow Two`,
    "Flow One:Element Three", // Continue to `Element Three` in `Flow One`
];