You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sdk/javascript/retrieve-conversations.mdx
+1-214Lines changed: 1 addition & 214 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,31 +97,6 @@ Relevant fields to access on returned conversations:
97
97
98
98
### With User and Group Tags
99
99
100
-
This method can be used to fetch the user/group tags in the `Conversation` Object. By default the value is `false`.
101
-
102
-
<Tabs>
103
-
<Tabtitle="JavaScript">
104
-
```javascript
105
-
let limit =30;
106
-
let conversationType ="group";
107
-
let conversationRequest =newCometChat.ConversationsRequestBuilder()
108
-
.setLimit(limit)
109
-
.setConversationType(conversationType)
110
-
.build();
111
-
```
112
-
113
-
</Tab>
114
-
115
-
</Tabs>
116
-
117
-
<Note>
118
-
Default limit is 30, maximum is 50.
119
-
</Note>
120
-
121
-
When conversations are fetched successfully, the response includes an array of [`Conversation`](/sdk/reference/entities#conversation) objects filtered by the specified type.
122
-
123
-
### With User and Group Tags
124
-
125
100
Use `withUserAndGroupTags(true)` to include user/group tags in the response. Default is `false`.
126
101
127
102
<Tabs>
@@ -148,26 +123,6 @@ Relevant fields to access on returned conversations:
148
123
149
124
### Set User Tags
150
125
151
-
This method fetches user conversations that have the specified tags.
152
-
153
-
<Tabs>
154
-
<Tabtitle="JavaScript">
155
-
```javascript
156
-
let limit =30;
157
-
let conversationRequest =newCometChat.ConversationsRequestBuilder()
158
-
.setLimit(limit)
159
-
.withUserAndGroupTags(true)
160
-
.build();
161
-
```
162
-
163
-
</Tab>
164
-
165
-
</Tabs>
166
-
167
-
When conversations are fetched successfully, the response includes `tags` arrays on the `conversationWith` objects.
168
-
169
-
### Set User Tags
170
-
171
126
Fetch user conversations where the user has specific tags.
172
127
173
128
<Tabs>
@@ -195,27 +150,6 @@ Relevant fields to access on returned conversations:
195
150
196
151
### Set Group Tags
197
152
198
-
This method fetches group conversations that have the specified tags.
199
-
200
-
<Tabs>
201
-
<Tabtitle="JavaScript">
202
-
```javascript
203
-
let limit =30;
204
-
let userTags = ["tag1"];
205
-
let conversationRequest =newCometChat.ConversationsRequestBuilder()
206
-
.setLimit(limit)
207
-
.setUserTags(userTags)
208
-
.build();
209
-
```
210
-
211
-
</Tab>
212
-
213
-
</Tabs>
214
-
215
-
When conversations are fetched successfully, the response includes only user conversations where the user has the specified tags.
216
-
217
-
### Set Group Tags
218
-
219
153
Fetch group conversations where the group has specific tags.
220
154
221
155
<Tabs>
@@ -243,27 +177,6 @@ Relevant fields to access on returned conversations:
243
177
244
178
### With Tags
245
179
246
-
This method makes sure that the tags associated with the conversations are returned along with the other details of the conversations. The default value for this parameter is `false`
247
-
248
-
<Tabs>
249
-
<Tabtitle="JavaScript">
250
-
```javascript
251
-
let limit =30;
252
-
let groupTags = ["tag1"];
253
-
let conversationRequest =newCometChat.ConversationsRequestBuilder()
254
-
.setLimit(limit)
255
-
.setGroupTags(groupTags)
256
-
.build();
257
-
```
258
-
259
-
</Tab>
260
-
261
-
</Tabs>
262
-
263
-
When conversations are fetched successfully, the response includes only group conversations where the group has the specified tags.
264
-
265
-
### With Tags
266
-
267
180
Use `withTags(true)` to include conversation tags in the response. Default is `false`.
268
181
269
182
<Tabs>
@@ -288,23 +201,6 @@ Relevant fields to access on returned conversations:
288
201
289
202
### Set Tags
290
203
291
-
This method helps you fetch the conversations based on the specified tags.
292
-
293
-
<Tabs>
294
-
<Tabtitle="JavaScript">
295
-
```javascript
296
-
let limit =30;
297
-
let conversationRequest =newCometChat.ConversationsRequestBuilder()
298
-
.setLimit(limit)
299
-
.withTags(true)
300
-
.build();
301
-
```
302
-
303
-
</Tab>
304
-
305
-
</Tabs>
306
-
### Set Tags
307
-
308
204
Fetch conversations that have specific tags.
309
205
310
206
<Tabs>
@@ -330,24 +226,6 @@ Relevant fields to access on returned conversations:
330
226
331
227
### Include Blocked Users
332
228
333
-
This method helps you fetch the conversations of users whom the logged-in user has blocked.
334
-
335
-
<Tabs>
336
-
<Tabtitle="JavaScript">
337
-
```javascript
338
-
let limit =30;
339
-
let tags = ["archivedChat"];
340
-
let conversationRequest =newCometChat.ConversationsRequestBuilder()
341
-
.setLimit(limit)
342
-
.setTags(tags)
343
-
.build();
344
-
```
345
-
346
-
</Tab>
347
-
348
-
</Tabs>
349
-
### Include Blocked Users
350
-
351
229
Use `setIncludeBlockedUsers(true)` to include conversations with users you've blocked.
352
230
353
231
<Tabs>
@@ -517,6 +395,7 @@ let conversationRequest = new CometChat.ConversationsRequestBuilder()
517
395
</Tab>
518
396
519
397
</Tabs>
398
+
520
399
### Only Agentic Conversations
521
400
522
401
Use `setOnlyAgentic(true)` to fetch only AI agent conversations.
@@ -542,31 +421,6 @@ The `setHideAgentic()` and `setOnlyAgentic()` methods are mutually exclusive. Yo
542
421
</Note>
543
422
544
423
When conversations are fetched successfully, the response will include only conversations with AI agents. Agent users have `role: "@agentic"` and include agent-specific metadata.
545
-
Finally, once all the parameters are set to the builder class, you need to call the `build()` method to get the object of the `ConversationsRequest` class.
546
-
547
-
Once you have the object of the `ConversationsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of [`Conversation`](/sdk/reference/entities#conversation) objects containing X number of users depending on the limit set.
548
-
549
-
A Maximum of only 50 Conversations can be fetched at once.
550
-
551
-
<Tabs>
552
-
<Tabtitle="JavaScript">
553
-
```javascript
554
-
let limit =30;
555
-
let conversationRequest =newCometChat.ConversationsRequestBuilder()
556
-
.setLimit(limit)
557
-
.setOnlyAgentic(true)
558
-
.build();
559
-
```
560
-
561
-
</Tab>
562
-
563
-
</Tabs>
564
-
565
-
<Note>
566
-
`setHideAgentic()` and `setOnlyAgentic()` are mutually exclusive — use only one per request.
567
-
</Note>
568
-
569
-
When conversations are fetched successfully, the response includes only AI agent conversations. Agent users have `role: "@agentic"`.
570
424
571
425
### Fetch Conversations
572
426
@@ -664,47 +518,6 @@ Relevant fields to access on returned conversation:
664
518
665
519
## Retrieve Single Conversation
666
520
667
-
*In other words, as a logged-in user, how do I retrieve a specific conversation?*
668
-
669
-
To fetch a specific conversation, you can use the `getConversation` method. The `getConversation` method accepts two parameters.
670
-
671
-
1.`conversationWith`: UID/GUID of the user/group whose conversation you want to fetch.
672
-
673
-
2.`conversationType`: The `conversationType` variable can hold one of the below two values:
console.log("error while fetching a conversation", error);
692
-
}
693
-
);
694
-
```
695
-
696
-
</Tab>
697
-
698
-
</Tabs>
699
-
700
-
<Note>
701
-
Conversation tags are one-way. If user A tags a conversation with user B, that tag only applies for user A.
702
-
</Note>
703
-
704
-
When the conversation is tagged successfully, the response returns a [`Conversation`](/sdk/reference/entities#conversation) object with the `tags` field.
705
-
706
-
## Retrieve Single Conversation
707
-
708
521
Use `getConversation()` to fetch a specific conversation.
709
522
710
523
| Parameter | Description |
@@ -738,32 +551,6 @@ The `getConversation()` method returns a single [`Conversation`](/sdk/reference/
738
551
739
552
## Convert Messages to Conversations
740
553
741
-
As per our [receive messages](/sdk/javascript/receive-message) guide, for real-time messages, you will always receive `Message` objects and not [`Conversation`](/sdk/reference/entities#conversation) objects. Thus, you will need a mechanism to convert the Message object to the `Conversation` object. You can use the `getConversationFromMessage(BaseMessage message)` of the `CometChatHelper` class.
console.log("error while fetching a conversation", error);
755
-
}
756
-
);
757
-
```
758
-
759
-
</Tab>
760
-
761
-
</Tabs>
762
-
763
-
When the conversation is fetched successfully, the response returns a single [`Conversation`](/sdk/reference/entities#conversation) object.
764
-
765
-
## Convert Messages to Conversations
766
-
767
554
Use `CometChatHelper.getConversationFromMessage()` to convert a received message into a [`Conversation`](/sdk/reference/entities#conversation) object. Useful for updating your Recent Chats list when receiving real-time messages.
0 commit comments