Modals

Modals display form dialogs that collect structured user input. Modals are currently supported on Slack and Teams.

import {
  Modal,
  TextInput,
  DateInput,
  NumberInput,
  Select,
  ExternalSelect,
  RadioSelect,
  SelectOption,
} from "chat";

Top-level container for a form dialog. Open a modal from an onAction or onSlashCommand handler using event.openModal().

bot.onAction("open-form", async (event) => {
  await event.openModal(
    Modal({
      callbackId: "feedback",
      title: "Submit Feedback",
      submitLabel: "Send",
      children: [
        TextInput({ id: "comment", label: "Comment", multiline: true }),
      ],
    })
  );
});
PropTypeDefaultDescription
callbackId?string
Unique ID for routing to onModalSubmit/onModalClose handlers.
title?string
Modal title displayed in the header.
submitLabel?string"Submit"
Label for the submit button.
closeLabel?string"Cancel"
Label for the close/cancel button.
notifyOnClose?booleanfalse
Whether to fire onModalClose when the user dismisses the modal.
callbackUrl?string
URL to POST form values to when the modal is submitted.
privateMetadata?string
Arbitrary string passed through the modal lifecycle (e.g., JSON context).
children?ModalChild[]
Form input elements.

TextInput

A text input field.

TextInput({
  id: "name",
  label: "Your name",
  placeholder: "Enter your name",
})

TextInput({
  id: "description",
  label: "Description",
  multiline: true,
  maxLength: 500,
  optional: true,
})
PropTypeDefaultDescription
id?string
Input ID, used as the key in event.values.
label?string
Label displayed above the input.
placeholder?string
Placeholder text.
initialValue?string
Pre-filled value.
multiline?booleanfalse
Render as a textarea.
optional?booleanfalse
Whether the field can be left empty.
maxLength?number
Maximum character length.

DateInput

A date picker. Renders a Slack datepicker and an Adaptive Card Input.Date on Teams.

DateInput({
  id: "due_date",
  label: "Due date",
  placeholder: "Pick a date",
  initialValue: "2026-08-01",
})
PropTypeDefaultDescription
id?string
Input ID, used as the key in event.values.
label?string
Label displayed above the input.
placeholder?string
Placeholder text.
initialValue?string
Pre-filled date as YYYY-MM-DD.
optional?booleanfalse
Whether the field can be left empty.

The submitted value arrives in event.values as an ISO YYYY-MM-DD string. An initialValue that is not a valid YYYY-MM-DD date is dropped with a warning rather than forwarded, because Slack rejects a malformed initial_date by failing the whole modal.

NumberInput

A numeric input. Renders a Slack number_input and an Adaptive Card Input.Number on Teams.

NumberInput({
  id: "quantity",
  label: "Quantity",
  min: 1,
  max: 10,
})
PropTypeDefaultDescription
id?string
Input ID, used as the key in event.values.
label?string
Label displayed above the input.
placeholder?string
Placeholder text.
initialValue?number
Pre-filled value.
min?number
Minimum accepted value.
max?number
Maximum accepted value.
decimal?booleanfalse
Allow decimal values. Enforced by Slack; Adaptive Cards has no decimal switch, so Teams accepts decimals either way.
optional?booleanfalse
Whether the field can be left empty.

Values in event.values are always strings. Parse with Number(...) when you need a number.

Select

Dropdown menu.

Select({
  id: "priority",
  label: "Priority",
  placeholder: "Select priority",
  options: [
    SelectOption({ label: "High", value: "high", description: "Urgent tasks" }),
    SelectOption({ label: "Medium", value: "medium" }),
    SelectOption({ label: "Low", value: "low" }),
  ],
})
PropTypeDefaultDescription
id?string
Input ID, used as the key in event.values.
label?string
Label displayed above the select.
placeholder?string
Placeholder text.
initialOption?string
Pre-selected option value.
optional?booleanfalse
Whether the field can be left empty.
options?SelectOptionElement[]
Select options.
dispatchAction?booleanfalse
Dispatch onAction events when the selection changes in a Slack modal. Ignored by other adapters.

ExternalSelect

Dropdown that loads options dynamically from a handler as the user types. Slack-only. Pair with bot.onOptionsLoad to supply options. See Modals → ExternalSelect for a full example, grouped-options support, and Slack setup notes.

ExternalSelect({
  id: "assignee",
  label: "Assignee",
  placeholder: "Search people",
  minQueryLength: 1,
  initialOption: { label: "Alice", value: "U123" },
})
PropTypeDefaultDescription
id?string
Input ID, used as the key in event.values.
label?string
Label displayed above the select.
placeholder?string
Placeholder text.
minQueryLength?number
Minimum characters before the loader fires (Slack default: 3).
initialOption?{ label: string, value: string }
Pre-selected option when the modal opens. Unlike static Select where initialOption is a value string, ExternalSelect needs the full label/value object because the loader has not run yet.
optional?booleanfalse
Whether the field can be left empty.

The loader registered via bot.onOptionsLoad("assignee", handler) returns either a flat SelectOptionElement[] or OptionsLoadGroup[] ({ label, options }[]) for grouped options.

RadioSelect

Radio button group for mutually exclusive choices.

RadioSelect({
  id: "status",
  label: "Status",
  options: [
    SelectOption({ label: "Open", value: "open" }),
    SelectOption({ label: "Closed", value: "closed" }),
  ],
})

Same props as Select (except placeholder).

SelectOption

An option used inside Select and RadioSelect.

SelectOption({ label: "High", value: "high", description: "Urgent tasks" })
PropTypeDescription
label?string
Display text.
value?string
Value sent in event.values when selected.
description?string
Optional description shown below the label.

ModalChild types

The children array in Modal accepts these element types:

TypeCreated by
TextInputElementTextInput()
DateInputElementDateInput()
NumberInputElementNumberInput()
SelectElementSelect()
RadioSelectElementRadioSelect()
TextElementText(), for static text content
FieldsElementFields(), for key-value display

Read more