AI Agent Component Spec
AI Agent Component Spec
| Field | Value |
|---|---|
| Package | @cometchat/chat-uikit-react |
| Key class | ShortcutFormatter (extends CometChatTextFormatter) |
| Required setup | CometChatUIKit.init(UIKitSettings) then CometChatUIKit.login("UID") |
| Track character | ! — triggers shortcut expansion in the message composer |
| Sample app | GitHub |
| Related | Custom Text Formatter | All Guides |
ShortCutFormatter extends CometChatTextFormatter to expand shortcodes (like !hb) into full text via the Message Shortcuts extension. When a user types a shortcut, a dialog appears with the expansion — clicking it inserts the text.

Steps
1. Import the base class
2. Extend it
3. Set the track character
4. Handle key events
Detect shortcuts onkeyDown and trigger expansion logic.
5. Add dialog and formatting methods
Example


- ShortCutFormatter.ts
- Dialog.tsx
- ConversationDemo.tsx
Fetches shortcuts from the Message Shortcuts extension on init. On
keyUp, checks if the text before the caret matches a shortcut and opens a dialog with the expansion.