> 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/hablla/settings/distribution-queue.md).

# Distribution queue

The **Distribution Queues** allow automating the selection of an item from a previously configured set, using distribution rules defined by different algorithms.

Currently, this feature can be used in **Automation Flows** within your workspace in Hablla, allowing an item to be selected automatically from the queue during flow execution.

These queues can be used in several scenarios within Hablla, such as distributing support interactions among agents, automatically assigning the owner of a card, routing between organizations, selecting registered people, or any other process that needs to choose an item automatically and in a standardized way.

Each distribution queue created is composed of the following components:&#x20;

1. #### Queue Item Set

   *The set of items will be **the available options** so that the distribution algorithm can select one of these items.*
2. #### Distribution Algorithm

   *The algorithm is responsible for determining which will be the next item selected whenever the queue is used.*&#x20;

In this way, Distribution Queues make processes more flexible, eliminate manual distributions, and ensure that the selection logic is applied consistently across your operation.

## What is the Overflow Algorithm

The **Overflow Algorithm** is responsible for defining the logic used by the system to select the next item in a queue. Whenever a distribution queue is triggered within a flow, the system analyzes the available items and uses the configured algorithm to determine which one will be selected in that execution.

### Overflow Algorithms

Currently, the **overflow algorithm** has 6 available options, namely: Sequential Queue, Fewest Interactions Today, Fewest Open Interactions, Fewest Open Interactions with Limit, Random, and Weight by Agents. Below, we explain a little about each one.

### Sequential Queue

The sequential queue distributes items following a sequence among the items registered in the queue. For example, considering a queue with the options:

1. Ana
2. Bruno
3. Carlos

The executions will be distributed following the order:

```mermaid
---
config:
  theme: base
  themeVariables:
    primaryColor: "#893fff"
    primaryBorderColor: "#893fff"
    primaryTextColor: "#FFFFFF"
    lineColor: "#0057B8"
---
flowchart LR
    A([Ana]) --> B([Bruno])
    B --> C([Carlos])
    C --> A
```

This algorithm is recommended when you want to perform a uniform distribution following a continuous order.

### Fewest Interactions Today

Responsible for selecting the user who has the **fewest interactions received today**. In this algorithm, before the distribution is made, Hablla compares the number of interactions each user in the queue has received and selects the one with the lowest number.

This model helps balance distribution throughout the day.

### Fewest Open Interactions

Responsible for considering the number of **currently open interactions** for each user. In this way, the next interaction is directed to the user who has the fewest ongoing interactions at the moment the queue with this algorithm is triggered.

This algorithm is useful for balancing the team's current workload.

### Fewest Open Interactions with Limit

{% hint style="info" %}
**Important:** this algorithm works **only for users who use a Custom Permission with a defined interaction limit**. Users who use the platform's standard permissions will not have the interaction limit considered during distribution.
{% endhint %}

It works similarly to the option **Fewest Open Interactions**, but it also considers the **maximum allowed number of interactions** for each user.

Before making the distribution, Hablla checks which users currently have the fewest open interactions when the queue is executed and then validates whether they have not yet reached the limit configured in the permission. If a user has already reached that limit, they stop participating in the distribution until they once again have capacity to receive new interactions.

The interaction limit per user is defined through **Permissions**, in the configuration of the permission that will be assigned to the user.

