{{sidenavigation.sidenavigationExpandLabel}}
{{getMsg('Help_YouAreHere')}}: {{page.title}} {{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}} {{helpModel.downloadHelpPdfDataStatus}}

Bot-Message

A Bot-Message can only be send by administrative team users. They can not, however, read messages in channels due to the privacy concept. Bot-Messages can be used to inform users in all channels about important events, such as a server reboot.

POST /api/cowork/admin/admin/teams/<teamID>/channels/<channelID>/botmessage and PUT /api/cowork/admin/teams/<teamID>/channels/<channelID>/botmessage

Send a message to the given team using the Bot user and the following JSON. The response is the ID of the newly created message.

{
    "text":        "<The text to send to the channel>",
    "attachments": [ <attachment descriptions> ]
}
REQUEST Fields Value Type Description
text String The optional text message to send to the channel
attachments String Optional list of attachments to send along with the message. See Attachment Description

Note: Either the text or attachments field have to filled.

Example Request

# Request
# Use user:password for authorization
POST /api/cowork/admin/teams/3n1ytbwme7ngfyn9g9guwwurt/channels/3y8kdto0lnx3ig3mshwvrb9x7/botmessage HTTP/1.1
Accept: */*
Authorization: Bearer VGhpcyBpcyBqdXN0IGEgZGVtbyBhY2Nlc3MgdG9rZW4u
 
{"text":"Hey there."}
 
 
# Response
HTTP/1.1 200 OK
Content-Type: application/json
"00kunwfaycw5sqp8gc8kc0jms"

Attachment Description

Attachments can be sent using a Multipart request to the API. They have to accompanied by the JSON definition or they will be discarded.

Your JSON part has to define the attachment in the following way:

{
    "name":           "filename.ext",
    "lastModified":   <Datetime>,
    "attachmentType": <AttachmentType>,
    "previewWidth":   <Number>,
    "previewHeight":  <Number>
}
REQUEST Fields Value Type Description
name String The name of the file
lastModified Datetime The date time in milliseconds
attachmentType AttachmentType This value is optional. One of the following values:
"Unknown"
"Attachment"
"EmbeddedImage"
"Signature"
previewWidth Number An optional preview width size in pixels
previewHeight Number An optional preview height size in pixels

Note: If you are sending attachments to the server, you have to use a multipart/form-data content type. Each part has to have a specific name: json for the part containing the message JSON; attachmentX for every additional attachment, where X is a number starting at 0.

# cURL example
 
curl --request POST \
  --url https://127.0.0.1:9000/api/cowork/admin/teams/3n1ytbwme7ngfyn9g9guwwurt/channels/3y8kdto0lnx3ig3mshwvrb9x7/botmessage \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'json={"text":"Hi there","attachments":[{"name":"first image.jpg","lastModified":1680774451041,"attachmentType":"Unknown","previewWidth":100,"previewHeight":100},{"name":"second image.jpg","lastModified":1680774451041,"attachmentType":"Unknown","previewWidth":100,"previewHeight":100}]}' \
  --form attachment0=@/Users/dev/Downloads/image1.jpg \
  --form attachment1=@/Users/dev/Downloads/image2.jpg
i-net CoWork
This application uses cookies to allow login. By continuing to use this application, you agree to the use of cookies.


Help - /botmessages