Skip to content

PostMessage

Posts a new message to a channel.

1
$Domain.PostMessage(channelId: string, msg: `Attachments` : Array<`displayName` : ( ... | ... )

The display name of the attachment.

ext : ( ... | ... )
The file extension, if the attachment is a file type.

id : ( ... | ... )
The ID of the attachment. Optional.

type : ( ... | ... | ... )
The type of attachment.

url : ( ... | ... )
The URL of the attachment, if it is a URL type.>
An array of attachments for the message.

Content : string
The content of the message. Optional. This is the same as

Description : string
The description of the message. Optional.

Id : string
The ID of the message. Optional. Must be a string with a maximum length of 1024 characters.

References : Array
An array of IDs referencing previously sent messages. Optional.

Subject : string
The subject of the message. Optional.):Case : Case
The instance of the

Id : string
The ID of the activity message. This may be a new ID if a message with the given ID does not exist.

IsNew : boolean
A value indicating whether the message is new (not seen before).

Parameters

string channelId
    The ID of the channel to post the message to.

Attachments : Array<displayName : ( ... | ... )
The display name of the attachment.

ext : ( ... | ... )
The file extension, if the attachment is a file type.

id : ( ... | ... )
The ID of the attachment. Optional.

type : ( ... | ... | ... )
The type of attachment.

url : ( ... | ... )
The URL of the attachment, if it is a URL type.>
An array of attachments for the message.

Content : string
The content of the message. Optional. This is the same as

Description : string
The description of the message. Optional.

Id : string
The ID of the message. Optional. Must be a string with a maximum length of 1024 characters.

References : Array
An array of IDs referencing previously sent messages. Optional.

Subject : string
The subject of the message. Optional. msg
    The message properties.

Returns

A ChannelMessageResult instance containing the results of the operation.

Remarks

This method performs different actions depending on whether the given input has an Id property:

  • If no Id is specified, it simply posts a new activity message on the channel with the given subject and content. This is useful for notification purposes.
  • When an Id is given, the method first checks if a message with the specified Id was previously sent on the channel. If a previously sent message is found, it does not create a new activity and returns the existing Case instance.
  • If the input contains a references property, it also checks for previously sent messages with the referenced IDs. If any reference is found, it creates a new activity that is linked to the matching case and returns the existing Case instance.
  • When nothing matches, it creates a new Case on the channel with the activity and returns it.
  • If case management is not enabled on the channel, it always posts a new activity on the channel without a Case instance.

Create an activity

1
2
3
4
$Domain.PostMessage('22e8f630-aca2-4f55-ae25-138911190957', {
    subject : 'hello',
    description : 'hi team members'
});

Create a case

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
// First message to create the case
$Domain.PostMessage('22e8f630-aca2-4f55-ae25-138911190957', {
    id : 'first'
    subject : 'hello',
    description : 'hi team members'
});

// Continuation of the case
$Domain.PostMessage('22e8f630-aca2-4f55-ae25-138911190957', {
    id : 'second',
    references : ['first'],
    subject : 'hello again',
    description : 'second message of case'
});

See Also

Id : string
The ID of the activity message. This may be a new ID if a message with the given ID does not exist.

IsNew : boolean
A value indicating whether the message is new (not seen before). * ChannelMessageResult * Case * ChannelMessage.Description