Retrieve Messages

Get Chat Messages#

To get the chat history of the selected user, send a request to the server as described below.

await SDK.getChatMessagesDB(
toJid: ""
);

Example

await SDK.getChatMessagesDB(
toJid: "91XXXXXXXXXX@domain.com",
);

Request Params#

StatusDescriptionTypeRequired
toJidJID of the To UserJID Stringtrue

Response Format#

{
statusCode: 200,
message: "Success",
userJid: "", // String - Requested User Jid
data: [
{
deleteStatus: "", // Number - Delete Status
fromUserId: "", // String - From User Id
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
file_url: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message: "", // String - Message Body
message_type: "" // String - Message Type
},
fromUserJid: "", // String - From User Jid
msgId: "", // String - Unique Message Id
msgStatus: "", // String - Message Status
createdAt: "", // String - Message Created Time
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
rowId: "", // String - Table Row Id - Used for Fetching Next Paginated Messages
chatType: "", // String - Chat Type - "chat"
},
//...
];
}

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
},
}