# Modal

Modal action blocks allow you to send a form to the interacting user. Modals are especially useful for systems like modmail or ticket system.&#x20;

<figure><img src="https://1776429820-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6SxgQmtmSr2YrbDKvwZ%2Fuploads%2FZkukYIShwZtHyscuz8Cu%2Fimage.png?alt=media&#x26;token=ffcd8511-fd5a-4f83-8213-1232f41fb2ec" alt=""><figcaption><p>With a modal, users using your command will experience a form like this.</p></figcaption></figure>

To start creating your modal, you can place a modal action block in any builder. Modal blocks can **only** be placed after an interaction, where a user has interacted with an event of command, such as:

1. When a command has been run (modal blocks will not work at the start of an event); or
2. When a trigger (e.g., button or select menu) as been used.

Modal blocks don’t need to be placed directly after an interaction. You can insert other blocks, such as a condition block, in between. However, if you place an action block (for example, a send message block) immediately after an interaction, the modal will not function.

## Creating your Modal

Every modal block comes with access to our Modal Builder. After selecting a modal block, simply press the **Modal Builder** button to begin creating your form. Within the builder, you can adjust your modal’s settings and preview a live representation of how it will appear in Discord.

<div align="center" data-full-width="false"><figure><img src="https://1776429820-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6SxgQmtmSr2YrbDKvwZ%2Fuploads%2FwKVzfRxzMq2upN7jHxt0%2FModal%20Builder.PNG?alt=media&#x26;token=8689f676-94b1-4bf6-af60-bf1cb0b6df73" alt=""><figcaption></figcaption></figure></div>

<figure><img src="https://1776429820-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6SxgQmtmSr2YrbDKvwZ%2Fuploads%2Fwq3231PWDWLpOxPW5S7O%2FInside%20Modal%20Builder.PNG?alt=media&#x26;token=d8ce2893-3d92-4ccf-aae2-3c3b4171999b" alt=""><figcaption></figcaption></figure>

For each modal you create, you **must** enter a title, custom ID and at least one label. As shown in the example above, a modal title will appear at the top of the form, where each label has eight customizable options.&#x20;

{% hint style="info" %}
For each modal, only five questions can be created, as per Discord limitations.
{% endhint %}

## Custom IDs & Field Identifiers

As mentioned, for every modal you must enter a custom ID. Custom IDs are a way to differentiate your current modal against other modals you may have in your builder. This is essential, as you may wish to use a modal variable to refer back to a user's answer.

Modal variables are a variable specific to each modal you create, and they can be used for referring to a user's answer to any field/question. Using the example image above, you can view the modal variable called `{modal_he74anu04dc_1}`. If I used that variable in my builder, it will return the answer a user has given for the question.

Field identifiers, similar to custom IDs, differentiate a modal's fields/questions. For example, a modal with multiple questions will need numerous unique field identifiers so that you can refer to a user's answer to one, or more, questions.&#x20;

<figure><img src="https://1776429820-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd6SxgQmtmSr2YrbDKvwZ%2Fuploads%2Fbgx8BD0AMBjRnzbBZQ9Z%2FModal%20Field%20Example.PNG?alt=media&#x26;token=76c3c6a6-707f-47af-946b-d845fb4795c7" alt=""><figcaption></figcaption></figure>

In the example above, the field identifiers `1` has been used to represent the question number. With this identifier, I can use `{modal_he74anu04dc_1}` to return the user's answer to the field/question.

## Creating Fields

Fields are your questions; for each field you create, you create a new question. With each field, you will have eight customizable options, allowing you to create intricate questions. However, every question requires you to enter a label, type and field identifier.

Labels are simply the question title, and the field type will distinguish whether you would like a short answer or a long answer. These are all you require to successfully create a modal question! However, the other optional components will let you customize your question a bit more.

### Optional Components

These components are entirely optional, and are not required to be filled in when creating a new field.

<table><thead><tr><th width="179">Component</th><th>Description</th></tr></thead><tbody><tr><td>Placeholder</td><td>Text visible before an answer has been given; usually added for guidance.</td></tr><tr><td>Minimum Length</td><td>Set a minimum number of characters that must be entered.</td></tr><tr><td>Maximum Length</td><td>Set the maximum amount of characters a user can use in their answer.</td></tr><tr><td>Required</td><td>Toggle whether the question must be answered or not.</td></tr><tr><td>Default Value</td><td>Set a default answer for a question. These can be edited by the user.</td></tr></tbody></table>

#### Placeholders vs Default Values

Placeholders are only visible when a user has not yet entered an answer. These can be used to aid a user into providing an appropriate answer, or to explain the question further.&#x20;

However, default values are where you would automatically answer the question for the user. These values can be edited, but will be useful for pre-answering a question or starting off an answer.
