# Action Jail Editor Sections

The Action Jail action creation/editing wizard consists of five sections (accordions). Each section is responsible for a specific aspect of the action and has a direct link to how the action is displayed in the Scenario Builder.

## Editing code, JSON, and documentation

When you open **Implementation Code**, **JSON Configuration**, or **Documentation**, the text is edited in the **lower panel** of the editor. The upper area keeps the section title, hints, and actions (including AI generation). This makes long code easier to work with: the mouse wheel scrolls the editor content instead of the whole page.

On the **Implementation Code** section, the lower panel header (next to AI generation) includes **Open code in fullscreen**. It opens the same code in a larger window; changes stay in sync with the lower panel. **JSON Configuration** and **Documentation** do not have this button — text is edited only in the lower panel.

On sections without a text editor — **Basic Information**, **UI Schema**, and **Testing** — the lower panel is hidden and the form uses the full editor height. In the new-action wizard, the lower panel appears on the code, JSON, and documentation steps; on form-only steps it stays hidden.

## 1. Action Information

**What to fill in:**
- **Display name** — the name users see when selecting the action in a scenario.
- **System ID** — unique identifier (`action_*`), cannot be changed after creation.
- **Description** — short explanation of the action's purpose.
- **Group** — category for grouping actions in the library.

**Where it appears in Scenario Builder:**
- Display name — in the action list when adding an Action block, in the selected action's title.
- Group — in the "Select action group" filter in the Action block sidebar.

---

## 2. Implementation Code

**What to fill in:**
- JavaScript function that executes the action logic.
- Function must start with `action_` and be exported via `module.exports`.
- Use `this.getCurrentNodeParamsJSON()` to get parameters from the JSON config.
- Use `this.getCurrentConstJSON()` to access scenario constants.

**Where it appears in Scenario Builder:**
- Code is not displayed in the UI — it runs on the backend when the scenario passes through the Action block.

**AI generation:** "Quick Generate" / "Generate Code" button — generates a code draft from a description. Requires a configured OpenAI token for the selected process (bot).

**Fullscreen editing:** Available on this section only — see [Editing code, JSON, and documentation](#editing-code-json-and-documentation) above.

---

## 3. JSON Configuration

**What to fill in:**
- Parameter schema: `parameters` — array of objects with `name`, `type`, `required`, `description`, `defaultValue`, etc.
- `ui` — field grouping for the form (accordion, groups).
- `json_example` — example of valid JSON.
- `events_schema` — possible `return` values for routing.

**Where it appears in Scenario Builder:**
- In the Action block in **Form** mode — each parameter from `parameters` becomes a form field (input, select, textarea, etc.).
- Groups from `ui.groups` are displayed as accordion sections.
- In **JSON** mode — user enters values directly in JSON; structure comes from `parameters` and `json_example`.

**AI generation:** "Generate from Code" — analyzes code and extracts parameters from `getCurrentNodeParamsJSON()` into a JSON schema.

---

## 4. UI Schema

**What to fill in:**
- Same parameters as in the JSON config, but as a visual list of fields.
- For each field: key, type, label, placeholder, required, description, default, validation, options, dataSource, etc.

**Where it appears in Scenario Builder:**
- The UI schema defines how fields are displayed in Form mode:
  - field type: text, number, on/off switch, dropdown list;
  - label, placeholder, hints;
  - grouping (accordion) with `ui.groups`.

**Relationship:** The UI schema is a representation of `json_config.parameters` and `json_config.ui`. Changes in one place are synchronized with the other.

---

## 5. Documentation

**What to fill in:**
- Markdown text: action description, parameters, usage example, return values.

**Where it appears in Scenario Builder:**
- Documentation is not displayed directly in the Action block.
- It is used in reference guides, hints, and for integrators (Actions Reference).

**AI generation:** "Generate Documentation" — creates Markdown from the action name, code, and parameters.

---

## Action Jail Fields → Scenario Builder (Form mode) Mapping

| Action Jail field      | Display in Scenario Builder (Form)                         |
|------------------------|------------------------------------------------------------|
| Display name           | Selected action name in the Action block                   |
| Group                  | "Select action group" filter in sidebar                    |
| Description            | Hints, reference guides                                   |
| `parameters`           | Form fields (input, select, textarea, etc.)                |
| `parameters[].label`   | Field label                                               |
| `parameters[].placeholder` | Input placeholder                                    |
| `parameters[].type`    | Widget type (string → text, number → number, boolean → switch) |
| `ui.groups`            | Accordion sections in the parameters form                 |
| `json_example`         | Default values on first open                               |

---

## Related instructions

- [How Action Jail Data Flows to Scenario Builder](/en/actionjail/explanation/action-to-scenario-flow.md)
- [How to create a custom action](/en/actionjail/how-to/create-custom-action.md)
- [How to create and manage actions](/en/actionjail/how-to/admin-manage-actions.md)
- [AI generator setup](/en/actionjail/how-to/admin-ai-generator-setup.md)
- [Actions Reference](/en/actionjail/reference/actions-reference.md)
