thread.subscribe()), subsequent messages
including @-mentions go to onSubscribedMessage handlers instead.
To detect mentions in subscribed threads, check message.isMention:
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Handler for new @-mentions of the bot.
thread.subscribe()), subsequent messages
including @-mentions go to onSubscribedMessage handlers instead.
To detect mentions in subscribed threads, check message.isMention:
// Handle new mentions (unsubscribed threads only)
chat.onNewMention(async (thread, message) => {
await thread.subscribe(); // Subscribe to follow-up messages
await thread.post("Hello! I'll be watching this thread.");
});
// Handle all messages in subscribed threads
chat.onSubscribedMessage(async (thread, message) => {
if (message.isMention) {
// User @-mentioned us in a thread we're already watching
await thread.post("You mentioned me again!");
}
});
type MentionHandler = (thread: Thread<TState>, message: Message, context: MessageContext) => void | Promise<void>
Was this page helpful?