How to customize the suggested replies message UI #452
sendbird-sdk-deployment
announced in
Conversation
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Versions
Summary
This guide explains how to replace the default suggested replies UI in the conversation message with your own layout, while keeping the rest of the message UI intact.
Guide & Snippet
Android
How to customize the Suggested Replies UI in the conversation message
By default, the SDK renders suggested replies as right-aligned rounded chips outlined with the primary color. You can replace them with your own layout by subclassing
OtherMessageContainerand overriding onlydrawSuggestedReplies(...), then registering a customMessageContainerGenerator.The example below renders suggested replies as full-width, left-aligned "menu rows" with a trailing chevron. Everything else (profile, nickname, timestamp, template, feedback) keeps the default behavior inherited from
OtherMessageContainer.Step 1: Subclass
OtherMessageContainerand overridedrawSuggestedRepliesOtherMessageContainerisopenand so isdrawSuggestedReplies, so you can override just the suggested replies rendering.The parent keeps
onSuggestedRepliesClickListenerin aprivatefield, so capture your own reference fromeventListenersinsideinitialize(...)to forward clicks. The SDK hands you aSuggestedRepliesView(aFrameLayout); you can reuse it as a plain container by clearing its default content and adding your own views.The chevron above uses a small vector drawable. Add it to your app resources (e.g.
res/drawable/sample_ic_chevron_right.xml):Step 2: Provide a custom
MessageContainerGeneratorExtend
DefaultMessageContainerGeneratorand return your container for theLEFT(bot) side only, keeping the defaults forRIGHT(my) andPLAIN.Step 3: Register the generator with
AIAgentAdapterProviders.conversationProvide the conversation adapter yourself and pass your custom generator into
ConversationMessageListAdapter. (The third parameter is the default generator supplied by the SDK; ignore it and pass your own.)Important: This registration must be done before calling
MessengerLauncher.attach()or launchingMessengerActivity.The provider must be ready before the screen is created in order for the custom container to take effect.
Notes:
onSuggestedRepliesClickListenerexactly like the default, so tapping a reply hides the list and sends the reply.companion objectcolors and the paddings/corner radius/text size increateReplyRow/createRowBackground.messageListUIParams.messageListTheme.backgroundColorandmessageListUIParams.aiAgentTheme.primaryColor) instead of hardcoded values.iOS
How to customize the Suggested Replies UI in the conversation message
By default the SDK renders suggested replies as right-aligned rounded chips. Subclass
SBASuggestedReplyView, build your own layout fromoptions, and register the subclass onSBAConversationModule.List.Cell.SuggestedReplyView.The example renders them as full-width menu rows with a trailing chevron. Everything else — profile, nickname, timestamp, template, feedback — keeps the default behavior.
Step 1: Subclass
SBASuggestedReplyViewStep 2: Register the subclass
Notes:
SBATheme.conversation.list.cell.userMessage.suggestedReply. Alignment and width are not themeable.React
React Native
Reference
No response
Screenshots
All reactions