Mirra
IntegrationsOther

Mirra Messaging

SDK reference for mirra messaging operations

Overview

Send messages through Mirra platform with automation metadata tracking

  • Category: communication
  • Auth Required: No
  • Supported Modes: standard, delegated, service

Operations

sendMessage

Send a message to a group (including direct chats). The message is sent as the authenticated user with optional automation metadata. Returns normalized flat structure.

Arguments:

  • groupId (string, required): Group ID to send the message to (use getContacts or getGroups to get the groupId)
  • content (string, required): Message text content
  • automation (object, optional): Automation metadata: { source: string, flowId?: string, flowTitle?: string, sessionId?: string, isAutomated?: boolean }. Use sessionId to group related messages and enable Flow-based reply routing.
  • structuredData (array, optional): Structured data for rich UI rendering: [{ displayType, templateId, data, metadata?, interactions? }]

Returns:

AdapterOperationResult - Returns FLAT structure with: messageId, chatInstanceId, groupId, content, timestamp, automationSource, automationSessionId, automationFlowId, linkUrl, linkLabel. No nested objects.

Response Fields:

FieldTypeDescription
messageIdstringSent message ID
chatInstanceIdstringChat instance ID
groupIdstringGroup ID
contentstringMessage content
timestampstringSent timestamp (ISO 8601)
automationSource`stringnull`
automationSessionId`stringnull`
automationFlowId`stringnull`
linkUrlstringDeep link URL to chat
linkLabelstringDisplay label for link

Example:

const result = await mirra.mirraMessaging.sendMessage({
  groupId: "abc123",
  content: "example"
});

updateMessage

Update an existing message sent by the authenticated user. Returns normalized flat structure.

Arguments:

  • messageId (string, required): ID of the message to update
  • content (string, required): New message text content
  • structuredData (array, optional): Updated structured data for rich UI rendering

Returns:

AdapterOperationResult - Returns FLAT structure with: messageId, chatInstanceId, groupId, content, editedAt, editCount. No nested objects.

Response Fields:

FieldTypeDescription
messageIdstringUpdated message ID
chatInstanceIdstringChat instance ID
groupIdstringGroup ID
contentstringUpdated message content
editedAtstringEdit timestamp (ISO 8601)
editCountnumberTotal edit count

Example:

const result = await mirra.mirraMessaging.updateMessage({
  messageId: "abc123",
  content: "example"
});

getContacts

Get list of accepted contacts for the user. Returns normalized flat structures.

Arguments:

  • limit (number, optional): Maximum number of contacts to return (default 50)
  • offset (number, optional): Offset for pagination (default 0)

Returns:

AdapterOperationResult - Returns { contacts[], totalCount, limit, offset, hasMore }. Each contact has FLAT fields: contactId, userId, username, profilePhoto, groupId, isContact. No nested objects.

Response Fields:

FieldTypeDescription
contactsMirraMessagingContact[]List of contacts
contacts item fields (MirraMessagingContact)
FieldTypeDescription
contactIdstringContact record ID
userIdstringUser ID
usernamestringUsername
profilePhoto`stringnull`
groupId`stringnull`
isContactbooleanWhether user is a contact

| totalCount | number | Total available contacts | | limit | number | Items per page | | offset | number | Current offset | | hasMore | boolean | Whether more items exist |

Example:

const result = await mirra.mirraMessaging.getContacts({});

findContact

Find a contact by username or partial name match. Returns normalized flat structures.

Arguments:

  • query (string, required): Username or name to search for

Returns:

AdapterOperationResult - Returns { contacts[], users[], query, contactCount, userCount }. Each entry has FLAT fields: contactId, userId, username, profilePhoto, groupId, isContact. No nested objects.

Response Fields:

FieldTypeDescription
contactsMirraMessagingContact[]Matching contacts
contacts item fields (MirraMessagingContact)
FieldTypeDescription
contactIdstringContact record ID
userIdstringUser ID
usernamestringUsername
profilePhoto`stringnull`
groupId`stringnull`
isContactbooleanWhether user is a contact

| users | MirraMessagingContact[] | Matching non-contact users |

users item fields (MirraMessagingContact)
FieldTypeDescription
contactIdstringContact record ID
userIdstringUser ID
usernamestringUsername
profilePhoto`stringnull`
groupId`stringnull`
isContactbooleanWhether user is a contact

| query | string | Search query used | | contactCount | number | Number of matching contacts | | userCount | number | Number of matching users |

Example:

const result = await mirra.mirraMessaging.findContact({
  query: "example"
});

getChats

Get list of chat instances for the user. Returns normalized flat structures.

Arguments:

  • scope (string, optional): Filter by scope: direct, user, group, or all (default all)
  • limit (number, optional): Maximum number of chats to return (default 50)

Returns:

