Sending inputs to a flow

We can pass data to a flow as it is being initialized; giving us the flexibility to launch predefined tasks (for example, search for a specific record, and load the details) as soon as a flow starts.

This input data is accessible through a query string when the flow starts. This is what a Flow Run URL would look like: https://flow.manywho.com/<tenant-id>/play/player?flow-id=<flow-id>&flow-version-id=<flow-version-id>&example-data1=123&example-data2=abc

The first thing we need to do for this, is create a new player. We will customize the player code next.

Open the new player. (We are calling the player Input.)

We will capture the data sent as a query string, on line 126 after manywho.settings.initialize add the following code:

1

2

3

4

varexampleData1=queryParameters['example-data1'];

varexampleData2=queryParameters['example-data2'];

// Change example-data1 to the property name in your query string

// Change example-data2 to the property name in your query string

For the Flow engine to recognize this as valid inputs, we need to create an inputs array. Let’s add this code to the player now:

1

2

3

4

5

6

varinputs=[

{"example-data1":exampleData1},

{"example-data2":exampleData2},

];

varexampleInputs=manywho.json.generateFlowInputs(inputs);

//Using a helper function to send an array of objects containing the property name/value

Let’s find the options object inside the initialize function. To send the input data into the flow, it has to be available as an option when the flow is being initialized. We will change inputs: null, line.
Replace null with the variable containing the input description, something like: inputs: exampleInputs,

Lastly, we will create a value for each of the inputs being set. The names of the values will match the property names of the input data we sent to the flow. (In this example, we would create a value called example-data1 and another one called example-data2). Be sure to select Input or Input/Output as the option for Access when creating the value.

When we run our flow, it will automatically populate these values with the data upon initialization.