# About Automatic Connection of Free Operator to New Dialog

Automatic connection of free operator allows automatically distributing new dialogs to free operators without manual intervention. This ensures quick response to client requests and efficient use of operator resources.

---

## Context and Problem

In many cases, operators need to be quickly connected to new dialogs:
- Large number of incoming requests requires quick processing
- Manual connection takes a lot of time
- Fair load distribution between operators is needed
- Handling situations when there are no free operators

Automatic connection solves this task by allowing the system to automatically distribute dialogs to free operators by various criteria.

---

## Key Concepts

### Configuration in Scenario

For automatic connection, you need to:
1. Add action block `operator_panel__connect_to_operator_with_msg`
2. Fill JSON configuration with `auto_connect_operator: true`
3. Add `limit` event to handle situations when there are no free operators

### Configuration in Operator Panel

To activate automatic connection, you need to:
1. Go to **Menu → Operator Panel - Settings → Settings**
2. Find **"Automatic Connection of Free Operator to New Dialog"**
3. Activate the setting

After activation, the **"In Queue"** folder appears, where dialogs waiting for operator connection are displayed.

---

## Approach Options

### Automatic Connection vs Manual Connection

**Automatic Connection:**
- ✅ Pros: Speed, fair distribution, automation
- ❌ Cons: Less control over distribution

**Manual Connection:**
- ✅ Pros: Full control, ability to choose operator
- ❌ Cons: Slowness, requires manual intervention

**Why We Use Automatic Connection:**
Automatic connection ensures quick response to client requests and efficient use of operator resources.

### Waiting Queue

If you need to add a waiting queue, you can use the `status: "queue"` parameter in JSON configuration. This adds the dialog to the waiting queue, even if there are free operators.

---

## Adopted Solutions

### Handling Situation of No Free Operators

The `limit` event is added to handle situations when there are no free operators. In this case, the user is redirected by the `limit` event, where there can be:
- Waiting message
- Sending to waiting queue
- Other handling options

### Auto-Distribution Order

The auto-distribution order is described in the operator panel documentation and considers:
- Operator status (online)
- Dialog limits per channel and general
- Automatic distribution method
- Number of operator's current dialogs

---

## Implications for Users and Implementation

### For Integrators

When configuring automatic connection, it's important to:

1. **Configure scenario** — add action block with `auto_connect_operator: true`
2. **Add limit event** — to handle situations without free operators
3. **Activate in operator panel** — enable automatic connection settings
4. **Configure queue** — if waiting queue is needed

### Common Errors

**Error:** Dialogs are not connected automatically  
**Problem:** Settings are not activated in operator panel or `auto_connect_operator: true` is not specified  
**Solution:** Check settings in operator panel and JSON configuration

**Error:** User does not receive message when operators are unavailable  
**Problem:** `limit` event is not added to handle the situation  
**Solution:** Add `limit` event with message or sending to queue

**Error:** Dialogs do not enter queue  
**Problem:** `status: "queue"` is not specified or settings are not activated  
**Solution:** Add `status: "queue"` in JSON configuration or activate settings

---

## Usage Examples

### Basic Configuration

```json
{
  "auto_connect_operator": true
}
```

### Configuration with Queue

```json
{
  "auto_connect_operator": true,
  "status": "queue"
}
```

### Full Configuration

```json
{
  "auto_connect_operator": true,
  "subject_alias": "support",
  "status": "queue"
}
```

---

## Related Documents

- **Explanation:** [Auto-Distribution of Dialogs](/en/operatorline/explanation/auto-distribute-dialogs.md) — detailed information about auto-distribution
- **Explanation:** [Redistribution of Chats from Operator](/en/operatorline/explanation/redistribute-chats-from-operator.md) — redistribution in case of problems

