Skip to content

Messenger

Messaging: discussions, messages, invites, unread counts, settings, and typing state.

Endpoints

EndpointArgumentsReturns
messenger.discussion_linksObjectIdobject[]
messenger.find_user_discussionObjectIdobject
messenger.get_unread_countunknownobject
messenger.invite_usersObjectId, unknownunknown
messenger.join_event_discussionObjectIdobject
messenger.leave_discussionunknown, ObjectIdobject
messenger.load_discussionsunknown, optionsobject[] | Record<string, object> | object
messenger.load_messagesObjectId, optionsobject[]
messenger.save_discussion_settingsoptionsunknown
messenger.sendmessage, discussionIdobject
messenger.set_discussion_last_seenObjectIdunknown
messenger.set_discussion_typing_stateObjectId, unknown, unknownboolean

Description

List discussion links

Parameters

Argument 1 (ObjectId, required): discussionId

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.discussion_links', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);

Returns

Array of objects:

FieldTypeRequiredDescription
uidstringyesuserId
linkstringyeslink
datetimestampyesTime (milliseconds since 1970-01-01 UTC)
messageTextstringyes

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.find_user_discussion

Description

Find private discussion with user

Parameters

Argument 1 (ObjectId, required): withUid

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.find_user_discussion', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);

Returns

FieldTypeRequiredDescription
_idObjectIdyes
createdtimestampyesTime (milliseconds since 1970-01-01 UTC)
uidObjectIdyes
participantsObjectId[]yes
subjectstringno
privatebooleanno
descriptionstringno
updatedtimestampnoTime (milliseconds since 1970-01-01 UTC)
cidObjectIdno
last_activetimestampnoTime (milliseconds since 1970-01-01 UTC)
linked_activityObjectIdno
processObjectIdno
linked_tasklistObjectIdno
linked_eventObjectIdno
last_seenobject[]no
cover_pictureObjectIdno
isStarredbooleanyes
isMutedbooleanno
membersobject[]no
moderatorsuserId[]no

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.get_unread_count

Description

Get unread messages count for discussion

Response:

json
{
  "<discussionId-1>": 3
  "<discussionId-2>": 7
}

Parameters

Argument 1 (any \| ObjectId \| ObjectId[], optional):

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.get_unread_count', [
  '...', // argument 1
]);
console.log(result);

Returns

Record<string, number>

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.invite_users

Description

Invite users to discussion

Emits signal to participants discussion.updated({ discussion: ObjectId })

Parameters

Argument 1 (ObjectId, required): discussionId

Argument 2 (ObjectId[] \| ObjectId, required):

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.invite_users', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  ['507f1f77bcf86cd799439011'], // argument 2 (required)
]);
console.log(result);

Returns

Undocumented

The return value is not described in the source yet.

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.join_event_discussion

Description

Join calendar event discussion

Parameters

Argument 1 (ObjectId, required):

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.join_event_discussion', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);

Returns

FieldTypeRequiredDescription
_idObjectIdyes
createdtimestampyesTime (milliseconds since 1970-01-01 UTC)
uidObjectIdyes
participantsObjectId[]yes
subjectstringno
privatebooleanno
descriptionstringno
updatedtimestampnoTime (milliseconds since 1970-01-01 UTC)
cidObjectIdno
last_activetimestampnoTime (milliseconds since 1970-01-01 UTC)
linked_activityObjectIdno
processObjectIdno
linked_tasklistObjectIdno
linked_eventObjectIdno
last_seenobject[]no
cover_pictureObjectIdno
isStarredbooleanyes
isMutedbooleanno
membersobject[]no
moderatorsuserId[]no

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.leave_discussion

Description

Leave discussion

First argument may be a single discussion ID or an array of IDs. Single ID: void on success, throws on error (e.g. lone admin, ball holder must pass first). Array: runs leave logic per discussion (duplicate IDs are processed once), never throws on per-item failures, returning { left, skipped }. passToUserId is honored only on the single-ID path; in the array path, discussions where the caller holds the ball are skipped.

Parameters

Argument 1 (ObjectId \| ObjectId[], required):

