Flows & Handlers

"Flows" are a set of statements, written like pseudocode using simplified language, for implementing integrations.

"Flows" are a set of statements like pseudocode, written using simplified language, for implementing integrations.

Introduction to Flows

Flows act as a neural schema for system integration, carrying out the whole integration process end to end. The flow is responsible for handling business logic, making API calls to the targeted system, formatting and validating data, logging transactions and so on.

Flows are created by developing a logical program sequence using lines of code-representation known as Handlers. Handlers form the backbone of every Flow.

  1. The list of Pipes associated with a Flow are displayed below the Flow Status Area.

What are Handlers?

Handlers are statements used to build a flow, in the form of code-representation by following an algorithmic approach. Every handler has its functional logic and requires a certain set of parameters to be defined to carry out its activities. Multiple Handlers are available to the user to build their flow.

Some example functionalities that Handlers can perform include

The same handler can be used N number of times in a Flow.

How to use Handlers?

Simply drag and drop Handlers to the ‘Play Area’ to include them in your Flow. Once it is positioned in the coding area, its parameters need to be assigned. These parameters are different for each handler and are discussed in detail below.

Handlers can also be copied, moved, and commented on within the Play Area and can also be deleted when they are no longer needed.

Selecting Multiple Handlers

Multiple Handlers can be selected by selecting the checkbox alongside each handler statement. Once the handlers are selected, user may Cut/Copy/Delete/Comment the statements as needed.

Available Handlers

API Calls

Triggers an API Call in which you can pass parameters and payload to any system. The API responses will be stored in a defined variable which is available for further usage in the Flow.

While clicking on the API dropdown list, a differentiator to identify global and custom APIs will be seen. See image below:

It is recommended to use the If, Else handlers after the API call handler, to ensure the validity of the API response.

For XML Payload (Examples)

Plain request

{'plain_request': {'key1':'value1','key2':'value2'}}

Not a plain request

{'body':{'key1':'value1','key2':'value2'}}

Use keywords(DYNAMIC_TOKEN, GET_FROM_CREDENTIALS) to fetch and pass the respective dynamic information in headers and payload.

  • DCKAP Integrator accepts API responses in JSON, CSV and Text formats.

  • API Call Handler also has the facility to add headers from Flows.

To add additional envelope namespace

Along with the above request, add another key “envelope_namespace” to add additional namespace with default namespace

XML Request Body

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
   </soapenv:Header>
   <soapenv:Body>
      <urn:login>
         <urn:username>user1@ddckap.com</urn:username>
         <urn:password>user1@123</urn:password>
      </urn:login>
   </soapenv:Body>
</soapenv:Envelope>

Converted JSON request Body

{
    "envelope_namespace": "xmlns:urn='urn:enterprise.soap.sforce.com'",
    "body": {
        "urn:login": {
            "urn:username": "user1@ddckap.com", 
            "urn:password": "user1@123"
        }
    }
}

To override the API manager timeout at the Flow level.

Choose: Yes/No from the drop-down list Yes - Override the timeout based on read and connect values mentioned here No - Do not override the timeout based on read and connect values mentioned here

"Connect" refers to the maximum allowed time for DCKAP Integrator to establish communication with the system to which the API call is made.

"Read" refers to the maximum allowed time for the system to respond back to DCKAP Integrator.

MySQL

Connects to the SQL database and allows users to configure data in the SQL database.

Different Action Types with examples:

Action: Insert 
Description: Used to insert a record into a table
Example: 
INSERT into table_name (name, email, contact_no) values ('John Smith', 'johnsmith@gmail.com', '+17427772299');
Action: Insert Many 
Description: Used to insert multiple records into a table
Example:  
INSERT into table_name (name, email, contact_no) values ('John Smith', 'johnsmith@gmail.com', '+17427772299'), ('Max Roger', 'roger@gmail.com', '+17217772299'), ('Mike Hussey', 'hussey@gmail.com', '+17347772299');
Action: Replace 
Description: Used to insert records into a table if there is no record found already, otherwise records will get updated
Example:
INSERT into table_name (name, email, contact_no) values ('John Smith', 'johnsmith@gmail.com', '+17427772299'), ('Mike Hussey', 'hussey@gmail.com', '+17347772299') ON DUPLICATE KEY UPDATE name=VALUES(name), email=VALUES(email), contact_no=VALUES(contact_no);
Action: Update 
Description: Used to update a record from the table
Example: UPDATE table_name SET name='Steve Smith', contact_no='+17433773377' WHERE email='steve@gmail.com';
Action: Delete 
Description: Used to delete a record from the table
Example:
DELETE from table_name WHERE email='hussey@gmail.com';
Action: Select 
Description: Used to retrieve a record from the table
Example: SELECT * FROM table_name WHERE email='johnsmith@gmail.com' limit 10;

To retrieve column names from the table below example query should be executed,
Query: SELECT * FROM table_name WHERE 1=0;

Incrementer

Increments the value of a specified variable by a given step.

Example

Increment variable line_number by 1

Here, the variable line_number will be incremented by value 1

Formatter

The formatter is used to stringify/dump the JSON.

