AI Agent Component Spec
AI Agent Component Spec
| Field | Value |
|---|---|
| Package | Custom class extending com.cometchat.chatuikit.shared.formatters.CometChatTextFormatter |
| Key class | ShortCutFormatter (extends CometChatTextFormatter) |
| Required setup | CometChatUIKit.init() then CometChatUIKit.login("UID") |
| Track character | ! — triggers shortcut expansion in the message composer |
| Extension | message-shortcuts CometChat extension must be enabled |
| Sample app | GitHub |
| Related | Mentions Formatter | All Guides |
ShortCutFormatter extends CometChatTextFormatter to expand shortcodes (like !hi) into full text via the Message Shortcuts extension. When a user types a shortcut trigger in the composer, a suggestion appears with the expansion — selecting it inserts the text.

Steps
1. Create the ShortCutFormatter class
ExtendCometChatTextFormatter with '!' as the tracking character:
- Kotlin
- Java
2. Fetch shortcuts from the extension
- Kotlin
- Java
3. Override the search method
Match user input against stored shortcuts and update the suggestion list:- Kotlin
- Java
4. Override onScrollToBottom
- Kotlin
- Java
5. Integrate with MessageComposer
Add the XML element to your layout:- Kotlin
- Java
! followed by a valid shortcut key (e.g., !hi) displays a suggestion with the expanded text. Selecting it inserts the expansion into the composer.