Skip to content
weftGitHub

Question

The run stops and asks you to choose before it carries on.

SourcePackage @weft-js/warp

Preview

tsx
import { state } from '@weft-js/core'import { Question } from '@weft-js/warp'export function PickScope() {  const question = state<typeof GAP & { answer?: string | string[] }>(GAP)  return <Question question={question.value} quiet onAnswer={answer => (question.value = { ...GAP, answer })} />}const GAP = { id: 'scope', prompt: 'Which regions should go back to d-4801?', options: ['Only ap-south', 'Every region'], free: true }

Installation

npm install @weft-js/warp

Usage

tsx
import { Question } from '@weft-js/warp'

Several answers

A question with multiple set lets people pick more than one of its options.

tsx
import { state } from '@weft-js/core'import { Question } from '@weft-js/warp'export function ManyAnswers() {  const question = state<typeof NOTIFY & { answer?: string | string[] }>(NOTIFY)  return <Question question={question.value} quiet onAnswer={answer => (question.value = { ...NOTIFY, answer })} />}const NOTIFY = { id: 'who', prompt: 'Who should hear about the rollback?', options: ['#incidents', 'The on-call engineer', 'Everyone watching mobile-bff'], multiple: true }

Closed

The run stopped before anyone answered.

tsx
import { Question } from '@weft-js/warp'export function Closed() {  return (    <Question question={{ ...GAP, closed: true }} quiet />  )}const GAP = { id: 'scope', prompt: 'Which regions should go back to d-4801?', options: ['Only ap-south', 'Every region'], free: true }

When to use

Use it for

  • The assistant needs a decision, not just a yes

Reach for something else

Accessibility

  • It is a real fieldset with the question as its legend.
  • A new question is announced straight away unless quiet.

API Reference

PropTypeDefaultDescription
questionAgentQuestion—The prompt, options, and multiple, free, answer and closed.
quietbooleanfalseIt was there on load.
EventTypeDefaultDescription
onAnswer((answer: string | string[]) => void)—Continue was pressed.

RelatedTool callAssistant