# Response Node

The Response node is a fundamental component in workflow design, especially in API workflows, facilitating the transmission of data back to the caller.

{% embed url="<https://youtu.be/sQluBbI_jG0>" %}

### Functionality

* **Sending Responses:** The primary function of the Response node is to send data back to the caller of the workflow.
* **Integration with API Workflows:** It is particularly useful in API workflows where returning data to the requester is essential.

### Behavior in Workflows

* **Flow Termination**: Adding a Response node effectively terminates the flow above it.
* **Introduction of Delay Node:** Upon adding a Response node in the middle of a flow, a Delay node is automatically appended immediately after it.

**Reason**: This design choice ensures that anything added after the Delay node will run *asynchronously* within the workflow.

### Add Response Node in Workflow

Click on **+ icon** and add a response node from the list of available nodes.\
![](https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FBiTyATs9YkNe40Mhy0jI%2Fresponse_node_1.png?alt=media\&token=45b8d374-abc6-4703-9063-92681fe8498b)

### Configure Response Node

The **Response Node** lets you define and return structured outputs from your workflow — allowing other systems or processes to consume the result.\
Configuring its input parameters works the same way as in the **Set Variable** node.

When you click on a **Response Node**, the configuration modal opens. Inside the **Input Params** tab, you can define your response attributes by specifying their **name**, **data type**, and **value**.

#### Adding Fields

Click the **Add Field** button. You’ll see two options:

**1. Custom Attribute**

Select **Custom Attribute** to manually create a new response key and assign it a value.\
You can:

* Add **static values** directly, or
* Use **dynamic attributes** (via the token widget on the left) to pull data from triggers, previous nodes, or global variables.

The **Input Attributes panel** automatically appears on the left when you click inside any value field.\
You can search or expand groups like *Trigger Attributes*, *Previous Node Attributes*, *Global Attributes*, or *System Attributes*, and **drag and drop** them into the form field.\
Only compatible data-type attributes will be available for selection.

Each attribute appears in curly braces (`{{ }}`), such as:

* `{{Trigger.order_id}}`
* `{{SetVariable1.output.customer_name}}`
* `{{globalVar.discountRate}}`
* `{{systemVar.NULL}}`

#### Supported Variable Types

| Type         | Description                                                                                                                                                                              |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Boolean**  | For true/false values. Static or dynamic attributes can be used.                                                                                                                         |
| **String**   | For text or alphanumeric data. Supports static or mapped values.                                                                                                                         |
| **Numeric**  | For integers or decimal numbers.                                                                                                                                                         |
| **Date**     | For date-only values in `YYYY/MM/DD` format (e.g., `2024/07/21`).                                                                                                                        |
| **DateTime** | For timestamp values in RFC3339 format (e.g., `2024-08-07T12:46:00+05:30`).                                                                                                              |
| **JSON**     | For structured JSON outputs. See the [JSON Editor Documentation](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419) for details.         |
| **List**     | For lists or arrays of items. See the [List Editor Documentation](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419).                    |
| **JS Code**  | For outputs computed using JavaScript. See the [JavaScript Editor Documentation](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419).     |
| **Formula**  | For outputs computed via formula expressions. See the [Formula Editor Documentation](https://chatgpt.com/g/g-p-675d098818e08191b6e21e8ec082c1b3/c/68f0a34a-6018-8320-ad27-79675abac419). |

**2. Attribute Library**

If you choose **Attribute Library**, a modal opens showing available attribute libraries.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2Fe1WBzMMXYgO8GP72fDD3%2Fimage.png?alt=media&#x26;token=33f16736-7104-4504-b682-eba9808a0885" alt=""><figcaption><p><strong>Read the</strong> <a href="../../../references/attribute-library"><strong>Attribute Library</strong></a> <strong>doc</strong></p></figcaption></figure>

* If you haven’t created one yet, you’ll see a prompt to create your first library. You can follow the linked steps in the [**Attribute Library Documentation**](https://docs.nected.ai/nected-docs/references/attribute-library).
* If you already have existing libraries, you’ll see a list of them with available attributes.

Select one or more attributes from the library, then click **Import to Input Attribute** to add them to your Response Node.

Once imported:

* You can assign values for each attribute from the **value** field.
* If an attribute is marked as **Mandatory**, its assigned value must match a predefined value or be selected from the available attributes in the panel.

***

#### Testing the Response Node

After defining all your response attributes:

1. Click **Save** to apply your configuration.
2. Use the **Test** button to run the Response Node and verify that the returned data matches the expected output format.

The **Input Section** will display the provided attributes and values, while the **Output Section** will show the structured JSON response returned from the node.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FNgz1PfQQXiglv07RAsb7%2FExport-1723023773409.gif?alt=media&#x26;token=e7b939ca-b894-4b30-a936-bf666ada16f8" alt=""><figcaption></figcaption></figure>

> **Consideration:** While using the Response node, it's essential to consider the flow termination behaviour and the introduction of the Delay node for proper workflow management.

After adding a Response Node, the next available node you can add is the **Delay Node**. The Delay Node is used to introduce a delay after showing the response. This is useful for pacing the flow of the workflow.

The Delay Node allows you to specify a wait time before the workflow proceeds to the next action. This can be useful for creating pauses in the workflow for user interactions or system processing time.

For more details on the Delay Node, refer to the [Delay Node Documentation](https://docs.nected.ai/nected-docs/workflow/add-node/control-nodes/delay-node-renamed-wait-and-resume-node).

### Pass tokens from previous nodes:

To return values from prior nodes, you can access these values using tokens directly in a designated field within the response node. Simply insert the relevant tokens in the desired location inside the response node. This approach simplifies the process of retrieving and utilizing data that was handled in preceding nodes, enabling seamless integration and functionality within your workflow. This method ensures that information flows smoothly from one part of your application to another, enhancing efficiency and coherence in handling complex operations.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FKwMGyutxeCFhFxs382Tv%2FExport-1730205761934.gif?alt=media&#x26;token=e29c516a-6b4a-4701-a740-30834684cffa" alt=""><figcaption></figcaption></figure>

### Pass tokens among fields:

You can also transfer tokens between different fields. This means you have the flexibility to utilize tokens from one field within another across the same response node. Here's an example to illustrate

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FXCqwfyGplpsi3HpxVnN9%2FExport-1730205536019.gif?alt=media&#x26;token=26d9ff7a-0f4f-420e-8eea-0bf4e36a8796" alt=""><figcaption></figcaption></figure>

### Conclusion

The Response node serves as a vital component in workflow design, facilitating seamless communication between workflows and their callers, particularly in API environments.
