currentChannel.lastMessage only updates with user messages

[Problem]

const { currentChannel, messages } = useGroupChannelContext()
// send a chatbot message via API and observe
console.log(currentChannel?.lastMessage)
console.log(messages.at(-1))

I’m implementing custom InputWrapper and noticed that:

  1. When sending a regular user message, currentChannel.lastMessage and messages.at(-1) are the same.
  2. But when sending a bot message with the API, the lastMessage still shows the user message while messages.at(-1) indeed is the bot’s message.

Here is the log

currentChannel?.lastMessage?.messageId 8317010301
messages.length 30
messages.at(-1).messageId 8317010301
// sent chatbot message, component got re-rendered
currentChannel?.lastMessage?.messageId 8317010301
messages.length 31
messages.at(-1).messageId 8317010417

[SDK Version]
3.14.14

[Reproduction Steps]

  1. Send a chatbot (not AI) message to a channel, observe that currentChannel.lastMessage doesn’t change
// CustomGroupChannel.tsx
    <GroupChannel
      renderMessageInput={() => (
        <CustomMessageInput  />
      )}
    />
  )

// CustomMessageInput.tsx
export function CustomMessageInput() {
  const { currentChannel, messages } = useGroupChannelContext()
  console.log(
    'currentChannel?.lastMessage?.messageId',
    currentChannel?.lastMessage?.messageId
  )
  console.log('messages.length', messages.length)
  console.log('messages.at(-1).messageId', messages.at(-1).messageId)

  return (<MessageInputWrapper/>)
}

[Frequency]
every time

[Current impact]
we can’t rely on lastMessage

I think thats because bot messages are silent by default.
I’ve DMed @Ian after seeing similar messages on the community.
Could that be it?

@Guy_Guy,

Yes, that’s correct. It’s a setting that must be disabled by Sendbird support if you do not want your bot messages to be delivered silently.