Add To Response (Dynamic)
Overview
Add To Response (Dynamic) adds key-value pairs to the flow response and evaluates their values when the response is generated. This means the response uses the latest value of each referenced variable, including any changes made later in the flow.
Use this stage when response fields should reflect the final state of your flow variables.
* This example demonstrates how Add To Response (Dynamic) always returns the latest value of the variable. After counter is increased by the Fast Adder stage, the response returns currentCount = 1.
Note: The variable names, values, criteria, and configuration used in this example are for demonstration purposes only.
Configuration
Required Fields
| Field | Description | Example |
|---|---|---|
| Name (Response Key) | The key that will appear in the response. Enter it as plain text without variable brackets. | currentCount, finalStatus, itemsProcessed |
| Value (Response Value) | The variable reference whose latest value should be included in the response. | {{counter}}, {{status}}, {{totalItems}} |
Fixed vs Dynamic
| Aspect | Fixed | Dynamic |
|---|---|---|
| When the value is evaluated | When the stage runs | When the response is generated |
| Value after later changes | Remains unchanged | Uses the latest variable value |
| Best suited for | Values that should be captured at a specific point in the flow | Values that may continue changing before the flow completes |
Example: Fixed and Dynamic Values
Flow: 1. Set Default Value: counter = 0 2. Add To Response (Fixed): count → {{counter}} Captured value: count = 0 3. Fast Adder: counter + 1 4. Add To Response (Dynamic): currentCount → {{counter}} Latest value: currentCount = 1
Response: { "count": 0, "currentCount": 1 }
| Step | Action | Current value of counter | Response value |
|---|---|---|---|
| 1 | Set Default Value | 0 | — |
| 2 | Add To Response (Fixed) | 0 | count = 0 (captured) |
| 3 | Fast Adder (+1) | 1 | — |
| 4 | Add To Response (Dynamic) | 1 | currentCount = 1 (latest) |
Exit Points
| Exit | When |
|---|---|
| Pass | Always. This stage does not have a fail exit. |
How It Works
When executed, the stage:
- Receives the configured fields – Reads each response key and variable reference.
- Stores the variable references – Keeps the fields linked to their variables rather than capturing a snapshot.
- Adds the fields to the response – Includes the configured key-value pairs in the response payload.
- Evaluates the values when needed – Uses the latest variable values when the response is generated.
Key behavior: If a referenced variable changes after this stage runs, the response reflects its latest value.
Common Use Cases
1. Return Final Progress Values
Include variables that are updated as the flow progresses.
Configuration:
itemsProcessed→{{totalItems}}currentStatus→{{status}}
Result: The response contains the latest values after the flow has completed its updates.
2. Return Branch-Specific Values
Add values that are set differently depending on the route taken through the flow.
Pass branch:
success→{{successCount}}
Fail branch:
error→{{errorMessage}}
Result: The response reflects the values set by the branch that was executed.
3. Combine Fixed and Dynamic Response Fields
Use Fixed for values that should be captured immediately and Dynamic for values that may change later.
Add To Response (Fixed):
processedAt→{{timestamp}}version→2.0
Add To Response (Dynamic):
itemsProcessed→{{totalItems}}currentStatus→{{status}}
Result: The response combines values captured at stage execution time with values evaluated when the response is generated.
Best Practices
- Use Dynamic for variables that may change later in the flow.
- Use clear, consistent response key names.
- Initialize optional variables with Set Default Value to avoid empty values.
- Combine Fixed and Dynamic stages when the response needs both captured and final values.
- Test the complete execution path to confirm that the final response contains the expected values.
Common Mistakes
| Mistake | Symptom | Fix |
|---|---|---|
| Using variable brackets in the response key | The response contains an incorrect key name | Enter the key as plain text, for example userId. |
| Using Fixed when the value must reflect later changes | The response contains an earlier value | Use Add To Response (Dynamic). |
| Referencing an uninitialized variable | The response contains an empty or null value | Initialize the variable with Set Default Value earlier in the flow. |
| Expecting the value to remain unchanged | The response value changes after the variable is updated | Use Add To Response (Fixed) when a snapshot is required. |
Troubleshooting
| Issue | Common Cause | Fix |
|---|---|---|
| Field is missing from the response | The response key or value is empty or misconfigured | Check that both fields are completed and that the stage is on the executed flow path. |
| Value is different from the value seen when the stage ran | The variable was updated later in the flow | Review later stages that modify the variable, or use Fixed if the earlier value is required. |
| Value is empty or null | The variable was not initialized before the response was generated | Initialize it with Set Default Value. |
| Response structure is inconsistent | Some variables are only created on specific branches | Initialize all expected response variables before routing the flow. |
Do's and Don'ts
| Do | Don't |
|---|---|
| Use Dynamic for values that may change before the response is generated. | Do not use variable brackets in response key names. |
Use variable references such as {{userId}}. | Do not expect Dynamic values to remain frozen after the stage runs. |
| Initialize optional variables before using them. | Do not use Dynamic when you need to preserve an earlier value. |
| Use Fixed and Dynamic together when both behaviors are needed. | Do not assume every branch creates the same variables. |
Edge Cases
- Variable not initialized: The dynamic reference may resolve to an empty or null value.
- Variable changed after the stage: The response uses the latest value.
- Same variable used more than once: Each reference resolves to the same latest value.
- Null values: A null value remains null rather than being converted to text.
- Data types: The current variable type is preserved in the response.
Related Stages
- Add To Response (Fixed): Capture response values when the stage runs.
- Return True: Return a successful completion result.
- Return False: Return a false completion result.
- Change Data: Update variables before the response is generated.
- Set Default Value: Initialize optional variables before using them.