getMessages(options);
Call this method to get messages from the chat room.
JavaScript
const messages = await sdk.getMessages(skip);
getMessages(options)
Parameter Name | Description | Type | Required |
---|---|---|---|
skip | 18 messages are returned when you call this method in descending order. Set the skip to the number of messages you want to skip in the call | Integer | No |
Example
The code snippet below prints the latest 18 messages from the chat.
const messages = await sdk.getMessages();
console.log("Messages", messages);
Properties
Properties | Description | Type |
---|---|---|
messages | Array of messages in the chat room | Array of Message |
eventId | Internal field | string |
Message
Properties | Description | Type |
---|---|---|
_id | id of the message | String |
likes | number of likes of the message | Array |
created | timestamp when the message was sent | Date |
message | the message itself | String |
user | user object that contains details about the user | Object |
_id | userId | String |
username | username of the user | String |
customer | customerID | String |
User
Properties | Description | Type |
---|---|---|
_id | id of the user | String |
username | username of the user | String |
JSON Sample Response
{
"eventId": "f97f775e-8ce2-432a-b309-c7660b609207",
"messages": [
{
"_id": "63237f8ef0357f1c64879194",
"likes": [],
"created": "2022-09-15T19:39:58.157Z",
"chatRoom": "631794a83671700c713b1ce6",
"message": "ghfhf",
"user": {
"_id": "63233015c3aa3508a4c8fc34",
"username": "bobob"
},
"customer": "631794a83671700c713b1ce5",
"__v": 0
},
{
"_id": "63237f54f0357f1c64879193",
"likes": [],
"created": "2022-09-15T19:39:00.413Z",
"chatRoom": "631794a83671700c713b1ce6",
"message": "sdfsd",
"user": {
"_id": "63233015c3aa3508a4c8fc34",
"username": "bobob"
},
"customer": "631794a83671700c713b1ce5",
"__v": 0
},
{
"_id": "63237f53f0357f1c64879192",
"likes": [],
"created": "2022-09-15T19:38:59.703Z",
"chatRoom": "631794a83671700c713b1ce6",
"message": "fsdf",
"user": {
"_id": "63233015c3aa3508a4c8fc34",
"username": "bobob"
},
"customer": "631794a83671700c713b1ce5",
"__v": 0
},
{
"_id": "63237f52f0357f1c64879191",
"likes": [],
"created": "2022-09-15T19:38:58.919Z",
"chatRoom": "631794a83671700c713b1ce6",
"message": "dfsfsd",
"user": {
"_id": "63233015c3aa3508a4c8fc34",
"username": "bobob"
},
"customer": "631794a83671700c713b1ce5",
"__v": 0
},
{
"_id": "6323301cc3aa3508a4c8fc35",
"likes": [],
"created": "2022-09-15T14:01:00.801Z",
"chatRoom": "631794a83671700c713b1ce6",
"message": "Hello world0.9368298953351251",
"user": {
"_id": "63233015c3aa3508a4c8fc34",
"username": "bobob"
},
"customer": "631794a83671700c713b1ce5",
"__v": 0
}
]
}