Skip to content


The flow object provides a mechanism to invoke other flows. This allows some flows to become superflows connecting multiple flows together. Flows from other applications may also be invoke in this fashion.

Shared functionality

You can use the include(...) method to include code from a MODULE typed flow. This is great if you have some code that you want to share between multiple flows.

The code in the module flow can export its functionality by assigning variables to the global exports object. See the example below.


  • name the name or subject of the module to include


We’ll define a handy math module (given the subject = math):

var times = function(a, b) {
  return a*b;

var plus = function(a, b) {
  return a+b;

var bigNumber = 10000;

exports.times = times; = plus; = bigNumber;

and this can then be used in another flow:

var math = Flow.include('math');
var ten = math.times(2, 5);

Run flow

Run another flow with the run(...) method. You provide the input to the flow and will get the outputs of the flow.


  • name the name, subject or id of the flow to run - if there are 0 or more than 1 flow with this name an Error will be thrown
  • environment is a JavaScript object containing the input to the flow. Each property on the object will be mapped to an input. Currently only string values are supported. Inputs are accessed in the running flow with Inputs["<inputname>"] e.g. Inputs["myinput"] or simply <inputname> e.g. myinput (if the <inputname> is a valid JavaScript identifier).
  • session a session selector (see below)
  • options (optional) which can include;
    • allowLaunch (bool) allow Manatee to launch the application, default is true
    • allowVirgin (bool) allow Manatee to run the flow before the state of the application has been synchronised


Since it is possible and valid to have flows in multiple apps with the same name, it can be ambiguous which flow should be chosen by If flows called ExampleFlow exist in apps A and B and a flow on app A runs'ExampleFlow'), manatee will always prefer the matching flow from the same app (A) as the calling flow.

Note that if ExampleFlow exists in apps B and C and a flow in app A calls'ExampleFlow'), you can’t be sure which flow is called. In such cases you can use the subject or id of the flow as the first argument instead - or rename one of the colliding flows.


var result ="MyOtherFlow", { "inputA": "AAA", "inputB": "BBB" });
// "MyOtherFlow" will now get executed, the inputs may be accessed via e.g. Inputs["inputA"] in "MyOtherFlow"
var outputC = result.outputC; // providing "MyOtherFlow" has a defined output called "outputC"

It is possible to chain flows like:

var result ="RunLast","RunFirst", {}));

Run a flow only if the application is already running and connected to Manatee:

var result ="RunThisOnlyIfAppIsRunning", {}, null, { allowLaunch: false }); to run flows in another session

In order to run a flow in another session you need to provide a third argument to This “session selector” argument can either be a function acting as a predicate on the states of the sessions or a an object that contains keys and values to match.

Using a predicate

We’ll assume we have the following sessions currently available.

  • Session 1 with app A (instance 1) has the following state; s1 = v1.
  • Session 2 with app A (instance 2) has the following state; s1 = v2.

If we want to run the flow “foo” in session 2 then we do:

javascript"foo", null, function(state) { return state["s1"] === "v2"; });
Using a key-value match

Using the same sessions described above we can match session 2 again using a the key-value match:

javascript"foo", null, {"s1": "v2"});

The key-value matcher will also create the session if it does not exist - this will not happen using the predicate approach.

Stop the current flow

Use the stop() method to stop a running flow gracefully.