Querying Messages

To query for a list of all messages in a channel:

This method will return a list of all messages in the specified channel. You can observe the list in order to update your view whenever you receive new messages.

  • with the includingTags and excludingTags parameters you can filter messages based on the tags set (or not set) in each message

  • with the parentId parameter you can filter messages according to their relationship:

    • if no parentId is passed, any message will match

    • if null parentId is passed, search for all messages without a parent

    • if a non-null parentId is passed: query for all messages with the parentId as parent

  • with the type parameter you can filter messages according to their type

    • if no type is passed, any message will match

    • if an AmityMessage.DataType is passed, query for all messages with the specific type

      • AmityMessage.DataType.TEXT for text messages

      • AmityMessage.DataType.IMAGE for image messages

      • AmityMessage.DataType.FILE for file messages

      • AmityMessage.DataType.AUDIO for audio messages

      • AmityMessage.DataType.VIDEO for video messages

      • AmityMessage.DataType.CUSTOM for custom messages

Exclude delete messages in querying

A popular request was to have an isDeleted boolean filter to avoid querying deleted messages to display in a chatroom. It is now available and can be used as:

The overall rule for the isDeleted parameter is as following:

  • isDeleted = undefined : both deleted and not deleted messages will be returned

  • isDeleted = true : only deleted messages will be returned

  • isDeleted = false : only non deleted messages will be returned

Threaded Messages

A message can be the root for a thread. To query the children of a message thread, you can add the parentId parameter in a message query, along with the filterByParentId flag.

Last updated