How can I filter LastMessage?

When I get list of channel, I want to filter each channel’s lastMessage. I don’t want to show AdminMessage as lastMessage. Is there any way to filter this?

Hello @reallife ,

Yes, you can filter out AdminMessages when retrieving the list of channels. You can use the BaseMessageParams class and set the messageType parameter to exclude AdminMessages. Here’s an example in Android:

BaseMessageParams params = new BaseMessageParams();

GroupChannelListQuery query = GroupChannel.createMyGroupChannelListQuery();
query.setFilter(params); GroupChannelListQuery.GroupChannelListQueryResultHandler() {
public void onResult(List list, SendBirdException e) {
if (e != null) {
// Handle error

    // Process the list of channels


In this example, the MessageTypeFilter.USER is used to exclude AdminMessages from the list of channels.
Let me know if you need further assistance!

Thanks for reply!
I forgot to mension, Im using flutter as developing app. How can I do that on flutter?

Hello @reallife ,

In Flutter, when you receive the list of channels, you can iterate through each channel and check the type of the lastMessage. If the lastMessage is an AdminMessage, you can exclude that channel from your filtered list.

Here’s an example of how you can achieve this in Flutter:

List filterChannels(List channels) {
List filteredChannels = ;

for (Channel channel in channels) {
if (channel.lastMessage is! AdminMessage) {

return filteredChannels;

In this example, the filterChannels function takes a list of channels as input and returns a new list of channels with AdminMessages filtered out. You can then use this filtered list to display the channels in your Flutter application.

Note: this is just a basic example, and you may need to modify it based on your specific implementation and the structure of your channel objects.

Please reach out to me if you have any query.

Seems this solution means I exclude every channel that have lastmessage as adminmessage.

On our app, Every channel that user have joined will be shown at a list page.
On this page, each channel’s lastmessage will be also displayed.
What I want to do is, If a channel have certain type of message(for example, CustomType == ‘a’) as lastmessage, then don’t show that as lastmessage and show latest message that customType isn’t ‘a’ instead.

Thanks for your reply and support!

Then, you can filter out the channels that have a certain custom type as their last message and display the latest message with a different custom type instead.

You can try below :

  1. Retrieve the list of channels that the user has joined.
  2. For each channel, retrieve the last message using the getLastMessage() method.
  3. Check the custom type of the last message.
  4. If the custom type matches the one you want to exclude, retrieve the previous messages in the channel using the getMessagesByTimestamp() method.
  5. Find the latest message with a different custom type and display it as the last message for that channel.

Let me know if this helps.