Navigate the workflow data context, set reusable variables, transform data shapes between steps, and inject dynamic values into URLs, headers, and email templates.
The Workflow Data Context
Every Cotonity workflow maintains a data context — a structured object that grows as the workflow progresses. When the workflow starts, the context contains the trigger payload (for webhooks) or a timestamp (for schedules). As each step executes, its output is appended to the context under a namespace derived from the step's name. For example, a step named 'Fetch Contact' produces output at 'steps.fetch_contact.output'. Every subsequent step can read any field from the context using the data mapping editor, which provides a point-and-click picker showing all available fields with their current test values. Understanding this linear accumulation model is key to designing workflows correctly: a step can only reference data from the trigger or from steps that appear earlier in the execution graph.
Setting and Updating Variables
Use the Set Variable step to store a computed value that you want to reference repeatedly throughout the workflow without recalculating it each time. A common use case is computing a formatted date string once and referencing it in five different email templates and API calls. Click Add Variable, give it a name ('formatted_date'), and enter an expression using Cotonity's template syntax: '{{date.format(trigger.created_at, "MMMM D, YYYY")}}'. Variables persist in the data context for the rest of the workflow execution and are accessible via 'vars.variable_name'. You can also update a variable later in the workflow — useful for incrementing a counter inside a loop or appending items to an array as iterations complete.
Transforming Data Between Steps
Upstream APIs rarely return data in the exact shape your downstream systems expect. The Data Transform step lets you reshape, filter, and compute new fields without writing a custom code step. It uses a declarative mapping editor where you define output fields as expressions over the input context. For example, you might concatenate a first name and last name ('{{steps.fetch_contact.output.first_name}} {{steps.fetch_contact.output.last_name}}'), convert a Unix timestamp to an ISO 8601 string, or extract a nested value from a deeply structured JSON object using dot notation. For complex transformations that exceed the capabilities of the declarative editor, the Code step accepts a JavaScript function that receives the full context as an argument and returns the transformed data.
Dynamic Values in Templates and API Calls
Cotonity's template syntax (double curly braces) works everywhere a text field appears: URL paths, query parameters, request headers, request bodies, email subjects, message texts, and condition values. This means you can build fully dynamic API calls where the endpoint URL, authentication header, and request body are all computed from the current execution's data context. For example, a step that updates a CRM contact might use 'https://api.crm.example.com/contacts/{{steps.fetch_contact.output.id}}' as its URL, making the step reusable across any contact in a loop. Template expressions support dot notation for nested access, bracket notation for array indexing, and a growing library of built-in helper functions for string manipulation, date formatting, number rounding, and JSON encoding.