Argument 2 (ObjectId, optional): passToUserId for single-discussion ball pass on leave

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.leave_discussion', [
  '507f1f77bcf86cd799439011', // argument 1 (required)
  '507f1f77bcf86cd799439011', // ObjectId
]);
console.log(result);

Returns

FieldTypeRequiredDescription
leftObjectId[]yes
skippedObjectId[]yes

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.load_discussions

Description

Load discussions

json
{
  ...
  last_seen: { "userId": isoDateString }
}

Parameters

Argument 1 (ObjectId \| ObjectId[] \| any, optional):

Argument 2 (object, optional):

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.load_discussions', [
  '507f1f77bcf86cd799439011', // argument 1
  { /* ... */ },
]);
console.log(result);

Returns

object[] \| Record<string, object> \| object

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.load_messages

Description

Load messages from discussion

Parameters

Argument 1 (ObjectId, required): discussionId

Argument 2 (object, optional):

FieldTypeRequiredDescription
attachmentsOnlybooleanno
filterstringno
skipintegernoDefault: 0.
msg_idObjectId | ObjectId[]no
newestObjectIdno
limitintegerno

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.load_messages', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  {
    attachmentsOnly: false,
    filter: 'string',
  },
]);
console.log(result);

Returns

Result form 1:

Array of objects:

FieldTypeRequiredDescription
_idObjectIdyesMessage id
createdtimestampyesTimestamp of when the message was sent
updatedtimestampnoTimestamp of when the message was last updated
removedtimestampnoTimestamp of when the message was deleted
editedtimestampnoTimestamp of when the message last edited
locobjectnoMessage location data
fromuserIdnoSender user id
uiduserIdnoSender user id
discussiondiscussionIdnoDiscussion id
typeuser | user.join | user.leave | activity.created | activity.updated | activity.removed | linked.activity.created | linked.activity.moved | event.new | event.updated | event.removed | event.going | event.notgoing | event.attend_response | discussion.invites | discussion.removesinvites | meet.start | meet.end | ball.passed | ball.passed_by | ball.taken | ball.cleared | ball.auto_assigned | collapsednoType of the message
metastring[] | object | stringnoMeta data of the message
msgstringnoThe contents of the message
filesfileId[]noAttached files
taggedobjectno
_metasobjectno
localIdentifierstringno
replyToObjectIdnoId of the reply message
replyMessageobjectnoReply message
reactionsRecord<string, string[]>noMessage user reactions
starsobject[]no
isStarredbooleanno
linkedDataarrayno
scheduledbooleanno
cidWorkspaceIdnoworkspaceId (former networkId)
deleteAtDatenoDate after which the message should be automatically deleted (BSON Date for MongoDB TTL)
forwardMessageobjectno

Result form 2:

FieldTypeRequiredDescription
_idObjectIdyesMessage id
createdtimestampyesTimestamp of when the message was sent
updatedtimestampnoTimestamp of when the message was last updated
removedtimestampnoTimestamp of when the message was deleted
editedtimestampnoTimestamp of when the message last edited
locobjectnoMessage location data
fromuserIdnoSender user id
uiduserIdnoSender user id
discussiondiscussionIdnoDiscussion id
typeuser | user.join | user.leave | activity.created | activity.updated | activity.removed | linked.activity.created | linked.activity.moved | event.new | event.updated | event.removed | event.going | event.notgoing | event.attend_response | discussion.invites | discussion.removesinvites | meet.start | meet.end | ball.passed | ball.passed_by | ball.taken | ball.cleared | ball.auto_assigned | collapsednoType of the message
metastring[] | object | stringnoMeta data of the message
msgstringnoThe contents of the message
filesfileId[]noAttached files
taggedobjectno
_metasobjectno
localIdentifierstringno
replyToObjectIdnoId of the reply message
replyMessageobjectnoReply message
reactionsRecord<string, string[]>noMessage user reactions
starsobject[]no
isStarredbooleanno
linkedDataarrayno
scheduledbooleanno
cidWorkspaceIdnoworkspaceId (former networkId)
deleteAtDatenoDate after which the message should be automatically deleted (BSON Date for MongoDB TTL)
forwardMessageobjectno

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.save_discussion_settings

