Retrieve and filter messages from channels with advanced querying capabilities, sorting options, and real-time updates for dynamic chat experiences.
getMessages
function provides comprehensive message retrieval capabilities, allowing you to fetch messages from specific subchannels based on various criteria. This function returns a live collection that automatically updates when messages are added, modified, or deleted.
Parameter | Type | Description |
---|---|---|
subChannelId | String | The ID of the subchannel from which to retrieve messages |
Parameter | Type | Description |
---|---|---|
includingTags | Array<String> | Filter messages that contain at least one of the specified tags |
excludingTags | Array<String> | Exclude messages that contain any of the specified tags |
includeDeleted | Boolean | Whether to include deleted messages in results (default: false) |
type | MessageType | Filter by specific message type (TEXT, IMAGE, FILE, AUDIO, VIDEO, CUSTOM) |
sortOption | SortOption | Sort order: firstCreated (oldest first) or lastCreated (newest first) |
firstCreated
for chronological order (oldest first) or lastCreated
for reverse chronological order (newest first, typical for chat interfaces).Tag-Based Filtering
includingTags
and excludingTags
to create sophisticated filtering systems:Message Type Filtering
AmityMessage.DataType.TEXT
for text-only conversationsIMAGE
, VIDEO
, AUDIO
for media galleriesFILE
for document sharing viewsCUSTOM
for app-specific message typesThread Management
messageParentFilter: nil
or parentId: null
for main conversation flowparentId
to get all replies to a specific messageMessage Navigation
Efficient Pagination
Real-time Synchronization
Performance Optimization