# AI Builder Assistant

The AI ​​Assistant is a built-in helper within the bot builder that understands your bot's structure and can edit it directly in real-time via an SSE stream.

## Opening the Widget

Click the **AI Assistant** button (bot icon) in the top-left toolbar of the builder. The chat panel will appear on the right.

## Capabilities

- **Builder Questions** — ask about block types, settings, or flow logic
- **Flow Analysis** — the assistant sees all nodes and blocks in your current session
- **Bot Editing** — the AI ​​can add, modify, or delete nodes and blocks directly on the canvas
- **Auto-layout** — arrange nodes on the grid using a command like "organize the flow"
- **Node Highlighting** — the AI ​​can highlight specific nodes while explaining

## Workflow: Plan → Confirmation

Before making any edits, the AI ​​will **propose a plan** with numbered steps:

1. Review the plan
2. Click **Confirm** — the AI ​​will execute the steps one by one
3. Click **Cancel** — no changes will be made

## Stopping

The **Stop** button (red square) cancels the current generation process.

## Clearing History

The refresh icon button in the chat header clears the conversation history. The AI ​​will start the conversation over.

## Funnel Analytics

The AI ​​can analyze at which steps users drop off and why. This provides specific recommendations for improving the scenario without the need to manually parse statistics.

### How to ask

Ask the AI ​​a question in natural language, for example:

- "Why aren't users registering?"
- "At which step do people leave the bot?"
- "Which commands are underperforming? Show me the stats."
- "Analyze the funnel and tell me what needs improvement."

The AI ​​will automatically:
1. Retrieve the current scenario flow
2. Load statistics for each command
3. Check the content of problematic commands
4. Provide specific recommendations: which text to change, which button to add, or where to create a connection

### Statistics field definitions

| Field | Description |
|---|---|
| **Views** | Number of times users accessed this command (total over all time) |
| **Average Time** | Average time (in seconds) from the command display to the user's next action |
| **Transitions** | Number of times users clicked a button or an automatic transition to the next step occurred |
| **Drop-offs** | Number of times a user accessed the command but did not proceed further |
| **Drop-off Rate** | Percentage of visits that did not result in a transition. A drop-off rate exceeding 50% for non-final steps warrants investigation |
| **Current users** | Number of users currently at this step who have not yet taken an action |
| **Final step** | Steps with no outgoing connections—the end of the scenario. A high drop-off rate here is normal |
| **Utility step** | Contains only logic blocks (database, API, variables, conditions). Users pass through automatically; high drop-off is normal |
| **User action required** | The step contains buttons or an input form—the user must click or type something. If `false`, the step merely notifies or automatically advances the user |

### What the AI ​​flags as a problem

Only steps meeting all the following criteria are flagged as problematic:
- **Non-final** — has outgoing connections by design
- **Non-utility** — contains messages for the user, not just logic
- **User action required** — requires clicking a button or entering text
- **Drop-off rate > 50%**

Notification steps without buttons have high drop-off by definition—the user reads the notification and moves on, or an automatic transition triggers. This is **normal**, not a problem.

Typical causes of actual drop-off:

- **No navigation button** — the user doesn't know what to do next
- **Unclear text** — the message doesn't explain the next step
- **Dead end** — the step leads nowhere
- **Input form without instructions** — the user doesn't know what to type
- **Many users "stuck"** — likely waiting for input but unsure how to provide it

### Applying recommendations

After analysis, the AI ​​will identify specific steps and suggest fixes. You can:

- Ask the AI ​​to implement the changes immediately: "Apply all recommendations"
- Select specific ones: "Fix only the 'Registration' command"
- Reject them and make the changes yourself

> **Important:** Statistics are aggregated from the moment the scenario was first published. A breakdown by period is not supported; the data reflects the bot's entire operational lifespan.

## Security

- Canvas editing is available only to authorized users
- The AI ​​does not perform destructive actions without explicit plan confirmation
- History is stored in the database and linked to the session