Try Block

The Try Block is used to catch an error.

No parameters are assigned for the Try Block

Exception Block

The Exception block handles the exceptions caught by the Try Block

Email Sender

Sends an email from the Flow to the assigned recipient list.

Example 1

Message Type: Plain Text
Dynamic Data: Leave it blank
Message: String
Dear Sir,
This is to inform you that we received your ticket.
Example 2

Message Type: HTML
Dynamic Data: Leave it blank
Message: Non-String
<html>
   <head>
      <h1> Line1 </h1>
   </head>
   <body>
      <i>This is a mail to communicate that we are working on your ticket </i>
   </body>
</html>
Example 3

Message Type: HTML
Dynamic Data:  
{"keys": ["Name","Age","Company"], 
"records": 
[
{"name": "Alex", "age": 25, "company": "DCKAP"},
{"name": "David", "age": 28, "company": "DCKAP"}
]
}
Message: Non-String
<!DOCTYPE html> 
<html>
   <head>
      <style> 
         table, th, td { border: 1px solid black; } 
      </style>
   </head>
   <body>
      <table>
         <tr>
            {% for key in keys %}
            <td>{{key}}</td>
            {% endfor %} 
         </tr>
         <tr>
               {% for dict_item in records %}
                      {% for key, value in dict_item.items() %} 
                              <td>{{value}}</td>
                      {% endfor %}
                      <tr></tr>
               {% endfor %} 
         </tr> 
      </table>
   </body>
</html>

Base-64 HTML Combination and occasionally Base-64 plain text combinations don't work as expected. This will be addressed in the upcoming releases.

Initialize Variable

Assigns and stores data in the specified variable which can be used in the Flow, after the variable declaration.

Available Options

Example 1

Assign value 0 to variable Area_Code

Here, 0 is assigned to the variable: Area_Code

Example 2

Assign value orders_info[‘data’][‘customers’] to variable customers

Here, the value in the dictionary: orders_info[‘data’][‘customers’] is assigned to a variable: customers

Example 3

Assign value {"entity_id": customer['id'], "shipto_id": ""} to variable customer_info

Here, the dictionary {"entity_id": customer['id'], "shipto_id": ""} is assigned to variable customer_info

Example 4

Assign value dependent_customers[item['customer_id']]['customer_id'] to 
variable mapped_orders['hdr']['customerId']

Here, the value in dictionary dependant_customers[item['customer_id']][customer_id] is assigned to variable mapped_orders['hdr']['customerId']

Modify Variable

The handler is used to change or modify the contents of a variable (mainly array and dictionary), that has already been used in the flow.

Available Options

Use Case 1 - Dictionary(Action: Assign)

Modify variable customer_info['customer_id'] with value custom_attribute['value']
  • Assume the variable customer_info is a dictionary/JSON and contains the value {“entity_id”:12, “name”: “Alice Blue”}

  • To add more keys with values to the dictionary, the modifier handler is used

  • The below step adds customer_id to the dictionary

  • After processing, the customer_info variable contains the value {“entity_id”:12, “name”: “Alice Blue”, “customer_id”: custom_attribute[‘value’]}

Use Case 2 - Array(Action: Append)

