Retrieve Messages

Get Chat Messages#

To fetch all the conversation between you and a single chat user or group, call the below method.

await SDK.getChatMessages(TO_JID);

Example

await SDK.getChatMessages("91XXXXXXXXXX@domain.com");

Request Params#

StatusDescriptionTypeRequired
toJidJID of the To UserJID Stringtrue

Response Format#

{
"statusCode": 200,
"message": "Success",
"userJid": "", // String - Requested User Jid
"data": [
{
"createdAt": "2023-12-12 08:39:50",
"chatType": "", // String - Chat Type - "chat"
"favouriteBy": "",
"favouriteStatus": 0,
"deleteStatus": 0,
"fromUserId": "",
"fromUserJid": "",
"toUserJid": "", // String - Requested User Jid
"publisherJid": "",
"publisherId": "",
"timestamp": 1702370390914000,
"msgId": "ea14f3b4-74d6-407e-8c9a-3b493e69430a",
"msgStatus": 0,
"msgBody": {
"mid": "ea14f3b4-74d6-407e-8c9a-3b493e69430a",
"message": "",
"message_type": "text",
"replyTo": "",
"mentionedUsersIds": "",
"nickName": ""
}
}
]
}

Get Message based on MsgId#

Use the below method to get the message using the messageId which you got.

SDK.getMessageById(`MSG_ID`);

Example Request#

SDK.getMessageById(`815f37b5-1f8f-4a39-8237-247c44b1b521`);

Response Format#

{
statusCode: 200,
message: "Success",
data:{
chatType: "", // String - Chat Type - "chat" - Single - "groupchat" - Group
createdAt: "", // String - CreatedAt - "2023-04-11 09:23:52"
deleteStatus: 0, // Number - Delete Status
deletedBy: "0", // String - Deleted By
fromUserId: "", // String - From User Id
fromUserJid: "", // String - From User Jid -
// Will Be Same as PublisherJid in Case of Single Chat
// GroupJid in Case of Group Chat
msgBody: {
message: '', // String - Message Body
message_type: '', // String - Message Type text, image, video, audio & file
mentionedUsersIds: [], // Array - Mentioned Ids In case of Group
nickName: '', // String - User Nickname
}
msgId: "", // String - Message Id
topicId: "", //String - Topic id for the message
msgStatus: 2, // Number - Message Status
msgType: "", // String - value ""
profileUpdatedStatus: "" // String
publisherJid: "", // String - Jid - PublisherJid
publisherId: "", // String - Id - Publisher Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
userId: "", // String - UserId
userJid: "", // String - UserJid
},
}