Saltar al contendio prinicipal

Messages Data Model

Advertencia

Esta página aún no se encuentra traducida al español.

COTMessage

Description

A message model (COTMessage) contains all the information concerning a particular message sent through the channel workspace chat. Messages can contain text, multimedia files, answered surveys, or system-generated responses.

When displaying a form, i.e., a submitted survey, there is a message for each answered survey question displayed in the chat. If a submitted survey has two questions, two corresponding messages are sent.

JSON Samples

Text Message

{
"_id": "6140e8a49d0ad6efd374ab7f",
"channel": "6140e8bafaddd3a2f4fc743c",
"content": "Hello, world!",
"contentType": "text/plain",
"createdAt": 1630947233455,
"isActive": true,
"isHidden": false,
"isSaved": 16,
"modifiedAt": "2021-09-06T16:54:14.517Z",
"sentBy": "6140e8c5745ce660679a3da4",
}

Survey Message

{
"_id": "6140e8df7ba70ee0d3e7aaba",
"answer": "613fd15cc7d8ac89ff82d9c9#613fd0e14a8541000782ed58",
"channel": "6140e8bafaddd3a2f4fc743c",
"contentArray": [
"613fd0e14a8541000782ed5c",
"613fd0e14a8541000782ed5d"
],
"contentType": "application/vnd.cotalker.survey",
"createdAt": 1631572327913,
"form": {
"modifiedAt": [
"2021-09-13T22:32:07.911Z"
],
"id": "613fd1674a8541000782f29e",
"createdAt": "2021-09-13T22:32:07.911Z"
},
"isActive": true,
"isSaved": 16,
"modifiedAt": "2021-09-13T22:32:07.926Z",
"modifiedLocal": 1631572327639,
"responses": [
{
"cdata": [],
"_id": "613fd1674a8541000782f2a3",
"cref": "613fd0e14a8541000782ed5c"
},
{
"cdata": [
"{\"_id\":\"613fd0154a8541000782eb14\",\"subproperty\":[],\"isActive\":true,\"name\":{\"code\":\"nyc_00\",\"display\":\"New York\"},\"propertyType\":\"location\",\"company\":\"600ac7d8df5461626aac89c0\",\"createdAt\":\"2021-09-13T22:26:29.673Z\",\"modifiedAt\":\"2021-09-13T22:26:29.686Z\"}"
],
"_id": "613fd1674a8541000782f2a4",
"cref": "613fd0e14a8541000782ed5d"
}
],
"sentBy": "600ac7d8df54617a28ac89ff"
}

Field

FieldDescriptionTypeNotes
_idMessage ID numberObjectId<COTMessage>
answerA survey answer that is sent back as a message in the channel workspaceObjectId<COTAnswer.uuid> #ObjectId<COTSurvey>Answers Model, Survey Model
channelThe channel the message is sent inObjectId<COTChannel>Channel Model
contentDisplayed data; could be user text input, system message, or file object.stringFor details about the type of content allowed, go to COTMessageContentType.
contentArrayArray of answered survey questionsCOTQuestion[ ]Questions Model
contentPartsIndicates the format and content to use in each part of an enriched message. Required with text/enriched content types.Object[ ]See samples.
contentParts[x].typeContent part types include: text, link, hover, and task.stringRequired with text/enriched content types.
contentParts[x].contentThe text displayed in the message. In case of link, hover, and task types, the text is linked to the respective payload data.stringRequired with text/enriched content types.
contentParts[x].payloadThe data linked to the text in contentParts.content. Each contentParts.type has a specific payload object.objectRequired with text/enriched content types.
contentParts[x].payload.urlIndicates the linked URL when using the link type.stringRequired when using the link enriched message type.
contentParts[x].payload.cardThe data displayed when hovering over hover type content.objectRequired when using the hover enriched message type.
contentParts[x].payload.card.imageURL of the image that is displayed on the pop-up card.stringRequired when using the hover enriched message type.
contentParts[x].payload.card.textThe text that is displayed on the pop-up card.stringRequired when using the hover enriched message type.
contentParts[x].payload.companyObjectId of the company in which the message is sent.ObjectId<COTCompany>Required when using the task enriched message type.
contentParts[x].payload.taskObjectId of the task that is linked to the contentParts.content text.ObjectId<COTTask>Required when using the task enriched message type.
contentParts[x].payload.taskGroupObjectId of the task group in which the task is found.ObjectId<COTTaskGroup>Required when using the task enriched message type.
contentTypeIndicates content type, for example: text/plain (user text input), application/vnd.cotalker.survey (answered survey), application/pdf (pdf file), image/gif (uploaded gif image)stringFor a complete list of content types, go to COTMessageContentType.
createdAtThe date and time the message was creatednumberUnix epoch time format
extendsAnswerExtra information added to a survey question's answer through another surveystringSuperseded by COTQuestionContentType survey+survey available through messages.contentArray.
formGeneral information of a submitted form.objectA copy of the question responses can be found in messages.responses
form.createdAtDate the form was originally submittedISODateYYYY-MM-DDTHH:mm:ss.SSSZ
form.idContains the main-survey ID, unique for the entire submitted survey.ObjectIdThis ID is present in all the messages corresponding to answered survey questions. It is also present in the corresponding Answers Data Models as answers.formId.
form.modifiedAtList of dates the form was modifiedISODate[ ]YYYY-MM-DDTHH:mm:ss.SSSZ
form.subidcontains the sub-survey ID, unique per sub-survey (null for the non-sub-survey parts)ObjectId
isHiddenUsed to hide sent messages from the view of other users in the chat roombooleanWhen users choose to delete a message from the channel's workspace, this option is set to true; messages are never truly deleted, just hidden.
isSavedUsed to indicate the message state. 2 is used for sending a regular message; 8 is used for sending unanswered surveys; 16 is used to indicate a message has already been delivered.numberUse with precaution; consult the Cotalker Platform Community for further details
replyList of messages this message is replying toObjectID<COTMessage>[ ]
modifiedAtDate and time last modifiedISODateYYYY-MM-DDTHH:mm:ss.SSSZ
modifiedLocalDate and time last modifiednumberUnix epoch time format
responsesResponses refer to an answered survey question. Sometimes, responses come in pairs, the first response object contains the field label, the second, the submitted data.object[ ]Check messages.form for the forms identification data
responses[x].cdataContains the responses submitted to a given survey questionstring[ ]
responses[x].crefReferences the questionObjectId<COTQuestion>Question Model
reactionsEmoji reactions to messageobjectEmojis used on message appear as object keys, e.g., reactions.laugh, reactions.rocket
sentByIndicates the ID number of the user that sent the messageObjectId<COTUser>User Model

Deprecated or Not to be used

FieldDescriptionTypeNotes
cmdUsed in mobile apps to calculate and save commanded message visibilityobjectDEPRECATED
cmd.idsList of users I can commandObjectID<COTUser>[ ]DEPRECATED
cmd.byUser that commands meObjectId<COTUser>DEPRECATED
cmd.status1: ids calculated; 2: by calculated; 3: bothnumberDEPRECATED
cmd.visibilityMy current statebooleanDEPRECATED
isActiveUsed for hiding messages; replaced by messages.isHiddenbooleanDEPRECATED
responses[x]._idAutomatically generated internal system codeObjectIdNot to be used
readByUsers that have read the messageObjectId<COTUser>[ ]DEPRECATED

Additional Resources

Help