Data Transform Node

Understand what a Data Transform node is and how to configure it

The Data Transform node enables you to transform data from JSON or XML to the desired format using VTL (Velocity Template Language). Velocity is a Java-based template engine. VTL is used to provide the easiest, simplest, and cleanest way to incorporate dynamic content on a web page.

Within Webex Connect, you can use it for tasks such as converting the JSON response from an HTTP call (made using HTTP request node) into XML format.

When you double-click the node, the Data Transform screen appears with two tabs: Configuration and Transition Actions. The Configuration tab enables you to configure the data conversion settings whereas the Transitions tab provides configuring the node on-enter/on-leave operations.

Here is the node image:

165

Data Transform Node

Interface Elements

1000

Click the image to view it larger

Here is the description for the interface elements:

S. NoElementDescription
1Configuration tabUse this tab to configure the data transformation settings.

Here is the description for the fields:

Input Variable
In this field, specify the variable in which the data is stored.

Input Data Format
From this drop-down box, select the input data format choosing from JSON or XML .

Define Template
In this box, specify the template into which the data from the JSON or XML is to be converted.
2Transition Actions tabUse this tab to configure node on-enter/on-leave operations.

Here is the description for the fields:

Add action link - Click it to view the Transition action fields.
3Input VariableClick the collapsible panel on the right side of the node UI to view the list of all the available flow variables. You can search for a variable using the Search field. You can also add a variable to the flow variables list by clicking the Add new flow variable link at the bottom of the list.
4Output VariablesClick this collapsible panel to view the output variables. The data generated by the node is displayed as variables here.
5Node OutcomesClick this collapsible panel to view the list of possible node outcomes. You can also customize the node labels by clicking the Edit icon.

Transforming Data Using VTL

You can transform data from JSON or XML to the desired format using VTL (Velocity Template Language).

Here are the steps:

Configuring Settings

  1. Double click the Data Transform node.
    The Data Transform screen appears.
  2. On the Data Transform screen:
  • In the Input Data Variable field, specify the variable in which the input data is stored.
  • From the Input Data Format drop-down box, select JSON or XML from which you wish to transform the data.
  • In the Define Template (Using VTL) field, specify the desired template into which the data from JSON or XML is to be transformed. Quick example below.
  • Click the Save button at the bottom.

The data is transformed and is populated in the Output Variables panel on the right.

Quick Sample

Let's say you want to convert the following JSON to XML using Data Transform Node:

{
   "date": "02-07-2023",
   "milliseconds_since_epoch": 1675806192399,
   "time": "09:43:12 PM"
}

First you will need to convert the JSON payload to the JSON String format.

"{\"date\":\"02-07-2023\",\"milliseconds_since_epoch\":1675806192399,\"time\":\"09:43:12PM\"}"

Please note that if you have made an API call using 'HTTP Request' node the response is already stringified by Webex Connect.

To convert this JSON String into XML using the Data Transform node, you will need to do the following config in Define Template (Using VTL) section:

#set($responseJSON = $(n9.http.responseBody))

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <row>
        <dated>$responseJSON.date</dated>
        <milliseconds_since_epoch>$responseJSON.milliseconds_since_epoch</milliseconds_since_epoch>
        <time>$responseJSON.time</time>
    </row>
</root>

Sample Output:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <row>
        <dated>02-07-2023</dated>
        <milliseconds_since_epoch>1675806192399</milliseconds_since_epoch>
        <time>09:43:12PM </time>
    </row>
</root>

Set directive that's been used in the first line in the above example is a VTL directive that is used to set the value of a reference. You can read more about it here.

The XML response will be available in the 'dataTransform.output' variable.

Configuring Transitions

As part of configuring transition actions, you can configure on-enter/on-leave operations. However, configuring these are optional.

Here are the steps:

  1. On the Datatarnsfrom screen, click the Transition Actions tab.
  2. On the Transition Actions tab, click Add Action.
    The Transition Actions area appears.
  3. On the Transition Actions area:
  • From the Time drop-down box, select On-enter or On-leave. For example, On-enter.
  • From the Acton drop-down box, select an action choosing from the pre-built options.

📘

Tip

To delete an event, click the delete button corresponding to that event. See the image below.

37

Delete Button

  • Finally, click the Save button at the bottom.
    The transition actions are configured.