AI Integration Quick Reference
AI Integration Quick Reference
CometChatTextFormatter is an abstract class for formatting text in the message composer and message bubbles. Extend it to build custom formatters — hashtags, shortcuts, or any pattern triggered by a tracking character.
Steps
1. Create a class extending CometChatTextFormatter
Pass your tracking character to the superclass constructor.- Kotlin
- Java
2. Override the search method
Called when the user types after the tracking character. Match input against your data and update the suggestion list.- Kotlin
- Java
3. Override onScrollToBottom
Required by the base class. Implement pagination logic or leave empty.- Kotlin
- Java
4. Override span formatting methods (optional)
Customize how matched text renders in different contexts usingSpannableStringBuilder.
- Kotlin
- Java
5. Integrate with a component
- Kotlin
- Java
CometChatMessageList and CometChatConversations via their setTextFormatters() methods to apply formatting across all contexts.
Methods Reference
Next Steps
Mentions Formatter
Built-in @mention formatting with styled tokens
ShortCut Formatter
Shortcut text expansion via the message-shortcuts extension
All Guides
Browse all feature and formatter guides
Sample App
Full working sample application on GitHub