AI Chatbot
ProNewAn assistant window for your own model: launcher with optional delayed greeting, quick replies, streamed answers with a thinking state and Stop, plus copy, rating and retry.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| onSend* | (message: string, context: ChatbotContext) => ChatbotReply | Promise<ChatbotReply>Answers a message. Return a string, or an async iterable of text chunks to stream the answer in as it is generated. Throw to show the error state. | — |
| name | stringThe assistant's name, in the header and the welcome screen. | "AI Assistant" |
| caption | stringOne line under the name on the welcome screen. | "Ask me anything. I answer in seconds." |
| avatar | stringPicture for the assistant. A sparkle on your accent color is used without one. | — |
| welcome | stringThe assistant's opening message. | "Hi! How can I help you today?" |
| suggestions | string[]Quick replies offered until the visitor sends a first message. | [] |
| placeholder | string | "Write a message..." |
| disclaimer | stringSmall print under the input. | — |
| initialMessages | ChatbotMessage[]A conversation to start from, for example one restored from storage. | [] |
| onFeedback | (message: ChatbotMessage, value: "up" | "down" | null) => voidCalled when a thumb is pressed. `null` means the rating was taken back. | — |
| layout | "floating" | "inline"`floating` pins a launcher to a corner of the viewport and fills the screen on phones; `inline` renders the open window in the page. | "floating" |
| accent | stringAny CSS color, for the launcher, your messages, quick replies and focus rings. | "#006dff" |
| launcherLabel | stringAccessible name of the launcher. | "Ask the AI assistant" |
| position | "bottom-right" | "bottom-left" | "bottom-right" |
| open | booleanControlled open state for the floating layout. | — |
| defaultOpen | boolean | false |
| onOpenChange | (open: boolean) => void | — |
| teaser | stringOptional floating greeting shown once before the visitor first opens the assistant. | — |
| teaserDelay | numberSeconds to wait before showing the greeting; defaults to 10. | 10 |
| errorMessage | stringShown when `onSend` throws without a message of its own. | "Something went wrong while answering. Please try again." |
| className | string | — |
Accessibility
- The launcher reports expanded state; opening puts focus in the input and Escape or Close returns it to the launcher.
- The optional greeting is a button that opens chat; its dismissal is a separate named button and it does not return after the visitor opens chat.
- Answers are announced once, when complete, through a status region rather than chunk by chunk; “thinking” and “stopped” are announced too.
- Enter sends and Shift+Enter adds a line; Stop replaces Send while an answer streams.
- Thumbs are toggle buttons with pressed state; a failed answer is an alert with a Try again button.
- On phones the window fills the screen and keeps Tab inside it. Dots, shimmer and the caret hold still under reduced motion.