Skip to main content
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

Extend CometChatTextFormatter with '!' as the tracking character:

2. Fetch shortcuts from the extension

3. Override the search method

Match user input against stored shortcuts and update the suggestion list:

4. Override onScrollToBottom

5. Integrate with MessageComposer

Add the XML element to your layout:
Then add the formatter to the composer:
Typing ! followed by a valid shortcut key (e.g., !hi) displays a suggestion with the expanded text. Selecting it inserts the expansion into the composer.

Next Steps

Message Composer

Configure the composer where ShortCutFormatter is integrated

Mentions Formatter

Format @mentions with styled tokens and click handling

All Guides

Browse all feature and formatter guides

Sample App

Full working sample application on GitHub