Emit this socket event to send a chat message. The Avaya Spaces socket server will emit either SEND_MESSAGE_FAILED(if message was not sent) or MESSAGE_SENT (if message was sent successfully).
The failure response is the same, unless a wrong topic id was entered, then the response payload will be of type "app.event.channel.subscription.required".
To create posts: /api/spaces/{spaceid}/ideas or tasks: /api/spaces/{spaceid}/tasks
The same can be achieved with sending either SEND_MESSAGE's 'task' or 'idea' payload.
Payload Parameters
Name | Description | JSON type |
---|
category | Type of message to send, can be: 'chat', 'idea', 'task' | string |
chatMessages | - messages: (array) array of chat messages
- previousPageUrl: (string) used with pagination API. Either "", or URL string with path to previous page.
- nextPageUrl: (string) used with pagination API. Either "", "end" or URL string with path to next page.
chatMessages: object, has two keys : messages(array); previousPageUrl (string); nextPageUrl (string) (URL, "" or "end") | object |
content | - bodyText: (string) message text to send
- assignees: (array) list of people the message is assigned to. Used in 'task' type response only.
- _id: (string) id of a person, who the task is assigned to
- data: (array) objects representing attached files
- fileId: (string) fileKey from /files/getuploadurl
- fileSize: (int) size of file in bytes
- fileType: (string) 'image', 'video', 'audio', or (default) 'document'
- icon: (string) Not currently in use
- name: (string) file name
- provider: (string) 'native'
- providerFileType: (string) MIME type
- description: (string) optional description.
- dueDate: (string) date when the task is due.
- status: (string) status of the message, default is "pending".
| Object |
parentMsg | Object containing the data of the parent post or task- _id: (string) unique identifier of the post/task
| Object |
topicId | Unique identifier of topic to send message to. Note: Direct messages are sent to a topic with only 2 members. To retrieve the topicId for a direct message see /spaces/direct/{userType}/{userId}. | string |
sender | - _id: (string) id of the sender.
- type: (string) sender's type. Can be either "user" or "anonymous"
| string |
Authorization
None.
Example
socketConnection.emit('SEND_MESSAGE', payload);
Payload Sent ('chat'), when sending a text value
{
"category": "chat",
"chatMessages": {
},
"content": {
"bodyText": "<p>Random text</p>",
"data": [
],
"description": ""
},
"topicId": "5f1051f0f3ed772f915f19ed"
}
Payload Sent ('chat'), when sending a file value
{
"category": "chat",
"chatMessages": {
},
"content": {
"assignees": [
],
"bodyText": "",
"data": [
{
"fileId": "152b23dd-0b80-426f-9ec6-b8389f11ae42",
"fileSize": 924,
"fileType": "document",
"icon": "",
"name": ".gitignore",
"provider": "native",
"providerFileType": "text/plain"
}
],
"description": "",
"dueDate": "",
"status": "pending"
},
"topicId": "5f1051f0f3ed722f915e19ed"
}
Payload ('idea') - in this case, idea is a post
{
"category":"idea",
"chatMessages":{
},
"topicId":"5f1051f0f3ed722f915e19ed",
"content":{
"bodyText":"asdas",
"assignees":[
],
"description":"<p>dasdadasd</p>",
"data":[
{
"fileId":"474af505-d32f-49c2-b07a-b9df43cd5246",
"fileSize":77,
"fileType":"document",
"icon":"",
"name":"testimport.csv",
"provider":"native",
"providerFileType":"application/vnd.ms-excel"
}
],
"dueDate":"",
"status":"pending"
}
}
Payload ('task')
{
"category":"task",
"chatMessages":{
},
"topicId":"5f06c25e574ca36b54cb4cdf",
"content":{
"bodyText":"Test task",
"assignees":[
{
"_id":"5f0426ccaa4a347af9994cdf"
}
],
"description":"<p>A test task</p>",
"data":[
{
"fileId":"511b26c0-0c2d-45cf-93f3-445f91aeade2",
"fileSize":77,
"fileType":"document",
"icon":"",
"name":"testimport.csv",
"provider":"native",
"providerFileType":"application/vnd.ms-excel"
}
],
"dueDate":"2020-07-20T09:45:40.618Z",
"status":"pending"
}
}
Payload ('chat'), with parent post or task
{
"category": "chat",
"content": {
"bodyText": "<p>Random text</p>",
"data": [
]
},
"parentMsg": {
"_id": "5f1052c2d371313d0ca8ce3a"
},
"sender": {
"_id": "5f04251caa4a347bf9946e99",
"type": "user"
},
"topicId": "5f1051f0f3ed772f915e1923"
}