PostMessage¶
Posts a new message to a channel.
1 |
|
Parameters¶
string channelId
The ID of the channel to post the message to.
ChannelMessage 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 with no Case instance.
Create an activity:¶
1 2 3 4 |
|
Create a case:¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Types¶
ChannelMessage¶
Represents a message within a channel.
Attachments
: Array<ChannelMessageAttachment>
An array of attachments for the message.
Content
: string
The content of the message. Optional. 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.
ChannelMessageAttachment¶
Represents an attachment to a channel message.
displayName
: string
The display name of the attachment.
ext
: string
The file extension, if the attachment is a file type.
id
: string
The ID of the attachment. Optional.
type
: ( "file"
| "url"
)
The type of attachment.
url
: string
The URL of the attachment, if it is a URL type.
ChannelMessageResult¶
Represents the result of posting a channel message.
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).