Skyone
Skyone
English
English
  • Home
  • Data
    • Getting Started
      • Create an account
      • Recover Password
      • Quick Platform Guide
      • How to test the platform for free
      • Workspace
        • Creating a new Workspace
        • Find a Workspace
        • Sending an invitation to a Workspace
        • Editing a Workspace
      • Organizations
        • Creating an Organization
        • Organization Overview
        • Organization Management
        • Organization Monitoring
      • Settings and Preferences
        • Profile
        • Notifications
        • Usage and Billing
        • Users and Permissions
    • Modules
      • Module management
        • Creating a Module
        • Importing a Module
          • IAC Files - Integration as Code
        • Editing a module
        • Module Options
      • Settings and Operations
        • Module settings
          • Connectivity: Database
          • Connectivity: Email
          • Connectivity: REST
          • Connectivity: SOAP
          • Connectivity: File
          • Connectivity: RFC
          • Connected Account Management
        • Operations
          • Importing operations into REST Modules
          • Operation Management
        • Flows Using This Module
    • Monitoring
    • API Gateway
    • Terminals & Agent
      • Agent
        • Versions supported by Agent
        • How to Update the Agent Version
        • How to back up Agent files
      • Terminals
    • Data
      • Data Stack
        • Process Control
        • Data Stack Upload
        • File Actions
        • File Jobs
        • Data Job Parameters
        • Data Store
        • Data Share Features
        • ODBC
        • How to use the Data Engine Proxy
    • Integrations
      • Integration Management
        • Create integration
        • Import Integration
        • Edit Integration
        • Integration Options
        • Flows of this integration
      • Flows
        • Flow management
          • Creating a flow
          • Flow options
          • Flow Canva: configuring and editing the flow
            • Flow Canva: overview
            • Exception Handler
              • Exception Handler - Configuration
              • Exception Handler - Cases
            • Multicontext Flows
              • Example: Multicontext with an API Gateway
              • Example: Multicontext with a Time Trigger
            • Flow Settings
        • Triggers of a flow
          • API Gateway Triggers: Adding and Setting
          • AS2 Triggers: Adding and Setting
          • Queue Triggers: Adding and Setting
          • Flow Triggers: Adding and Setting
          • Time Triggers: Adding and Setting
          • Webhook Triggers: Adding and Setting
        • Tool Modules
          • AS2 Module
          • CSV Module
          • Data Transform Module
          • Data Balancer Module
          • EDI Module
          • Flow Call Module
          • IF Module
          • JavaScript Module
          • Log Module
          • Loop Do While Module
          • Loop For Module
          • Return Module
          • XML Module
          • Other Tool Modules
        • Module Header
        • Connecting components of a flow
        • Editing triggers and modules
        • Data Operations
          • Object Handling
            • Practical example: Handling variables
          • SMOP (Small Operations)
          • Parameterization rules
    • How to
      • Insert JSON into databases
      • Flattening: Data transformation using JSONata
      • How to use Form Data
      • Understanding recursion in JSONata
      • REST Module Output Consolidation
      • Isolated in execution: concept and application in variables
      • URL Parameters in API Gateway
      • Use case: API Gateway trigger parameters
      • Use case: Exception Handler in financial transactions
      • Use case: using Groups to manage access to flows
      • How to create a download endpoint and integrate with Power BI
      • Is it possible to use two triggers in a single flow?
      • How to set up WhatsApp in Skyone Studio
    • FAQ
    • GIGS: The complete guide
    • Glossary
  • Support
    • How do I request support?
    • Case Severity Levels
    • SLAs
    • Help & Resources
Powered by GitBook
On this page
  1. Data
  2. Integrations
  3. Flows
  4. Flow management
  5. Flow Canva: configuring and editing the flow
  6. Multicontext Flows

Example: Multicontext with a Time Trigger

PreviousExample: Multicontext with an API GatewayNextFlow Settings

Last updated 6 months ago

This example illustrates the creation of a multi-context flow from a time trigger. Contexts are internally programmed from a flow variable.


Flow Definition

In this example, we present a scenario of an integration between a Web System that provides weather information and a Postgres database. The weather information is obtained recurrently through a time trigger. At each reading, we also record the relevant information in a database so that it can be accessed later.

The reading of the weather information requires the specification of the locality about which the current data will be provided. In addition, it's necessary to provide an access token for the API to work correctly.

At first, we will do a single-context (conventional) flow that retrieves the data from a single location and stores it in a single database. Next, we will extend the same flow so that we can read the weather information from multiple locations using distinct access accounts and store the information from each location in a distinct database. To do this, we will use the platform's multicontext tools.


Steps


Step by Step

Step 01: Create the original monocontext flow

Create the single-context version of the flow to start with, so that we can more easily validate that it works correctly. The monocontext version is just a conventional version of flow that works for only one context. After checking if this version is functional we will turn it into a multicontext version.

You can also start creating a multicontext flow from zero. This example starts from a single-context stream for didactic purposes.

The original flow we are going to work with looks like the one in the figure below:

Periodically the flow calls a Weather API and gets the weather information for a particular location. Then, a Database module stores the relevant information in a Postgres database.

