Skip to main content
All CollectionsBuild AutomationsWorkflowsData
Understand Data Access and Utilization in Torq: Workflow Context
Understand Data Access and Utilization in Torq: Workflow Context

Learn how to use workflow context in Torq for data access and utilization within your automation processes.

Updated over a week ago

All data in Torq is in JSON format. JSON (JavaScript Object Notation) is easy to read and manipulate (transform) for users and machines. JSON is also the most common data format used by REST APIs. Here are some examples of how JSON references may be passed through Torq:

  • Say you have an event based on suspicious user activity, the user's MAC address may be contained in the event JSON. Despite not knowing the exact address, you can pass it on to the next step by specifying the JSONPath to that key: $.event.user.macAddress.

  • Use JSONpaths in a free-text field when sending messages. To personalize a message, you can write: Hello {{ $.event.user.firstName }}.

Break Down JSON

Data in JSON format is easy to parse and allows for quick digestion and data location.

To better understand JSON, we will use a running example of data for a party.

{ 
"party": {
"day": "Saturday",
"time": "2021-11-03",
"address": "123 Party Place",
"food": ["chicken", "beef", "fish", "veggies"],
"decorations": [ { "style": "balloons", "color": "blue" }, { "style": "streamers", "color": "red" } ],
"guestsNumber": 25,
"surpriseParty": false }
}

The two main components of JSON are keys and values, otherwise known as a key:value pair. Each key:value pair is a separate line in the JSON. A colon separates them : and each line ends with a comma ,

In our example data, "day" is a key. The corresponding value would be "Saturday", - but as you can see, a value can also be any supported data type. See the list below for an analysis of each data type shown in our example.

  • string: An alphanumeric sequence of characters written in quotation marks. (ex: "day":"Saturday")

  • number: An integer, not written in quotation marks. (ex: "guestsNumber":25)

  • boolean: True/False, not in quotation marks. (ex: "surpriseParty":false)

  • array: An array is a list placed within double brackets []. (ex: "food": ["chicken", "beef", "fish", "veggies"])

  • object: A JSON object is an array of key:value pairs placed within curly brackets {}. (ex: "party" is an object, and "decorations" is an array of objects)

Workflow Context

The workflow context is a collection of all the data (in JSON format) for a given workflow.

The data comes from the event and the executed steps. Data may be received from any third-party integration or passed as workspace, global, or workflow variables.

The following is an example of some context data.

JSONPath

Description

Example

$.event

Access event data that triggered the workflow.

{{ $.event.attachments }} Event-triggered by an IMAP event that contained at least one attachment.

$.integrations

Access integrations for which you've made configurations.

{{ $.integrations.wiz_demo }} Integration for the wiz_demo integration.

$.secrets

Access credentials or secrets for integrations or custom secrets.

{{ $.secrets.<secret_key> }}

$.{step_name}

Access data from a previously executed step.

{{ $.extract_urls_from_email.results }}

After an object is added to the context, subsequent steps can access that data with Torq's JSONPath autocomplete. Type {{ $. and follow the automatically generated workflow context tree to locate the data you are looking for. The tree is structured in the same format as JSON as covered above, with key:value pairs.

Did this answer your question?