Question

Asks a person for the answer an agent needs to continue.

Forge asks

Which database should I run the migration against?

It adds a NOT NULL column to orders, which has 2.1M rows. I'll stop after it and show you the plan.

Forge waits up to 30 minutes

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/ask

Usage

import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { Ask } from "./ui/uicontext/components/kit/Ask.ts"
const scout: Actor = { id: "scout", name: "Scout", kind: "agent" }const Message = UiSchema.TaggedEnum({ AnsweredOwner: { value: Schema.String, request: Schema.String } })export const OwnerQuestion = (h: Html.H<typeof Message.Type>, outcome: Outcome | null) =>	Ask(h, {		props: {			id: "owner",			actor: scout,			question: "Who should own PAY-412 while Ben is out?",			options: [				{ value: "mira", label: "Mira Patel" },				{ value: "queue", label: "Leave it in the Payments queue" },			],			can: ["answer"],			outcome,		},		// send the answer to the agent, then pass back an Outcome with the same request		onEmit: { Answered: ({ value, request }) => Message.AnsweredOwner({ value, request }) },	})

Examples

Checked answers

A number in range, an email the app refuses with a reason, and a longer note with a length limit. Try sending each one empty or wrong.

Juno asks

What's the most I should spend on the team dinner?

Eight people on Thursday. The two places with tables left start at 45 per person.

EUR
Juno asks

Which address should the calendar invite go to?

Dr. Osei from Halcyon Health is joining the review.

Juno asks

What should I tell the vendor about declining their offer?

⌘↵ to send

Several choices

With multiple, the person ticks any that apply and sends them together. other adds a typed answer.

Scout asks

Where should I post the 2.14 release notes?

Pick any that apply

Answered, closed and read-only

Once answered, the card shows the answer and who gave it. A question that ran out says why; someone who can't answer sees who can.

Scout asks

Who should own PAY-412 while Ben is out?

Mira Patel · answered

Scout asks

Should I reopen ENG-88?

No answer in 30 minutes, so Scout left it closed.

Scout asks

Which card should the refund go to?

Only Mira can answer: she owns the account.

API reference

Props

Ask props
NameTypeDescription
idrequiredstringIdentifies the question, for agents and for the answer
questionrequiredstringWhat the agent needs to know, as a question
detailstringWhy it asks, or what it will do with the answer
actorActorThe agent asking
optionsAskOption[]Choices to pick from; without them, the person types an answer
multiplebooleanPick any number of options, then send
otherstringWith options: a typed answer is allowed too, under this label ("Something else")
inputAskInputWhat a typed answer must be
answer{ value, actor } | nullThe answer once given, and who gave it
closedstringThe question ran out of time, or the agent moved on, with the reason to show
expiresstring"Expires in 10 min", under the question while it waits
outcomeOutcome | nullThe app's answer to the last Answered request
canrequiredCan(["answer"])"answer" when this person may answer
whoMayAnswerstringWho may answer, shown to someone who can't: "Only Ada can answer"

Events

Ask events
EventPayloadDescription
Answered{ value: string; values?: string[]; request: string }The person answered: an option's value, the picked values joined by ", " (with values), or what they typed. Settle request through outcome.

Agent actions

What agents can do with Ask
ActionDescription
ChoseOptionAnswer with one of the options (see page_query)
ToggledOptionPick (on: true) or unpick one of several options; then SubmittedPicked sends them
SubmittedPickedSend the picked options
ChangedTextWrite a free-text answer
SubmittedTextSend the written answer. It must pass the question's checks; problem in the snapshot says why it didn't.

Accessibility

  • The question is a region named by the question. Its options are buttons; without options it's a labelled text field that Enter sends.
  • Once answered, the card says the answer and who gave it, and the choices go away.
  • Agents read the question and whether it's answered, and must answer with one of its options.

Source