To learn how to configure this limit, consult the documentation for **Permissions** [by clicking here](/hablla-docs-en/hablla/settings/permissions.md#atendimentos).&#x20;

### Random

Selects one of the items registered in the queue at random whenever the queue is used. In this algorithm, all participating items have the same probability of being selected, without considering any distribution criteria.

This algorithm is recommended for scenarios where there is no need to maintain a sequence or balance the workload among participants, with the choice made randomly at each execution.

### Weight by Agent

{% hint style="warning" %}
To use this algorithm, it is necessary to configure the **priority level** for each user participating in the queue. If no weight is configured, the distribution may not occur as expected.&#x20;
{% endhint %}

Allows distributing the queue items proportionally among users, using a **weight** configured for each one of them. The higher the weight assigned to a user, the more frequently they will be selected during distributions.&#x20;

This algorithm is recommended for teams in which some users have greater service capacity or need to receive a larger volume of requests than others.

#### Example

<table><thead><tr><th width="236.0689697265625">Users</th><th width="243.793212890625" align="right">Priority Level</th></tr></thead><tbody><tr><td>Ana</td><td align="right">1</td></tr><tr><td>Bruno</td><td align="right">2</td></tr><tr><td>Carlos</td><td align="right">1</td></tr></tbody></table>

In this scenario, the user **Bruno** tends to receive approximately twice as many distributions as Ana and Carlos, while Ana and Carlos receive distributions in the same proportion.

{% hint style="info" icon="triangle-exclamation" %}
To learn how to perform this configuration, consult the practical guide in our documentation to learn how to configure users' service priority levels [by clicking here. ↗️](/hablla-docs-en/hablla/settings/permissions.md#atendimentos)
{% endhint %}

## How to Configure Distribution Queues

To create your own distribution queues, you will first need to have an **administrator** user to access your workspace settings.

{% stepper %}
{% step %}

### Access your Workspace settings

After accessing your [studio](https://studio.hablla.com/), to access the workspace settings, click the **gear** icon in the **upper-right corner** of your screen.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2Fr97rUYr60bo61u6Xr7Ou%2Fworkspace.png?alt=media&amp;token=e0122a72-2ca6-4f2e-90d9-77baa1f062ca" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Access the Distribution Queue settings

When accessing your workspace settings, locate the option "**Distribution Queues**" in the left-side menu on the left side of your screen and click it.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FtYZL1AgWPyC492cGf0f5%2Fqueue.png?alt=media&amp;token=d50554cc-4414-4b55-8ddf-599661fd9303" alt=""><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Create a new distribution queue

When accessing the settings of the **distribution queues**, you probably won't have a queue created yet. To create a new queue, simply click the "**+ New Distribution Queue**" button on the upper-right side of the new screen that will open.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FHtgxmHa8evHHFUKzR2kE%2Fnew_queue%20(1).png?alt=media&amp;token=552d788e-5a04-4fc4-9f52-335f9ff2950e" alt=""><figcaption></figcaption></figure>

After clicking, a new queue configuration screen will appear for you to create, with 3 fields to define: **Queue Display Name**, **Overflow Algorithm**, and **Queue Type**.

{% endstep %}

{% step %}

### **Define your Queue's Display Name**

At this step, you should create a display name for your distribution queue.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2FC9EahV1pjGvL5LWxwcLs%2Fnome_fila.png?alt=media&amp;token=ee437cea-1c9d-4c2d-932d-de2551d36e71" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Define your Queue's Overflow Algorithm**

Now you need to select one of the **Overflow Algorithms** available options to define the type of algorithm that will be used for your new queue.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2F9oQ4gipP46ahyDTcimId%2Falgoritmo_fila.png?alt=media&amp;token=b6009e2c-c348-4599-a149-2c3f128655a8" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### **Define your Queue Type**

Here you should select one of the **Queue Types** available to define what type your new distribution queue will be.

<figure><img src="https://1592162275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrmxWrIrMauHcIrsuqfGq%2Fuploads%2F8Pac95c7GSoI9t7IsOa6%2Ftipo_fila.png?alt=media&amp;token=b16aca59-68f9-43eb-8fc6-a9e263e31cd3" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Save the settings

Now just click the  <mark style="background-color:$primary;">**Save**</mark> button to apply your Distribution Queue settings.
{% endstep %}
{% endstepper %}

The **Distribution Queues** offer a simple and flexible way to automate item selection within Hablla, allowing distribution to follow consistent rules adapted to your operation's needs.

By correctly choosing the **Queue Type** and the **Overflow Algorithm**, it is possible to distribute interactions, assign owners, perform routing, and automate various processes without the need for manual decisions during flow execution.

After creating and configuring your distribution queue, it will be available for use in the **Automation Flows** of your workspace, and can be reused whenever necessary.

{% hint style="success" %}
**Next step:** Now that your queue is configured, consult the documentation for **Automation Flows** to learn how to use a Distribution Queue during the execution of a flow, [by clicking here ↗️](/hablla-docs-en/automation-flows/flow-management/how-to-use-distribution-queues-in-a-flow.md)
{% endhint %}


---

# 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 dynamically by asking a question.

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

```
GET https://docs.hablla.com/hablla-docs-en/hablla/settings/distribution-queue.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