AdapterOperationResult - Returns { chats[], count }. Each chat has FLAT fields: chatInstanceId, title, scope, lastMessageAt, lastMessagePreview, messageCount, peerUserId, peerUsername, peerProfilePhoto, groupId, groupName, groupProfileImage. No nested objects.

Response Fields:

FieldTypeDescription
chatsMirraMessagingChat[]List of chat instances
chats item fields (MirraMessagingChat)
FieldTypeDescription
chatInstanceIdstringChat instance ID
titlestringChat title
scope``'direct''user'
lastMessageAt`stringnull`
lastMessagePreview`stringnull`
messageCountnumberTotal message count
peerUserId`stringnull`
peerUsername`stringnull`
peerProfilePhoto`stringnull`
groupId`stringnull`
groupName`stringnull`
groupProfileImage`stringnull`

| count | number | Number of chats returned |

Example:

const result = await mirra.mirraMessaging.getChats({});

getGroups

Get list of groups the user is a member of. Returns normalized flat structures.

Arguments:

  • limit (number, optional): Maximum number of groups to return (default 50)

Returns:

AdapterOperationResult - Returns { groups[], count }. Each group has FLAT fields: groupId, name, description, profileImage, role, joinedAt. No nested objects.

Response Fields:

FieldTypeDescription
groupsMirraMessagingGroup[]List of groups
groups item fields (MirraMessagingGroup)
FieldTypeDescription
groupIdstringGroup ID
namestringGroup name
description`stringnull`
profileImage`stringnull`
rolestringUser role in group
joinedAtstringJoin timestamp (ISO 8601)

| count | number | Number of groups returned |

Example:

const result = await mirra.mirraMessaging.getGroups({});

createGroup

Create a new group. The authenticated user becomes the group owner. Returns normalized flat structure.

Arguments:

  • name (string, required): Group name (max 100 characters)
  • description (string, optional): Group description (max 500 characters)
  • category (string, optional): Category for organization: "family", "friends", "work", or "other" (default: "other")
  • memberIds (array, optional): Array of user IDs to add as initial members

Returns:

AdapterOperationResult - Returns FLAT structure with: groupId, chatInstanceId, name, description, category, createdBy, memberCount, createdAt, linkUrl, linkLabel. No nested objects.

Response Fields:

FieldTypeDescription
groupIdstringCreated group ID
chatInstanceIdstringChat instance ID
namestringGroup name
description`stringnull`
categorystringGroup category
createdBystringCreator user ID
memberCountnumberInitial member count
createdAtstringCreation timestamp (ISO 8601)
linkUrlstringDeep link URL to group chat
linkLabelstringDisplay label for link

Example:

const result = await mirra.mirraMessaging.createGroup({
  name: "example"
});

searchMessages

Search chat messages by keywords. Returns summaries by default to avoid overwhelming context. Use includeFullText for complete messages.

Arguments:

  • query (string, required): Keywords to search for
  • contactName (string, optional): Contact name to filter by sender (resolved to userId)
  • groupName (string, optional): Group name to limit search (resolved to groupId)
  • groupId (string, optional): Group ID to limit search (use groupName for name-based lookup)
  • scope (string, optional): "direct", "group", or "all" (default)
  • startDate (string, optional): ISO date for time range start
  • endDate (string, optional): ISO date for time range end
  • includeFullText (boolean, optional): Include full message text (default: false, returns snippets)
  • snippetLength (number, optional): Max chars for snippet (default: 200)
  • limit (number, optional): Max results (default 20, max 50)
  • offset (number, optional): Pagination offset

Returns:

AdapterOperationResult - Returns { messages[], totalCount, limit, offset, hasMore, query, summaryMode }. Each message has FLAT fields: messageId, chatInstanceId, groupId, groupName, senderId, senderUsername, snippet, text (if includeFullText), timestamp, scope, relevanceScore, isFromMe, chatType, messageLength. No nested objects.

Response Fields:

FieldTypeDescription
messagesMirraMessagingSearchMessage[]Matching messages
messages item fields (MirraMessagingSearchMessage)
FieldTypeDescription
messageIdstringMessage ID
chatInstanceIdstringChat instance ID
groupId`stringnull`
groupName`stringnull`
senderIdstringSender user ID
senderUsernamestringSender username
snippetstringMessage snippet around matched keywords
text`stringnull`
timestampstringMessage timestamp (ISO 8601)
scope``'direct''group'``
relevanceScorenumberSearch relevance score
isFromMebooleanWhether message is from authenticated user
chatType``'direct''group'``
messageLengthnumberFull message length in characters

| totalCount | number | Total matching messages | | limit | number | Items per page | | offset | number | Current offset | | hasMore | boolean | Whether more results exist | | query | string | Search query used | | summaryMode | boolean | Whether results are in summary mode |

Example:

const result = await mirra.mirraMessaging.searchMessages({
  query: "example"
});

On this page