# Define Flow

A **Flow** in ZBrain Builder is an operational blueprint that visually defines how your agent interacts with data, applies logic, makes decisions, and executes actions.

Get detailed information on ZBrain Flows here - [Flows](https://docs.zbrain.ai/zbrain-documentation/zbrain-builder/flows).

Defining a flow involves setting up a series of interconnected steps that guide the agent’s actions. This guide outlines the process of creating and configuring a flow, from initial setup to finalization.

### Steps to define Flow <a href="#steps-to-define-flow" id="steps-to-define-flow"></a>

To define a Flow, you can either create one from scratch, import an existing Flow or import a JSON to create the flow.

<figure><img src="/files/jeBUNv0OWiO7tGtJwKnz" alt=""><figcaption></figcaption></figure>

### 1. Navigate to the Define Flow page <a href="#id-1.-navigate-to-the-define-flow-page" id="id-1.-navigate-to-the-define-flow-page"></a>

Upon navigating to the Define Flow page, you will see four default components:

* **Webhook (Catch webhook):** This component is used to receive HTTP requests and trigger flows via unique URLs. The live URL for the webhook will be displayed. You can generate sample data and trigger the published Flow using this component.
  * **Synchronous requests:** If a response is required, add `/sync` to the URL. If the operation takes longer than 30 seconds, a 408 timeout will be returned. To send back data, include a webhook step with the return response action.
  * **Test URL:** To generate sample data without triggering the Flow, append `/test` to the webhook URL.
  * **Authentication:** You can select Basic Auth or Header Auth for authentication.

You can replace the default Webhook trigger with other triggers, such as Human Input or Google Sheets.

* **Selecting other trigger options**
  * Click on three dots on Catch Webhook and click 'Replace'.
  * After clicking, you will see additional trigger options to select from.

<figure><img src="/files/HiIK7j6cNLwmym3gAtVI" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/aud1TWRgzzDcJkpVwaDa" alt=""><figcaption></figcaption></figure>

* **Trigger input:** The trigger input component captures incoming data from the webhook or other sources. It initiates the Flow based on predefined conditions and serves as the starting point for processing the data.
* **ZBrain (Models)**: This component employs large language models to process the extracted data. Tasks such as data analysis, insight generation, summarization, classification, or other outputs are performed here, tailored to meet the specific requirements of the Flow.
* **Utilities (Agent output)**: This component handles the processed data from previous steps and sends the final output to the agent dashboard. It serves as the last step in the Flow, ensuring the result is properly delivered to the user-facing interface in the intended format.

<figure><img src="/files/QwwGbdrJuswXPyVYWw8W" alt=""><figcaption></figcaption></figure>

> **Note:** You can customize your workflow by building logic around these pre-configured components and incorporating additional elements as needed.

### **2. Adding components to the Flow** <a href="#id-2.-adding-components-to-the-flow" id="id-2.-adding-components-to-the-flow"></a>

You can add additional Flow components to build the logic.

Follow **How to create a Flow** for detailed instructions on defining a Flow with components.

### 3. Toggle options for robust workflows <a href="#id-3.-toggle-options-for-robust-workflows" id="id-3.-toggle-options-for-robust-workflows"></a>

Each component includes additional options:

* **Continue on failure**: Enable to skip the step and proceed with the Flow even if it fails.
* **Auto retry on failure**: Automatically retry the step up to four times if it fails.

<figure><img src="/files/SrXpXiQqPy4uI8aYeact" alt=""><figcaption></figcaption></figure>

### **4. Piece version** <a href="#id-4.-piece-version" id="id-4.-piece-version"></a>

Select the version of the component you want to use. The current version is selected by default, but you can switch to an earlier version from the dropdown if needed.

<figure><img src="/files/fve9i5WxswVHiHYKkndz" alt=""><figcaption></figcaption></figure>

### **5. Finalizing the Flow** <a href="#id-5.-finalizing-the-flow" id="id-5.-finalizing-the-flow"></a>

Once all steps are configured:

1. Review your Flow to ensure all steps are correctly configured.
2. Click 'Next' to continue and set up the additional settings.

#### **Exporting and reusing the Flow** <a href="#exporting-and-reusing-the-flow" id="exporting-and-reusing-the-flow"></a>

Once deployed, use the Export option to package it as a reusable template, accelerating new agent development, ensuring consistent logic, and sharing proven best practices across your organization.

* From Define Flow, click 'Flow options'
* Click 'Export'
* The Flow will be downloaded as a JSON file

<figure><img src="/files/S14dURRgR0eFBxSobYrb" alt=""><figcaption></figcaption></figure>

#### Explore advanced workflows <a href="#explore-advanced-workflows" id="explore-advanced-workflows"></a>

For more complex use cases, combine AI tools, core components, and app actions to seamlessly integrate advanced logic with third-party tools, ensuring seamless integration. This enables you to create highly customized workflows tailored specifically to your business needs.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zbrain.ai/zbrain-documentation/zbrain-builder/zbrain-ai-agents/creating-custom-ai-agents/define-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
