ChatUi unstable
The plain elements of buttons, selects and modals.
These are what goes on the wire, into ChatTest and into storage. Every
element is a Schema tagged struct and every value in one is already a
string. ChatInteraction holds the typed definitions that build them and
receive their clicks. A consumer that routes clicks itself builds them with
each schema's own make.
Details
postandedittake a flat list ofActions beside the Markdown, and the adapter lays out the rows.- Text in a modal is plain, not Markdown, because a Slack modal cannot hold
a
markdownblock.
Constructors
linkButton
unstableCreates a button that opens a URL.
When to use
Use to put a link beside the buttons of a message. It is the one element
with no definition in ChatInteraction, since it produces no click.
Signature
declare function linkButton(options: { readonly label: string; readonly url: string;}): { readonly _tag: "LinkButton"; readonly label: string; readonly url: string;}Example Posting a link button
import { Effect } from "effect"import { Chat, ChatThread, ChatUi } from "effect/chat"
const program = Effect.gen(function*() { const chat = yield* Chat.Chat yield* chat.post(ChatThread.make("slack", "T1/C1"), { markdown: "The diff is ready.", actions: [ChatUi.linkButton({ label: "Diff", url: "https://example.com/diff" })] })})Models
What post and edit take in actions: a button, a link button or a
select.
Signature
type Action = typeof Action.TypeA button on a message.
Signature
type Button = typeof Button.TypeThe style of a button.
Signature
type ButtonStyle = typeof ButtonStyle.TypeA button that opens a URL.
Signature
type LinkButton = typeof LinkButton.TypeA modal.
Signature
type Modal = typeof Modal.TypeOne element of a modal: a text input, a select or plain text.
Signature
type ModalElement = typeof ModalElement.TypeA single-choice select on a message.
Signature
type Select = typeof Select.TypeA single-choice select in a modal.
Signature
type SelectInput = typeof SelectInput.TypeOne option of a select.
Signature
type SelectOption = typeof SelectOption.TypePlain text in a modal.
Signature
type Text = typeof Text.TypeA text input in a modal.
Signature
type TextInput = typeof TextInput.TypeSchemas
Schema for what post and edit take in actions.
Signature
declare const Action: Union<readonly [TaggedStruct<"Button", { readonly id: String; readonly label: String; readonly style: optionalKey<Literals<readonly ["default", "primary", "danger"]>>; readonly value: optionalKey<String>;}>, TaggedStruct<"LinkButton", { readonly label: String; readonly url: String;}>, TaggedStruct<"Select", { readonly id: String; readonly options: $Array<Struct<{ readonly label: String; readonly value: String; }>>; readonly placeholder: optionalKey<String>; readonly selected: optionalKey<String>;}>]>Schema for a button on a message.
Details
value is the encoded value, absent when the definition has no value
schema.
Signature
declare const Button: TaggedStruct<"Button", { readonly id: String; readonly label: String; readonly style: optionalKey<Literals<readonly ["default", "primary", "danger"]>>; readonly value: optionalKey<String>;}>ButtonStyle
unstableSchema for the style of a button.
Signature
declare const ButtonStyle: Literals<readonly ["default", "primary", "danger"]>LinkButton
unstableSchema for a button that opens a URL.
Details
It produces no click, so it has no id and no handler.
Signature
declare const LinkButton: TaggedStruct<"LinkButton", { readonly label: String; readonly url: String;}>Schema for a modal.
Details
metadatais the consumer's encoded metadata. The adapter adds the thread and message of the click that opened the modal beside it.- The elements are shown in order.
Signature
declare const Modal: TaggedStruct<"Modal", { readonly elements: $Array<Union<readonly [TaggedStruct<"TextInput", { readonly id: String; readonly initial: optionalKey<String>; readonly label: String; readonly maxLength: optionalKey<Int>; readonly minLength: optionalKey<Int>; readonly multiline: optionalKey<Boolean>; readonly optional: optionalKey<Boolean>; readonly placeholder: optionalKey<String>; }>, TaggedStruct<"SelectInput", { readonly id: String; readonly initial: optionalKey<String>; readonly label: String; readonly optional: optionalKey<Boolean>; readonly options: $Array<Struct<{ readonly label: String; readonly value: String; }>>; readonly placeholder: optionalKey<String>; }>, TaggedStruct<"Text", { readonly text: String; }>]>>; readonly id: String; readonly metadata: optionalKey<String>; readonly submitLabel: optionalKey<String>; readonly title: String;}>ModalElement
unstableSchema for one element of a modal.
Signature
declare const ModalElement: Union<readonly [TaggedStruct<"TextInput", { readonly id: String; readonly initial: optionalKey<String>; readonly label: String; readonly maxLength: optionalKey<Int>; readonly minLength: optionalKey<Int>; readonly multiline: optionalKey<Boolean>; readonly optional: optionalKey<Boolean>; readonly placeholder: optionalKey<String>;}>, TaggedStruct<"SelectInput", { readonly id: String; readonly initial: optionalKey<String>; readonly label: String; readonly optional: optionalKey<Boolean>; readonly options: $Array<Struct<{ readonly label: String; readonly value: String; }>>; readonly placeholder: optionalKey<String>;}>, TaggedStruct<"Text", { readonly text: String;}>]>Schema for a single-choice select on a message.
Details
selected is the value of the option shown as chosen.
Signature
declare const Select: TaggedStruct<"Select", { readonly id: String; readonly options: $Array<Struct<{ readonly label: String; readonly value: String; }>>; readonly placeholder: optionalKey<String>; readonly selected: optionalKey<String>;}>SelectInput
unstableSchema for a single-choice select in a modal.
Details
Both ChatInteraction.choice and ChatInteraction.selectInput fields
become this. initial is the value of the option chosen when the modal
opens.
Signature
declare const SelectInput: TaggedStruct<"SelectInput", { readonly id: String; readonly initial: optionalKey<String>; readonly label: String; readonly optional: optionalKey<Boolean>; readonly options: $Array<Struct<{ readonly label: String; readonly value: String; }>>; readonly placeholder: optionalKey<String>;}>SelectOption
unstableSchema for one option of a select. value is the encoded value.
Signature
declare const SelectOption: Struct<{ readonly label: String; readonly value: String;}>Schema for plain text in a modal.
Details
Not Markdown: a Slack modal cannot hold a markdown block.
Signature
declare const Text: TaggedStruct<"Text", { readonly text: String;}>Schema for a text input in a modal, one line or several.
Signature
declare const TextInput: TaggedStruct<"TextInput", { readonly id: String; readonly initial: optionalKey<String>; readonly label: String; readonly maxLength: optionalKey<Int>; readonly minLength: optionalKey<Int>; readonly multiline: optionalKey<Boolean>; readonly optional: optionalKey<Boolean>; readonly placeholder: optionalKey<String>;}>