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

# Generate a Flow with AI

> Describe your voice agent in plain language and let AI build the flow for you.

# Generate a Flow with AI

The AI generator uses Claude (claude-sonnet-4-6) with an `edit_flow` tool to build or modify Voiceblox flows from natural language descriptions.

## How to use it

1. Click the **AI** button in the top toolbar
2. Describe the agent you want to build in plain language
3. The AI generates a set of operations and applies them to the canvas

## How it works

The system prompt is dynamically built from `nodeTemplates.ts` and `connectionRules.ts`, so the AI always has an up-to-date understanding of the available nodes and valid connections.

When you submit a message, the AI either:

* Calls `ask_user` to surface a clarifying question (response: `{ done: false, message }`)
* Calls `edit_flow` to produce a list of operations (response: `{ done: true, operations[], versionName }`)

The operations are validated against the graph's topology before being applied. If validation fails, the AI retries up to 3 times with the error feedback.

## Operation types

| Operation     | What it does                           |
| ------------- | -------------------------------------- |
| `add_node`    | Adds a new node with all parameters    |
| `update_node` | Updates parameters on an existing node |
| `remove_node` | Deletes a node and all its edges       |
| `add_edge`    | Connects two nodes                     |
| `remove_edge` | Removes a connection                   |

## Example prompts

```
Build a customer support agent for a SaaS product with:
- A greeting
- A triage question (billing vs technical support)
- Two branches routing to different specialists
```

```
Add a web search tool to the existing flow so the agent can
look up real-time product pricing.
```

```
Change the opening message to be more friendly and casual.
```

## Requirements

* The builder LLM key for your `BUILDER_LLM_PROVIDER` (`BUILDER_LLM_ANTHROPIC_API_KEY` or `BUILDER_LLM_GEMINI_API_KEY`) must be set in `.env.local`

## Tips

* Be specific about the conversation structure (number of steps, branch conditions)
* You can ask the AI to modify only part of an existing flow
* If the result isn't right, describe what's wrong and ask it to fix it

See [Prompting Tips](/ai-generation/prompting-tips) for more examples.