Description

Set discussion details

Parameters

Argument 1 (object, optional):

FieldTypeRequiredDescription
_idObjectIdyes
subjectstringno
participantsObjectId[]no
cover_pictureObjectIdnoDefault: null.

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.save_discussion_settings', [
  {
    _id: '507f1f77bcf86cd799439011',
  },
]);
console.log(result);

Returns

Undocumented

The return value is not described in the source yet.

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.send

Description

Send message

Send a message to a discussion

Emits signal messenger.new({ discussion, uid, msg_id, msg_type: "user" | "??" })

Parameters

Argument 1 (message, required):

FieldTypeRequiredDescription
msgstringno
subjectstringno
filesfileId[]no
locobjectnoDefault: null.
participantsuserId[]noparticipants
localIdentifierstringnolocalIdentifier
replyToObjectIdnomessageId
forwardMessageIdObjectIdnomessageId
replyPrivatelybooleannoIndicator that we are replying privately to forwarded message
linksarrayno
metaobjectnoOptional metadata (e.g. AI context), max 50 keys
scheduledbooleanno
scheduleTimetimestampnoTime (milliseconds since 1970-01-01 UTC)

Argument 2 (discussionId, optional): discussionId

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.send', [
  {
    msg: 'string',
    subject: 'string',
  },
  '507f1f77bcf86cd799439011', // discussionId
]);
console.log(result);

Returns

FieldTypeRequiredDescription
_idObjectIdyesMessage id
createdtimestampyesTimestamp of when the message was sent
updatedtimestampnoTimestamp of when the message was last updated
removedtimestampnoTimestamp of when the message was deleted
editedtimestampnoTimestamp of when the message last edited
locobjectnoMessage location data
fromuserIdnoSender user id
uiduserIdnoSender user id
discussiondiscussionIdnoDiscussion id
typeuser | user.join | user.leave | activity.created | activity.updated | activity.removed | linked.activity.created | linked.activity.moved | event.new | event.updated | event.removed | event.going | event.notgoing | event.attend_response | discussion.invites | discussion.removesinvites | meet.start | meet.end | ball.passed | ball.passed_by | ball.taken | ball.cleared | ball.auto_assigned | collapsednoType of the message
metastring[] | object | stringnoMeta data of the message
msgstringnoThe contents of the message
taggedobjectno
_metasobjectno
localIdentifierstringno
replyToObjectIdnoId of the reply message
replyMessageobjectnoReply message
reactionsRecord<string, string[]>noMessage user reactions
starsobject[]no
isStarredbooleanno
linkedDataarrayno
scheduledbooleanno
cidWorkspaceIdnoworkspaceId (former networkId)
deleteAtDatenoDate after which the message should be automatically deleted (BSON Date for MongoDB TTL)
forwardMessageobjectno
filesfileId[]no

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.set_discussion_last_seen

Description

Update discussion last seen to now

Parameters

Argument 1 (ObjectId, required): discussionId

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.set_discussion_last_seen', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
]);
console.log(result);

Returns

Undocumented

The return value is not described in the source yet.

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

messenger.set_discussion_typing_state

Description

Set user is typing state

Emits signal to participants discussion.typing({ discussion, typing, uid, statusText? })

Parameters

Argument 1 (ObjectId, required): discussionId

Argument 2 (boolean, required): typingState

Argument 3 (string, optional): statusText

Example

javascript
const { Client } = require('@hailer/cli');

const client = await Client.create({
  host: 'https://api.hailer.com',
  username: 'you@example.com',
  password: '••••••',
});

const result = await client.request('messenger.set_discussion_typing_state', [
  '507f1f77bcf86cd799439011', // ObjectId (required)
  false, // typingState (required)
  'string', // statusText
]);
console.log(result);

Returns

boolean

Auth: requires an authenticated session.

Errors: on failure returns the standard Hailer error object { code, msg, details?, debug? }.

Hailer Developer Documentation · v1.3.4