CometChatSmartReplies component displays AI-generated reply suggestions as clickable chips. It integrates with the CometChat AI extension to analyze the last received message and generate up to 3 contextual reply options.
Overview
The Smart Replies component provides intelligent reply suggestions:- AI-Generated Replies: Fetches up to 3 reply suggestions from the CometChat AI extension based on the last received message
- Trigger Keywords: Only shows suggestions when the message contains configurable trigger keywords (default: what, when, why, who, where, how, ?)
- Configurable Delay: Waits a configurable duration (default: 10 seconds) before showing suggestions, giving users time to type their own response
- Loading State: Displays a loading indicator while fetching suggestions from the AI service
- Keyboard Accessible: Full keyboard navigation with Tab, Enter/Space to select, and ArrowLeft/ArrowRight between replies
Live Preview — default smart replies preview.
Open in Storybook ↗
Basic Usage
Simple Smart Replies
With Custom Keywords and Delay
Properties
| Property | Type | Default | Description |
|---|---|---|---|
message | CometChat.BaseMessage | undefined | The message to generate smart replies for. Replies are based on this message’s content. |
user | CometChat.User | undefined | The user context for generating smart replies. Required for 1-on-1 conversations. |
group | CometChat.Group | undefined | The group context for generating smart replies. Required for group conversations. |
keywords | string[] | ['what', 'when', 'why', 'who', 'where', 'how', '?'] | Keywords that trigger smart replies. If the message contains any of these keywords, smart replies will be shown. An empty array shows replies for all messages. |
delayDuration | number | 10000 | Delay in milliseconds before showing smart replies. Gives users time to start typing their own response. Set to 0 to fetch instantly. |
Events
| Event | Payload Type | Description |
|---|---|---|
replyClick | string | Emitted when a smart reply chip is clicked. The payload is the reply text that was selected. |
closeClick | void | Emitted when the close button is clicked to dismiss the smart replies panel. |
Customization
CSS Variables
The Smart Replies component uses BEM-style CSS classes that can be customized with CSS variables:Accessibility
Keyboard Navigation
- Tab: Focus moves into the smart replies container and to the first reply chip
- ArrowRight / ArrowLeft: Navigate between reply chips with wrap-around
- Enter / Space: Select the focused reply chip, emitting the
replyClickevent - Focus is managed using a roving tabindex pattern
Screen Reader Support
- The container has
role="group"witharia-label="Smart replies" - Each reply chip has an
aria-labelwith the reply text - Screen readers announce “Smart replies available” when the component appears
Related Components
- CometChatConversationStarter - AI-generated conversation starters for empty conversations
- CometChatMessageList - Message list that hosts the smart replies component