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: apps/docs/content/docs/api/thread.mdx
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,28 @@ await scheduled.cancel();
114
114
Streaming and file uploads are not supported in scheduled messages.
115
115
</Callout>
116
116
117
+
## getParticipants
118
+
119
+
Get the unique human participants in a thread. Returns deduplicated authors, excluding all bots. Useful for subscribing only to 1:1 conversations and unsubscribing when others join.
// Subscribe only when one person is talking to the bot
125
+
if (participants.length===1) {
126
+
awaitthread.subscribe();
127
+
}
128
+
129
+
// Unsubscribe when the thread becomes a group conversation
130
+
if (participants.length>1) {
131
+
awaitthread.unsubscribe();
132
+
}
133
+
```
134
+
135
+
<Callouttype="warn">
136
+
Each call fetches the full message history to find all participants. On threads with long history this makes multiple API calls to the platform. Consider checking `message.author` against a known set before calling `getParticipants()` on every incoming message.
137
+
</Callout>
138
+
117
139
## subscribe / unsubscribe
118
140
119
141
Manage thread subscriptions. Subscribed threads route all messages to `onSubscribedMessage` handlers.
Copy file name to clipboardExpand all lines: apps/docs/content/docs/threads-messages-channels.mdx
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,33 @@ await thread.unsubscribe();
40
40
const subscribed =awaitthread.isSubscribed();
41
41
```
42
42
43
+
### Participants
44
+
45
+
Get the unique human participants in a thread. Returns deduplicated authors, excluding all bots. Useful for deciding whether to subscribe based on how many humans are in the conversation.
Each call fetches the full message history to find all participants. On threads with long history this makes multiple API calls to the platform. Consider checking `message.author` against a known set before calling `getParticipants()` on every incoming message.
0 commit comments