ChatFeedEntry

open fun ChatFeedEntry(entry: ChatFeedEntry, content: @Composable () -> Unit)

Renders a single entry in the chat feed.

Override this method to replace, augment, or hide individual entries based on their type. Use a when expression on entry to target specific subtypes such as ChatFeedEntry.ConversationEntryModel or ChatFeedEntry.DateBreakModel.

Parameters

entry

The ChatFeedEntry model representing the item to render. Inspect its ChatFeedEntry.contentType or use is checks to determine the entry kind.

content

The SDK's default composable for this entry. Call it to retain default rendering.

Samples

uiClient.viewComponents = object : ViewComponents {
    @Composable
    override fun ChatFeedEntry(
        entry: ChatFeedEntry,
        content: @Composable () -> Unit
    ) {
        when (entry) {
            is ChatFeedEntry.ConversationEntryModel -> {
                when (entry.entryType) {
                    ConversationEntryType.Message -> {
                        Text(text = "Custom message")
                    }
                    ConversationEntryType.ParticipantChanged,
                    ConversationEntryType.RoutingResult -> {
                        // Return without rendering to hide system entries
                    }
                    else -> content()
                }
            }
            else -> content()
        }
    }
}
val conversationClient = uiClient.conversationClient(context)

uiClient.viewComponents = object : ViewComponents {
    @Composable
    override fun ChatFeedEntry(
        entry: ChatFeedEntry,
        content: @Composable () -> Unit
    ) {
        when (entry) {
            is ChatFeedEntry.ConversationEntryModel -> {
                val payload = entry.payload as? EntryPayload.MessagePayload
                val choices = payload?.content as? ChoicesFormat.DisplayableOptionsFormat

                if (choices != null) {
                    val coroutineScope = rememberCoroutineScope()
                    Column {
                        Text(text = choices.text)
                        choices.optionItems.forEach { option ->
                            val title = (option as? OptionItem.TypedOptionItem.TitleOptionItem)
                                ?.titleItem?.title ?: return@forEach
                            Button(onClick = {
                                coroutineScope.launch { conversationClient.sendReply(option) }
                            }) {
                                Text(title)
                            }
                        }
                    }
                } else {
                    content()
                }
            }
            else -> content()
        }
    }
}