The Weather API requires only two parameters. The first is the locality in which to look for information. We enter this parameter through a previously configured flow variable.

The data returned by the Weather API is stored in the Postgres Database.

Step 02: Create the context keys

This flow has a temporal trigger and receives no external information at its initialization. For this reason, the context information will be stored within the flow itself using a flow variable.

In the multicontext version this same flow will run multiple times, but each time it will use different city information, Weather API access keys, and database account information. To do this, we will create a context key that will allow us to identify this information. The context key can be any identifier that is unique. We can use a userid information such as sequential numbers like: 0001, 0002, 0003, etc.

Create a flow parameter of type array. You can name it userid_list and set its value to the list of userids that will define the contexts, such as:

["0001","0002","0003"]

Step 03: Create the flow loop

We will execute the same procedure for each context. For this we will create a loop defining which part of the flow will be executed repeatedly.

Specify the newly created flow parameter userid_list as the control list. This way the loop will be executed once for each context key.

Step 04: Insert Context Finder Every time the platform runs through the loop, a different context must be used. To do this we will place the "Context Finder" inside the loop.

Insert "Context Finder" as shown in the image below:

"Context Finder" requires as a parameter the key of the context to be used. Enter the value of the element to be used in the module. This way we are passing the userid values defined in the flow parameter created earlier.

Step 05: Define the flow variables that change with Context

We need to indicate which variables will change according to the "Context".

In the original flow there are two flow variables that will vary according to the context. Both are used as parameters by the Weather API.

  • location

  • key_

We need to set them both to be defined by context. To do this, access the definition of these variables in "Context" > "Variables".

If you go to "Settings", note that they are under "Variables" in the "Context" tab.

You can't move a flow variable to the context variable

Step 06: Define the accounts that change with Context

We need to indicate which accounts will change according to the "Context".

In the original flow there is only one account that will change according to the context. It is the Postgres Database access account.

Go to the Database module and select the option: "Do you want to use flow context within this component?".

Click "Next". You can test the module again and then click "Save".

Note that the platform assumes the account that was previously configured as part of the "Default Context".

Step 07: Create the Context Accounts for the Database

Each context will access its own account. For this you need to set up individual accounts.

Access the accounts in Settings-> Connected accounts. Under "Manage connected account", select the "Database" option and under Database: POSTGRESQL. Create the database access accounts.

Step 08: Create the contexts

Each context corresponds to a set of variables and accounts that will be accessed when the context is identified. In this step we create the contexts and assign a key to locate them.

In the main Flow editing panel, click on "Context". Initially only the Default context is present. Let's create the additional contexts for our example.

Click "Add new context". Specify a name for the first context, such as "User 01" and assign a value to the key. This is the value that will be searched by "Context Finder" to identify the context. Enter the value 0001 and click "Save".

Repeat the operation to create context User 02 with key 0002 and context User 03 with key 0003.

Step 09: Define the variables and accounts within each Context

Set variable values and assign accounts for each context.

With the contexts created, you can edit their variables and define the accounts that each context should use. Click the pencil in the User 01 context to edit its values. Notice that in the Variables tab you have access to set the location and key_ parameters for this context. Click the pencil next to each of the parameters and set their values.

In the "Connected Accounts" tab you see all modules that require context accounts. In this example there is only the Postgres Database module that requires the definition of an account. Click the account selector and specify one of the Database accounts that you created earlier, in this example the User 01 DB account was selected. Save and close it to return to context editing.

Repeat the edit of parameters and accounts for the remaining contexts. In this example we use the information in the table below for the configuration. You will need to use your own access keys to configure the key_ variable for Weather API access.

Context

key

location

key_

account

User 01

0001

Sao Paulo

1f4efae6226c4e04a81140559220607

User 01 DB

User 02

0001

New York

f2fc5cb46fb74fe9b9d142517220607

User 02 DB

User 03

0003

Tokyo

8d91cdcb8c373805981143223220607

User 03 DB

Step 10: Activate and run the flow

You can verify the correct functioning of the flow through the logs available in the platform.

Activate the flow and click "Manual execution". Wait for the execution to finish and check the logs. Notice that the "Context Finder" finds the context information each time the flow goes through the loop.


Next Steps

Create a flow that gets the context key from external information.


The r is triggered every 15 minutes.

The second parameter is an authentication key to access the Weather API. Access to the API is public but requires prior registration on the where the key is provided to be used as authentication.

Insert the tool modules as shown in the diagram below. We will read the weather data and write it to the database for each context.

[ Step 01 ] Create the original monocontext flow
[ Step 02 ] Create the context keys
[ Step 03 ] Create the flow loop
[ Step 04 ] Insert context finder
[ Step 05 ] Define the flow variables that change with Context
[ Step 06 ] Define the accounts that change with Context
[ Step 07 ] Create the Context Accounts for the Database
[ Step 08 ] Create the contexts
[ Step 09 ] Define the variables and accounts within each Context
[ Step 10 ] Activate and run the flow
time trigge
site
Loop For
Original Monocontext and Adapted Multicontext Flow