> For the complete documentation index, see [llms.txt](https://docs.hablla.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hablla.com/hablla-docs-en/automation-flows/flow-management/how-to-use-distribution-queues-in-a-flow.md). Agents can also search and read this documentation through its [MCP server](https://docs.hablla.com/~gitbook/mcp).

# How to Use Distribution Queues in a Flow

Now that you already know how to create and configure a **Distribution Queue**, the next step is to use it in an **Automation Flow**. If you still don't know how to configure your Queue, you can learn more about the **Distribution Queues**in our official documentation [by clicking here ↗️](https://docs.hablla.com/hablla-docs-en/hablla/settings/distribution-queue.md).

Currently, Distribution Queues can be used **exclusively through Hablla Automation Flows** . To do this, it is necessary to add the component **Queue Distributor** to the flow where the distribution should occur.

In the tutorial below, we will use a flow model in which we **will create** a flow from scratch made up of only 4 components to exemplify the use of the **Distribution Queue** in practice.

### 1. Create the desired flow

Access the **Studio** and add a new flow where the distribution should be carried out. In this example, we will use a WhatsApp inbound service flow.

1. **First Step:** Click on the WhatsApp button icon in the quick icon menu located at the bottom of the screen.
2. **Second Step:** Select the "**WhatsApp Inbound**" icon in your flow.

{% hint style="info" %}
To select any component in automation flows, we have two options:&#x20;

* **Option 1:** Click and hold the component, then drag it to the **blank area** of the flow *(With this option, you can choose where the new component will remain in the flow).*

<img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2Fnm4rSaiJrPbTXL1sdCqx%2FAdobe%20Express%20-%20%5BDOCS%5D%20-%20Como%20Selecionar%20Componente%20no%20Fluxo%201_v2.gif?alt=media&amp;token=f0c32bee-74c8-49b7-a654-0b0eb2624872" alt="" data-size="original">

* **Option 2:** Just click on the component and the flow will automatically create the new component within a **default area** of the flow.

<img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2Fs6M3PDxwWOBgeIOQ9Vwc%2F%5BDOCS%5D%20-%20Como%20Selecionar%20Componente%20no%20Fluxo%202_v2.gif?alt=media&amp;token=3d7215cd-c338-49ee-b91d-032727c0e6b5" alt="" data-size="original">
{% endhint %}

### 2. Add the Queue Distributor component

{% hint style="warning" %}
**Important:** The component must be part of an automation flow. It cannot remain isolated, without connection to the other components in the flow.
{% endhint %}

1. **Step 1:** In the quick components menu at the bottom, locate and click the "Hablla" component (the icon with the Hablla logo)
2. **Step 2:** Now, locate the component: "**Queue Distributor**" and select it.
3. **Step 3:** Connect the inbound nodes to the queue distributor icon, as shown in the GIF below:

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FAJXTW1kWD3Dvxc5Hsogc%2F%5BDOCS%5D%20-%20Como%20selecionar%20distribuidor%20de%20filas%20(1).gif?alt=media&amp;token=003cd778-a92d-47ef-907e-1e0572b2aefc" alt=""><figcaption></figcaption></figure>

### 3. Select the queue that will be used in the Distributor node

Click **twice** on the component **Queue Distributor** to open its settings. When the new window opens, you need to select one of the **queues you configured** earlier following [our documentation](https://docs.hablla.com/hablla-docs-en/hablla/settings/distribution-queue.md).&#x20;

In the **Queue\***&#x66;ield, select one of the queues you created and then click **Save**.

{% hint style="warning" icon="triangle-exclamation" %}
If you haven't configured any distribution queues yet, they will not be displayed in this component.
{% endhint %}

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FcBCG6rCutL6Fiwxdbjge%2Fselecionar_queue.png?alt=media&amp;token=524b3585-4467-47c1-ba8e-afea07876a07" alt=""><figcaption></figcaption></figure>

### 4. Connect the Queue success output to the next node in the flow

After saving the queue settings, connect its **Success** output to the component **Global Variables**.

In this example, we will use a global variable to **make it easier to identify and reuse the data returned by the Queue Distributor** in the next steps of the flow. That way, instead of using the full expression generated directly by the component, we can assign this value to a variable with a simpler and easier-to-identify name.

{% hint style="warning" %}
The Global Variable does not **perform the distribution**. The user was already selected earlier by the **Queue Distributor**. In this example, it is used only to store the returned ID in a variable that is easy to identify and reuse in the next steps of the flow.
{% endhint %}

To add the global variables component:

* Click the icon **Add Component (Plus Icon)**, available in the flow's quick components menu.
* Then scroll down the component list to the section **Others**, click on it and then select the option **Define global variables**.
* Now you must connect the success output of the **Queue Distributor** to the new global variables component.
* After connecting the success output of the **Distributor** to the node of **Global Variables**, **twice** click on it to open the node settings.
* Add a global variable and enter in the value field the expression that returns the **User ID**, which in our example is returned by the key **key** of the **Queue Distributor**.

*Since in this example we are using a queue of the type **Users**, the Queue Distributor will return the information related to the users selected within the distribution queue.*

<table><thead><tr><th width="210.6895751953125">Global Variable Key</th><th>Value</th></tr></thead><tbody><tr><td><code>id_user</code></td><td>Expression with the user ID returned by the Queue Distributor</td></tr></tbody></table>

{% hint style="info" %}
In our example, the expression that returns the **user ID** returned by the Distributor is the key named "**key**" below:

```
{{$data?.queueDistributor_0b35ul2nyd8t?.key}}
```

:warning: Remember to change the **component ID** according to your flow.
{% endhint %}

* Now just save by clicking the "Save" button in the bottom-right corner of the screen.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2Fsy21LZplOWQWvMwvyjlG%2F%5BDOCS%5D%20-%20Definindo%20as%20Vari%C3%A1veis%20Globais.gif?alt=media&amp;token=05e7cd7e-3673-48e3-9470-cde967f53e1c" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
To better understand this step, we recommend consulting the documentation about [**How to use Variables and Expressions in Flows**](https://docs.hablla.com/hablla-docs-en/automation-flows/using-variables.md#o-que-sao-variaveis-na-hablla) and also the documentation for the component [**Define Global Variables**](https://docs.hablla.com/hablla-docs-en/automation-flows/all-components/others/set-global-variables.md).
{% endhint %}

### 5. Add and configure the Transfer component

Now that the user ID selected by the queue is stored in a **Global Variable**, the next step is to use this information to carry out the transfer of the service, and to do that, simply follow the steps below.

#### Add the Transfer component

* In the flow's quick components menu, click the icon **Hablla** to view the available components.
* Locate the option **Transfer**, click on it and drag the component into the flow.
* Then connect the success output of the component **Define global variables** to the component **Transfer**.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FuMnOXMcQCJF4ASf3RKvJ%2F%5BDOCS%5D%20-%20Como%20adicionar%20componente%20de%20transferencia.gif?alt=media&amp;token=a3983d1e-c0c4-454c-8158-f9d4317743ea" alt=""><figcaption></figcaption></figure>

Now that we've added the Transfer component to the flow, we need to configure it so it works properly. The next steps will show you how to make this configuration and apply the changes to your flow.

#### Configure the destination department

* **Double-click** on the component **Transfer** to open its settings.
* First, select the **Department** to which the service should be transferred.

{% hint style="warning" %}
**Important:** the users registered in your Distribution Queue must also **be part of the selected department** in the Transfer component.

If the user returned by the queue does not belong to the defined department, the service will not be directed to them. In this scenario, the service can be routed to the department's service queue or distributed to another user if that department has an active overflow algorithm.
{% endhint %}

#### Configure the user using an expression

After defining the department, configure the field **User** to use the ID previously stored in the Global Variable.

By default, this field lets you directly select one of the users registered in your workspace. Since we want to dynamically use the user selected by the Distribution Queue, it will be necessary to change the field to the mode **Expression**.

To do this:

1. Hover over the field title **User**.
2. On the right side of this field, locate and click the option **Expression**.
3. After clicking, the field will be unlocked to receive an expression.

Now, enter the expression corresponding to the Global Variable created earlier, which in our example is represented by the expression below:

```
{{$data?.id_user}}
```

After finishing the settings, click on **Save**.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FmId9VN9rrNyg6jlTRioW%2F%5BDOCS%5D%20-%20Como%20configurar%20componente%20de%20transferencia%20(1).gif?alt=media&amp;token=54f91e19-40c1-434c-acef-b2eb0330988d" alt=""><figcaption></figcaption></figure>

Finally, at this stage, we have finished configuring our example flow and it will follow this sequence:

```mermaid
flowchart LR
    A["WhatsApp Inbound"] --> B["Queue Distributor"]
    B --> C["Global Variables"]
    C --> D["Service Transfer"]
```

### 6. Publish and activate the flow

With all the components configured and connected, the next step is **publish the changes** made to the flow. To do this, simply follow the steps below:

* Click the **Publish**. A confirmation window will be displayed; confirm the publication to apply the changes.
* After publishing, also check whether the flow is **Active** by checking whether the switch to the right of the "publish" button is on or off. If it is inactive, click the activation switch to enable it.

{% hint style="warning" %}
**Important:** publishing and activating are different actions. In addition to publishing the changes made, make sure the flow is **Active**. If it is inactive, the flow will not run.
{% endhint %}

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FJYj4kmEaRLRfyLyTuhm9%2F%5BDOCS%5D%20-%20Como%20Publicar%20um%20Fluxo.gif?alt=media&amp;token=67b30a68-a84d-4df2-9be4-f18349996ab5" alt=""><figcaption></figcaption></figure>

### 7. Test your Distribution Queue

Now with the flow **published** and **active**, you can now test how your **Distribution Queue**.

Since in this example we use a **WhatsApp Inbound**WhatsApp Inbound **WhatsApp Inbound**.

, to test it, just send a message to the number configured in the component

```mermaid
flowchart LR
    A["Message received"] --> C["Queue Distributor"]
    C --> D["Global Variable"]
    D --> E["Service Transfer"]
```

During execution, when the flow passes through the **Queue Distributor**, it will automatically select a user according to the configured queue and algorithm. The selected user's ID will be stored in the Global Variable and used by the component of **Transfer** to direct the service.

**All set!** From now on, whenever a service passes through this flow, the Distribution Queue will be triggered and the service can be automatically transferred to the selected user, respecting the configured distribution rules.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hablla.com/hablla-docs-en/automation-flows/flow-management/how-to-use-distribution-queues-in-a-flow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
