# Schema Export and Import

The builder allows you to save the current scenario schema to a JSON file and load it back—either into the same bot or a different one. This feature is available only to platform administrators.

## Navigation Bar Buttons

Two icons are located next to the "Documentation" button in the builder's header:

- **CloudDownload (↓ cloud)** — exports the current schema to a JSON file and downloads it to your computer.
- **Upload (↑ arrow)** — opens a file picker to select a JSON file for import into the builder.

## Schema Export

Clicking the export button downloads a file named **{scenario_name}.json** to your computer.

The file contains:

```json
{
"schema_version": 1,
"name": "Scenario Name",
"exported_at": "2026-04-04T12:00:00.000Z",
"nodes": [ ... ]
}
```

The `nodes` field contains all nodes of the current scenario (including the start node). Edges (transitions) are not explicitly saved; they are automatically recalculated from button data upon loading.

## Schema Import

Clicking the import button opens a file selection dialog. Once a file is selected, an automatic check is performed.

### Validation

Before importing, the builder checks the following:

1. **JSON Syntax** — the file must contain valid JSON.
2. **Schema Structure** — the file must contain a nodes field with an array of nodes.
3. **Node Compatibility** — each node must contain the required fields (id, type, position, data) and a recognized type (start, command, trigger, auto_message, frame).
4. **Block Compatibility** — each block within a node must have a type supported by the current version of the builder. If the check fails, a dialog box appears with a specific error description. For example:

> "Unknown javascript block type in the 'Greeting' node. This scenario may have been created in a newer version of the builder and contains blocks that are not supported here."

### Selecting an Import Mode

If the file passes validation, a dialog opens with two options:

#### Replace current schema *(default)*

All nodes in the current scenario are deleted and replaced by the nodes from the file. This action can be undone using **Ctrl+Z**.

#### Add to current schema

Nodes from the file are added to the canvas alongside existing nodes. Note the following:

- **The start node from the file is skipped** — there can only be one start node on the canvas.
- The IDs of all added nodes are automatically recalculated to avoid conflicts with existing ones.
- Added nodes are placed below the existing ones on the canvas.

### Saving After Import

Once the import is confirmed, the schema is automatically saved as a draft after 1.5 seconds. To make the changes take effect for bot users, click **"Publish"**.

## Common Use Cases

- **Transferring a scenario** between bots or between test and production environments.
- **Backing up** a schema before making major changes.
- **Collaborative development** — exporting, sharing with a colleague, and adding to their schema.