cometchat/chat-sdk-javascript

How to fetch all conversations history, rather then by previous messages related to user?

Closed this issue · 4 comments

How to fetch all conversations history, rather then by previous messages related to user?

Hello @mike-van , you can fetch all the messages from all conversations i.e one-on-one and group conversation as follow:

var limit = 50;
var messagesRequest = new CometChat.MessagesRequestBuilder().setLimit(limit).build();
messagesRequest.fetchPrevious().then(
	messages => {
		console.log("Message list fetched:", messages);
	},error => {
		console.log("Message fetching failed with error:", error);
	}
);

Hi @mayur-bhandari yes i saw this in the documentations, but this only fetch the array of messages send and received by logged in user, i want to fetch the array of dialogs related to the user. if i use this, i'd have to group them into seperate dialog, and order them by timestamp before getting all the dialogs.

Hello @mike-van , we have added a functionality to fetch all the conversation the logged in user is part of. You can know more about Conversations here: https://prodocs.cometchat.com/v2.0/docs/js-messaging-retrieve-conversations

Closing this issue due to inactivity.