# About Configuring Alias for Outgoing Dialog

When completing a dialog with an operator, you can configure an alias for different situations, such as chat closure by operator, completion by timeout, or closure by client. This allows controlling user behavior after dialog completion and ensuring correct transition to the next scenario steps.

---

## Context and Problem

In many cases, you need to control user behavior after dialog completion:
- Sending feedback after operator closes chat
- Message about timeout during inactivity
- Handling situation when connection could not be established
- Reaction to client closing chat

Configuring alias for outgoing dialog solves this task by allowing specifying where to redirect the user in different situations.

---

## Key Concepts

### Types of Dialog Completion Situations

**Chat closure by operator:**
- Operator closes chat manually
- User is redirected to the specified alias

**Completion by timeout:**
- Chat closes automatically due to inactivity
- User is redirected to the specified alias

**Failed connection:**
- Could not establish connection with operator
- User is redirected to the specified alias

**Closure by client:**
- Client closes chat independently
- User is redirected to the specified alias

### Configuration Methods

**Through constants:**
- `initiated_dialog_alias_chat_closed` — alias for closure by operator
- `initiated_dialog_alias_chat_closed_by_timeout` — alias for timeout

**Through action parameters:**
- `chat_closed_alias` — alias for closure by operator
- `chat_closed_by_timeout_alias` — alias for timeout
- `connection_timeout_alias` — alias for failed connection
- `chat_closed_by_client_alias` — alias for closure by client

---

## Approach Options

### Constants vs Action Parameters

**Constants:**
- ✅ Pros: Global settings for all dialogs
- ❌ Cons: Less flexibility for individual cases

**Action parameters:**
- ✅ Pros: Flexibility for individual cases
- ❌ Cons: Need to configure for each case

**Why we use both approaches:**
Constants provide global settings, and action parameters allow overriding them for individual cases.

---

## Adopted Solutions

### Settings Priority

Constants have priority over action parameters. If constants are configured, they will be used instead of action parameters.

### Fallback Mechanism

If constants are not configured, the user will be redirected by aliases that were set during the last connection to the operator. If the user has never contacted the operator, the system redirects them by alias `entry`.

---

## Implications for Users and Implementation

### For Integrators

When configuring alias, it's important to:

1. **Determine necessary situations** — which situations need to be handled
2. **Create alias blocks** — in the scenario for each situation
3. **Configure constants or parameters** — depending on needs
4. **Check fallback mechanism** — for users without settings

### Common Errors

**Error:** User is not redirected after chat closure  
**Problem:** Constants or action parameters are not configured  
**Solution:** Add constants or action parameters with correct aliases

**Error:** Wrong alias is used  
**Problem:** Constants have priority over action parameters  
**Solution:** Check constant settings and their priority

**Error:** User is redirected to non-existent alias  
**Problem:** Alias does not exist in the scenario  
**Solution:** Check presence of alias blocks in the scenario

---

## Usage Examples

### Configuration Through Constants

1. Go to the "Constants" section in the scenario
2. Add constants:
   - `initiated_dialog_alias_chat_closed` = "feedback"
   - `initiated_dialog_alias_chat_closed_by_timeout` = "timeout_message"

### Configuration Through Action Parameters

```json
{
  "auto_connect_operator": true,
  "chat_closed_alias": "feedback",
  "chat_closed_by_timeout_alias": "timeout_message",
  "connection_timeout_alias": "retry_connection",
  "chat_closed_by_client_alias": "goodbye"
}
```

---

## Related Documents

- **Explanation:** [Connecting Chat with Operator](/en/operatorline/explanation/connect-chat-to-operator.md) — configuring connection to operator