Modify variable customer_info['customer_id'] with value custom_attribute['value']
  • Assume the variable customer_info is an array/list and contains the value [{“entity_id: 1}, {“entity_id: 2}, {“entity_id: 3}]

  • To add an item to the array, the Modify Variable handler is used

  • The below step adds customer_id to the Array

  • After processing, the customer_info variable contains the value [{“entity_id: 1}, {“entity_id: 2}, {“entity_id: 3}, {"custom_attribute['value']}]

Mapping

Provides the ability to get mappings from the user and format data between two different system APIs.

This adds a new mapping card in the pipes section to get mappings in the pipe. The Modifiers will also be provided in the same section.

Based on the Mapping configuration, the destination payload will be prepared from the source data.

Available Options

Example

Prepare mapping with name Customers Information from source Get Customers- Magento 2
to destination Create Customers - Epicor P21 Custom Server

Creates a mapping node in the pipe to provide the mapping of data between the specified source and destination APIs.

Use Case - Ignore Keys

{
  "customer": [
    {
      "name":"alice",
      "address": {
        "street": "Jarvis St.",
        "door_number": "5A"
      }
    },
    {
      "name":"bob",
      "address": {
        "street": "Marvel St.",
        "door_number": "7D"
      }
    }
  ]
}

Assume the field street is mapped from source to destination system and the path generated for this field will be customer/address/street.

During Mapping, when the user sends this customer data(Parameter: Data) inside a loop, one entry at a time, to get the street address, the resulting path generated will be address/street.

In this case, the user should mention the parent keys to be ignored. In this case customer. If multiple keys need to be ignored, then the user should mention them as comma-separated values.

When an API or system is changed in the Flow, then the previously configured mapping becomes unstable.

So users will be alerted if the mapping should be retained or if it should be deleted during the save and merge process.

If the mapping is retained, the errors will be highlighted.

If, Else If & Else

To define and check for decision-making conditions inside the Flow.

Condition parameters are defined for the If and Else If handlers. If this condition is satisfied, the children of If will be executed. Otherwise, the children of Else will be executed.

Available Options

No parameters are assigned for the Else Handler.

Examples

If specified condition matched

Some example conditions that can be used with the If statement, which need to be true for the proceeding children-statements to be executed

Loop (Works like a For Loop)

Executes a block of code repeatedly in a cyclic fashion, each time with a different value.

Available Options

Examples

Loop till specified condition matched
  • orders

  • mapped_orders["lines"]

MSSQL

Connects to the Microsoft SQL database and allows users to configure data in the SQL databases.

Step Progress

Denotes the progress of data processed inside a loop. The outcome of this handler is visually seen in the progress bar in the Integrations page. This helps in understanding how much data synchronization has been processed.

Use predefined variables records_processed and total_records to track the records. Add Incrementer handler in the loop to increment the values on every count.

Available Options

Steps

This handler is placed one level above the previous handler Step Progress. It is used to visually split the business logic of the flow, for better understanding while synchronizing the data.

Available Options

Logger

The Logger handler is used to log any errors or warnings in the flow. The Logs menu in the project area displays all the logs from the synchronization.

This is a general level log and to log at the entity level, click here.

Available Options

Step Logger

The Step Logger handler is similar to the Logger handler but used to provide logs at the item level. The Step Logger marks every single entity inside the loop as Success or Failure.

This can be viewed by clicking the "View" button in the Logs section.

For more general level logging, click here.

Available Options

Console

Displays messages in the Logs section console area. This is especially useful in debugging the Flow itself.

The messages can be either static or dynamic.

Available Options

Get Last Synchronized Time

Gets the last synchronized time of a system, in the required time zone

Available Options

Credential Keys

Retrieves any credential details from the respective project. (Example: Name, System, Hostname)

Available Options

Return Value

Returns data to the caller, in real-time.

This applies only to the dynamic pipes.

Available Options

Date Time Formatter

Add or subtract minutes or hours from a given time value.

Available options

Time Converter

Converts Time from one format to the other (12Hr clock to 24Hr clock and vice versa).

Time Zone converter

This handler serves two purposes:

  1. Converts datetime (object/string) from a time zone to another timezone.

  2. Generates a timestamp for a given datetime (object/string).

Click here to Learn more about configuring the Timezone Converter and examples.

Data Type converter

Converts data from one data type to another (string to integer or integer to string).

Current DateTime

Converts current time to the timezone of selected system.

Available options

Pagination

To send required paginated data for API calls.

Available options

While Loop

Loop till specified condition is true.

Available options

Break

To break a loop.

SFTP Writer

To create files in a remote location using SFTP connection.

Prerequisite: Add SFTP Credentials

To write CSV files, it should be in one of the below formats:

String:
Name,Branch,Year\nSanchit,COE,2\nHello,IT,1\nThere,CS,5

Array/List:
[['Name', 'Branch', 'Year', 'CGPA'],['Nikhil', 'COE', '2', '9.0'],
        ['Sanchit', 'COE', '2', '9.1'],
        ['Aditya', 'IT', '2', '9.3'],
        ['Sagar', 'SE', '1', '9.5'],
        ['Prateek', 'MCE', '3', '7.8'],
        ['Sahil', 'EP', '2', '9.1']]

SFTP Reader

To read files from a remote location using SFTP connection.

Prerequisite: Add SFTP Credentials

FTP Reader

To read files from a remote location using FTP connection.

Prerequisite: Add FTP Credentials

FTP Writer

To create files in a remote location using FTP connection.

Prerequisite: Add FTP Credentials

To write CSV files, it should be in one of the below formats:

String:
Name,Branch,Year\nSanchit,COE,2\nHello,IT,1\nThere,CS,5

Array/List
[['Name', 'Branch', 'Year', 'CGPA'],['Nikhil', 'COE', '2', '9.0'],
        ['Sanchit', 'COE', '2', '9.1'],
        ['Aditya', 'IT', '2', '9.3'],
        ['Sagar', 'SE', '1', '9.5'],
        ['Prateek', 'MCE', '3', '7.8'],
        ['Sahil', 'EP', '2', '9.1']]

FTP Advanced

Lists files, deletes, renames, moves & changes permission for file and creates directory in the remote location using the established FTP connection

Note: For root folder, use / in the path field

List files

Delete File

Rename File

Move File

Change Permission

Create Directory

SFTP Advanced

Lists files, deletes, renames, moves & changes permission for file and creates directory in the remote location using the established SFTP connection

Note: For root folder, use / in the path field

List files

Delete File

Rename File

Move File

Change Permission

Create Directory

Internal Dynamic Call

To trigger a dynamic pipe from another pipe.

a) Dynamic Pipe: Choose the dynamic pipe to trigger from the dropdown list

b) Payload: The payload field is used to send data to the Dynamic Pipe that is being called. This data will be used in the Dynamic pipe to process the associated Flow.

c) Response Variable: Once the dynamic pipe is triggered from this handler, a variable will be sent back from the dynamic pipe. The 'Response variable' field will be used to store that response.

Last updated