> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Flows & Dialogs

> Build conversation flows for virtual assistants.

## Overview

Dialog flows define how your virtual assistant handles conversations:

* **Intents** — What users want to accomplish
* **Entities** — Information extracted from messages
* **Dialogs** — Conversation logic and responses
* **Transitions** — How conversations move between states

***

## Dialog Types

### Standard Dialog

Structured conversation flow for specific tasks:

```
[User: Check order status]
         │
         ▼
[Collect Order Number]
         │
         ▼
[Validate Order Number]
         │
    ┌────┴────┐
    ▼         ▼
[Valid]   [Invalid]
    │         │
    ▼         ▼
[Fetch    [Request
 Status]   Again]
    │
    ▼
[Deliver Response]
```

### Agent Flow

Complex flows with AI agent capabilities:

```yaml theme={null}
Agent Flow: Research Assistant
Capabilities:
  - search_web
  - analyze_documents
  - summarize_findings
Behavior: |
  Research the user's question using available tools.
  Synthesize findings into a comprehensive answer.
  Cite sources when providing information.
```

### Sub-Dialog

Reusable dialog components:

```yaml theme={null}
Sub-Dialog: Collect Address
Entities required:
  - street_address
  - city
  - state
  - zip_code
Validation: address_verification_api
Reusable: true
```

***

## Building Dialogs

### Dialog Builder

Visual drag-and-drop builder:

| Node Type | Purpose |
| - | - |
| **Message** | Display text, cards, or media |
| **Prompt** | Collect user input |
| **Condition** | Branch based on conditions |
| **API Call** | Execute integrations |
| **Script** | Run custom code |
| **Agent** | Invoke AI agent |
| **Transfer** | Hand off to human |

### Node Configuration

Message node example:

```yaml theme={null}
Node: Welcome Message
Type: message
Content:
  text: "Hello! I'm your order assistant. How can I help you today?"
  quick_replies:
    - "Check order status"
    - "Start a return"
    - "Track my package"
Transitions:
  - intent: check_order → order_status_flow
  - intent: start_return → return_flow
  - default → fallback
```

### Transitions

Define conversation flow:

| Transition Type | Description |
| - | - |
| **Intent** | Move based on detected intent |
| **Entity** | Move based on extracted entity |
| **Condition** | Move based on variable value |
| **Default** | Fallback when no match |
| **Error** | Handle errors gracefully |

***

## Entity Management

### Entity Types

| Type | Use Case | Example |
| - | - | - |
| **Built-in** | Common data types | Date, Number, Email |
| **List** | Defined options | Product names, sizes |
| **Regex** | Pattern matching | Order ID: ORD-\d6 |
| **Composite** | Grouped entities | Full address |

### Entity Extraction

Configure extraction:

```yaml theme={null}
Entity: OrderNumber
Type: regex
Pattern: "(?:order|ORD)?[-#]?(\d{5,8})"
Validation: |
  length >= 5 AND length <= 8
  starts_with_digit
Prompts:
  initial: "What's your order number?"
  retry: "I didn't catch that. Order numbers are usually 5-8 digits."
Max retries: 3
```

### Entity Disambiguation

Handle ambiguous inputs:

```yaml theme={null}
Disambiguation: Size
Values: ["small", "medium", "large"]
On ambiguity:
  type: confirm
  message: "Did you mean {{matched_value}}?"
On multiple:
  type: select
  message: "Which size? Small, medium, or large?"
```

***

## Context Management

### Context Variables

Store and use conversation context:

```javascript theme={null}
// Set context
context.session.orderNumber = "12345"
context.session.customerTier = "premium"

// Use in messages
"Your order {{context.session.orderNumber}} is being processed."

// Use in conditions
if (context.session.customerTier === "premium") {
  // Premium customer handling
}
```

### Variable Scopes

| Scope | Lifetime | Use Case |
| - | - | - |
| **Turn** | Single turn | Temporary processing |
| **Session** | Conversation | Order details, selections |
| **User** | Across sessions | Preferences, history |
| **Global** | All users | Configuration, flags |

***

## Interruption Handling

### Configuration

Handle topic switches:

```yaml theme={null}
Interruption Handling:
  allow_interruptions: true
  hold_and_resume:
    enabled: true
    message: "No problem, let me help with that first."
  implicit_confirmation: true
  max_depth: 3
```

### Scenarios

| Scenario | Handling |
| - | - |
| **New intent** | Hold current, start new |
| **Clarification** | Handle inline, resume |
| **Cancel** | Confirm and exit |
| **Go back** | Return to previous step |

***

## Testing

### Conversation Testing

Test dialog flows:

1. Open **Test** panel
2. Enter test utterances
3. Verify intent detection
4. Check entity extraction
5. Validate flow navigation
6. Review responses

### Batch Testing

Run test suites:

```yaml theme={null}
Test Suite: Order Status Flow
Tests:
  - name: "Valid order number"
    utterance: "Where is my order 123456?"
    expected:
      intent: check_order_status
      entities:
        order_number: "123456"
      response_contains: "order status"

  - name: "Missing order number"
    utterance: "Where is my order?"
    expected:
      intent: check_order_status
      next_prompt: "order number"
```

### Debug Mode

Enable detailed debugging:

* Intent confidence scores
* Entity extraction details
* Flow transitions
* Variable values
* API call results

***

## Best Practices

### Dialog Design

* Keep flows focused on single tasks
* Use sub-dialogs for reusable components
* Handle errors gracefully
* Provide clear escape paths
* Test edge cases thoroughly

### Intent Training

* Add 15-25 utterances per intent
* Include variations and typos
* Use real customer language
* Regularly review misclassifications
* Avoid overlapping intents

### Conversation UX

* Confirm understanding before actions
* Provide clear options when ambiguous
* Keep messages concise
* Use quick replies for common paths
* Allow natural conversation flow

***

## Related

* [Automation AI](https://koreai.mintlify.site/ai-for-service/automationai.md)
* [Channels](https://koreai.mintlify.site/ai-for-service/channels.md)
* [Integrations](https://koreai.mintlify.site/ai-for-service/integrations)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.