v4.14.0
·
91 commits
to main
since this release
Features
- Three new features related to Generative AI have been added: Form type, Suggested replies and Feedback.
- Form type: A form type message is a message that contains a form. A form is a set of questions that a user can answer to collect data from users.
- How to determine if a message is a form type message:
val BaseMessage.isFormTypeMessage: Boolean get() = this.forms.isNotEmpty()
- How to save the answer in the SDK when the user enters input:
editText.addTextChangedListener( object : TextWatcher { ... override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { formField.temporaryAnswer = Answer(formField.key, s.toString()) } } )
- Submits a form
// submits form message.submitForm(form) { e -> if (e != null) { // handle error } } // The submitted form is updated through a message update event. SendbirdChat.addChannelHandler( "IDENTIFIER", object : GroupChannelHandler() { ... override fun onMessageUpdated(channel: BaseChannel, message: BaseMessage) { message.forms.find { it.formKey == "TARGET_FORM_KEY" }?.isSubmitted // should be true // update message UI to submitted form } } )
- How to determine if a message is a form type message:
- Suggested replies: Suggested reply is a set of items that a user can click quickly to send a message. Suggested replies is contained in a last message.
SendbirdChat.addChannelHandler( "IDENTIFIER", object : GroupChannelHandler() { ... override fun onChannelChanged(channel: BaseChannel) { if (channel is GroupChannel) { val suggestedReplies = channel.lastMessage?.suggestedReplies if (!suggestedReplies.isNullOrEmpty()) { // draw suggested replies for the channel's last message } } } } )
- Feedback: Feedback is a feature that allows users to provide their satisfaction or dissatisfaction with the bot's responses.
- How to draw feedback UI
val feedback = message.myFeedback when (message.myFeedbackStatus) { FeedbackStatus.NOT_APPLICABLE -> { // this message is not applicable for feedback // Make thumbs-up/down UI invisible or disable here // `feedback` should be null } FeedbackStatus.NO_FEEDBACK -> { // The feedback is not submitted yet but user can submit feedback // Make thumbs-up/down UI visible or enable without being selected // `feedback` should be null } FeedbackStatus.SUBMITTED -> { // The feedback is submitted // Make thumbs-up/down UI visible or enable as selected // `feedback` should not be null } }
- How to submit / update / delete feedback
// submit feedback message.submitFeedback(FeedbackRating.Good) { feedback, e -> when { feedback != null -> { // update feedback UI } e != null -> { // handle error } } } // update feedback message.updateFeedback(FeedbackRating.Good, "Very good response") { feedback, e -> when { feedback != null -> { // update feedback UI } e != null -> { // handle error } } } // delete feedback message.deleteFeedback { e -> // handle error }
- How to draw feedback UI
- Form type: A form type message is a message that contains a form. A form is a set of questions that a user can answer to collect data from users.
- Introduced
BaseMessage.extras
to enable developers to include their own data inBaseMessage
and carry it seamlessly. - Added
logCustom(String, List<BaseMessage>)
inFeedChannel
.
Improvements
- Fix the bug where the internal network status flag is incorrect when an app starts from offline mode.