# Plain-text input element

Allows users to enter freeform text data into a single-line or multi-line field.

| | |
|---|---|
| **Type** | `plain_text_input` |
| **Available in** | Modals, Home tab |
| **Works in blocks** | [Input block](https://workstation.repzo.com/docs/developers/block-kit/blocks/input-block) |

## Usage

Use the plain-text input inside an [input block](https://workstation.repzo.com/docs/developers/block-kit/blocks/input-block), in a modal or the Home tab. The value isn't sent as it's typed: when the person submits the modal, your app receives it in the `view_submission` payload under `view.state.values[block_id][action_id]`:

```json
{ "call_summary": { "summary": { "type": "plain_text_input", "value": "Agreed on a 12-seat pilot starting in December." } } }
```

Before calling your app, Repzo checks that required inputs (input blocks without `optional: true`) are filled in and that the value respects `min_length` and `max_length` ("Must be at least 20 characters.", "Must be 2000 characters or fewer."). Problems are shown under the field and your app isn't called.

With `dispatch_action: true` on the input block, the element also sends a `block_actions` payload with the same `value` when the person presses Enter, or as they type, depending on `dispatch_action_config`.

## Fields

| Field | Type | Description | Required? |
|---|---|---|---|
| `type` | String | The type of element. In this case `type` is always `plain_text_input`. | Required |
| `action_id` | String | An identifier for the input value when the parent view is submitted. You can use this when you receive a `view_submission` payload to identify the value of the input element (`view.state.values[block_id][action_id]`). Should be unique among all other `action_id`s in the containing block. Maximum length is 255 characters. If you leave it out, Repzo generates one. | Optional |
| `initial_value` | String | The initial value in the plain-text input when it is loaded. | Optional |
| `multiline` | Boolean | Indicates whether the input will be a single line (`false`) or a larger textarea (`true`). Defaults to `false`. | Optional |
| `min_length` | Integer | The minimum length of input that the user must provide. If the user provides less, they will receive an error. Acceptable values for this field are between 0 and 3000, inclusive. | Optional |
| `max_length` | Integer | The maximum length of input that the user can provide. If the user provides more, they will receive an error. Acceptable values for this field are between 1 and 3000, inclusive. | Optional |
| `dispatch_action_config` | [Dispatch action configuration object](https://workstation.repzo.com/docs/developers/block-kit/objects/dispatch-action-configuration-object) | A dispatch configuration object that determines when during text input the element returns a `block_actions` payload. Only used when the parent input block sets `dispatch_action: true`. Defaults to `on_enter_pressed`. | Optional |
| `focus_on_load` | Boolean | Indicates whether the element will be set to auto focus within the view. Only one element can be set to `true`. Defaults to `false`. | Optional |
| `placeholder` | [Text object](https://workstation.repzo.com/docs/developers/block-kit/objects/text-object) | A `plain_text` only text object that defines the placeholder text shown in the plain-text input. Maximum length for the `text` in this field is 150 characters. | Optional |

> **How Repzo Chat differs from Slack**
>
> - Works in the Home tab as well as in modals.
> - In a message, an input block is shown as a disabled stand-in and the API returns a warning instead of refusing the message.
> - `focus_on_load` is applied on the web; the mobile app ignores it.

## Examples

### A multi-line input in a form

This example belongs in a modal view — the screenshot shows it in a modal.

```json
{
  "blocks": [
    {
      "type": "input",
      "block_id": "call_summary",
      "label": {
        "type": "plain_text",
        "text": "Call summary"
      },
      "element": {
        "type": "plain_text_input",
        "action_id": "summary",
        "multiline": true,
        "min_length": 20,
        "max_length": 2000,
        "placeholder": {
          "type": "plain_text",
          "text": "What was agreed, and what happens next?"
        }
      }
    }
  ]
}
```

### A quick-add field on the Home tab

With `dispatch_action`, pressing Enter sends `block_actions` right away — no submit button needed.

This example belongs in a Home tab view — the screenshot shows it in a modal.

```json
{
  "blocks": [
    {
      "type": "input",
      "block_id": "quick_task",
      "dispatch_action": true,
      "label": {
        "type": "plain_text",
        "text": "Add a follow-up task"
      },
      "element": {
        "type": "plain_text_input",
        "action_id": "task_title",
        "dispatch_action_config": {
          "trigger_actions_on": [
            "on_enter_pressed"
          ]
        },
        "placeholder": {
          "type": "plain_text",
          "text": "Call Contoso about the renewal"
        }
      }
    }
  ]
}
```

## Related

- [Block elements](https://workstation.repzo.com/docs/developers/block-kit/elements)
- [Block Kit overview](https://workstation.repzo.com/docs/developers/block-kit)
