AI Integration Quick Reference
AI Integration Quick Reference
DataSourceDecorator, override the methods you need, and register the result with ChatConfigurator.
MessageDataSource is the default implementation ChatConfigurator starts from. Every decorator you register wraps whatever is currently active, so calling enable() more than once layers decorators rather than replacing them.
The five required overrides
A custom message type has to be declared twice — once so the list knows how to render it, and once so the list knows to fetch it — plus an identity soChatConfigurator can tell your decorator apart from the others.
Miss the fetch half and the bubble renders optimistically when the message is sent, then disappears on reload — the type is filtered out server-side, with no error in the console, on the listener, or in the network response. See Filtering Messages.
The four template and type methods must call
super and extend the result. Returning your own list wholesale drops every built-in type.
When to register
Example: a poll message type
Registering through uiKitSettings.extensions
enableExtensions() re-applies uiKitSettings.extensions after the reset, so an ExtensionsDataSource passed in settings is the one registration route that survives login(). It has its own trap.
ExtensionsDataSource is abstract. It requires addExtension() and getExtensionId(), and ships a concrete enable():
login(), so you do not have to sequence the call yourself.
Choosing a route
Use the settings route for a type your app always needs. Use the direct call for a type you register conditionally after the user is known.
Related
- Message List → Filtering Messages — why the fetch half matters.
- Message Composer — sending a custom message.
- Methods —
CometChatUIKit.initandlogin.