Multicontext Flows
Last updated
Last updated
"Multicontext Flows" allow to use the same flows for several contexts. Each content has its own flow variable values and its own accounts. Through the multicontex flows you can activate the same flow for different partners, clients or users, and specify their own account. It’s a simple way to use the same integration for different entities under the control of a single account.
It’s easier to explain the "Multicontext Flow" by exemplifying a scenario in which we need to execute the same flow for two different accounts. You can imagine that an integration runs periodically and updates the database of a certain customer. Now think that another client would like to use the same integration, but we need to save the information in the database of this other customer.
Using "Multicontext Flow" we can use the same flow to execute the function for both companies. Of course, we will need to indicate to the flow:
Context: In this case, we have a context for each cliente.
Context Key: It’s the variable that allows to identify the context. It can be a client identifier information. With this key we can identify all variables and accounts in the context.
Context Variable: We can create flow variables that are configured by context. In other words, the values of these flow variables are specified for each client individually.
Context Accounts: We can create access accounts (Database, REST API , etc) for each context. In this way, the flow will use the specific accounts of a client when running in that client’s context.
A "Multicontext Flow" has at least one "Context Finder". During the execution of the flow we call the "Context Finder" by passing a context identification key. The "Context Finder" has the goal of locating the context from the provided key. Once found, "Context Finder" returns all parameter and account values specific to that context. Subsequent modules can use the context-specific variables and accounts.
Building a multicontext flow must follow exactly the same steps as a conventional flow. Once tested, the conventional flow can be converted into a multicontext flow.
Build your flow in the conventional way using the flow variables and accounts as if this flow were to serve only one context.
The Context Finder receives a key to find the context. The context contains the set of flow variables and connected accounts that should be used when executing the flow.
Typically the "Context Finder" is at the beginning of the flow execution, but it can be located at any position within the flow. It must however be located before the modules that use the context dependent flow variables and connected accounts.
The "Context Finder" module requires the operator to supply only the key that will be used to find the context. Specify the variable that will be used as the key in the Parameter field.
You must define which variables change according to the context.
To indicate that a flow variable is also a context variable, simply edit the variable in Contexts → Variables → Add variables.
Observe that all flow variables created in Context are moved to a new tab exclusively for this type of variable, if you view it in Settings .
You need to specify the variables that change according to the context. All the accounts of the modules that are executed after the Context Finder can be specified.
Make sure you have inserted "Context Finder" in your flow, or you won’t be able to specify context dependent accounts.
Revisit the flow you created and open the configuration for modules that require connected accounts, such as Database or REST API modules that need context specific accounts.
Observe that these modules now allow you to specify an account associated with a context. Select the option to use context account.
Once you have made your selection, the Configure context connected account option will appear on the screen:
Note that at this point you can create other context accounts, but we'll do that later in this process. You can click "Next" to proceed to the module's test page.
Take note that you can now select the context account to run the test on. Since we have not configured any context so far, only the Default account is available.
Access accounts are still set up the same way. You must set up one account for each context. These accounts will later be referenced when editing the context.
There's a specific area for configuring contexts. Each context corresponds to a different entity that has its specific accounts and variables. For example, each context might correspond to a different client with its database access accounts and specific flow variables. In this step, you must create the contexts and define a key that allows you to identify each context, such as a customer identifier.
Select the "Context" option in the main flow editing screen.
In Context edit mode you can create, edit and remove contexts. The first time you log in, only the default context (Default) is available. You can click "Add context" to enter a new context.
When creating a new context you can define a name and a key for your context. The name is just a reference for the operator to locate the context. The key is the information that will be used to locate this context. It works as an indexer and must be unique for that flow.
When you save this context, you will see it in the list of available contexts.
In this step you set up the flow variables and accounts for each context.
Click on the editing pencil for the context you want to edit.
Notice that you will now be able to edit the connected variables and accounts of the selected context. All flow variables that were converted to Context Parameter for context variables in STEP 02 will automatically appear so that you can setup their values.
In the same way, Connected Accounts can also be defined in this step. Click "Connected Accounts".
You can define which account will be used for each of the components that require context-connected accounts. You will have to execute this function for each of the contexts you create.
Execute the flow in the same way that you run a conventional flow. Just make sure the key information is correctly provided to "Context Finder".
The logs of the multicontext flows have additional information about the context and the values obtained in each execution.
It's also important to make sure that the context key information is already available so that it can be passed to "Context Finder". Usually this key comes from a or an API call from the API Gateway, but it can come from any module, including a flow variable.