Skip to main content
Components provide context menus (e.g., long-press on a conversation) and the message composer provides attachment and AI action options. You can customize all of these at the component level or globally via the DataSource framework.

Component-Level Options

setOptions vs addOptions

MethodBehavior
setOptions(Function2<Context, Conversation, List<MenuItem>>)Replaces all default options with your custom list
addOptions(Function2<Context, Conversation, List<MenuItem>>)Appends your custom options to the existing defaults
Use addOptions when you want to keep the default actions (like “Delete”) and add your own. Use setOptions when you want full control over the menu.

Example: Adding a Custom Option

conversations.addOptions { context, conversation ->
    listOf(
        CometChatPopupMenu.MenuItem(
            id = "pin",
            name = "Pin Conversation",
            startIcon = ContextCompat.getDrawable(context, R.drawable.ic_pin),
            endIcon = null,
            onClick = {
                pinConversation(conversation)
            }
        )
    )
}

Example: Replacing All Options

conversations.setOptions { context, conversation ->
    listOf(
        CometChatPopupMenu.MenuItem(
            id = "archive",
            name = "Archive",
            startIcon = ContextCompat.getDrawable(context, R.drawable.ic_archive),
            endIcon = null,
            onClick = { archiveConversation(conversation) }
        ),
        CometChatPopupMenu.MenuItem(
            id = "mute",
            name = "Mute",
            startIcon = ContextCompat.getDrawable(context, R.drawable.ic_mute),
            endIcon = null,
            onClick = { muteConversation(conversation) }
        )
    )
}

DataSource Message Options

For message-level options (the actions that appear on message bubbles), use the DataSource framework. Override these methods in a DataSourceDecorator:

Message Option Methods

MethodDescription
getTextMessageOptions(Context, BaseMessage, Group)Options for text messages
getImageMessageOptions(Context, BaseMessage, Group)Options for image messages
getVideoMessageOptions(Context, BaseMessage, Group)Options for video messages
getAudioMessageOptions(Context, BaseMessage, Group)Options for audio messages
getFileMessageOptions(Context, BaseMessage, Group)Options for file messages
getCommonOptions(Context, BaseMessage, Group)Options common to all message types
getMessageOptions(Context, BaseMessage, Group)All options for a message (combines type-specific and common)

Composer Action Methods

MethodDescription
getAttachmentOptions(Context, User, Group)Attachment options in the composer (camera, gallery, file, etc.)
getAIOptions(Context, User, Group)AI action options in the composer

Extending Options via DataSourceDecorator

Use a DataSourceDecorator to add custom options globally without replacing the defaults:
class CustomOptionsDataSource(dataSource: DataSource) : DataSourceDecorator(dataSource) {

    override fun getTextMessageOptions(
        context: Context,
        baseMessage: BaseMessage,
        group: Group?
    ): List<CometChatMessageOption> {
        val options = super.getTextMessageOptions(context, baseMessage, group).toMutableList()
        options.add(CometChatMessageOption(
            id = "translate",
            title = "Translate",
            icon = R.drawable.ic_translate,
            onClick = { translateMessage(baseMessage) }
        ))
        return options
    }
}

// Register globally
ChatConfigurator.enable { dataSource -> CustomOptionsDataSource(dataSource) }