Copy link to headingContinue conversations without repeated mentions
agent/channels/slack.ts
export default slackChannel({ credentials: connectSlackCredentials("slack/my-agent"), async onMessage(ctx, message) {
if (message.author?.isBot) return null;
const isDirectMessage = message.raw.channel_type === "im"; return isDirectMessage || ctx.isBotMentioned() || (await ctx.isSubscribed()) ? { auth: null } : null; },});
Dispatches DMs, explicit mentions, and follow-ups in threads with an active session.
Copy link to headingCancel a turn or reset the conversation
agent/channels/slack.ts
export default slackChannel({
credentials: connectSlackCredentials("slack/my-agent"), async onMessage(ctx, message) {
if (message.text.trim() !== "!new") return null; await ctx.reset({ reason: "Slack user requested !new" }); await ctx.thread.post("Started a fresh conversation."); return null;
},});
Retire the session and start the next message fresh.
Copy link to headingHandle any Events API callback
agent/channels/slack.ts
const onboardingChannels = ["C0123ABC", "C0456DEF"];
export default slackChannel({ credentials: connectSlackCredentials("slack/my-agent"), async onEvent({ receive }, event) {
if (event.type !== "team_join") return;
await Promise.all( onboardingChannels.map((channelId) => receive({ message: `A user joined the Slack workspace. Onboard them from this event:\n${JSON.stringify(event)}`, target: { channelId }, auth: null, }), ), ); },});
Fans a single team_join event out into onboarding turns across multiple channels.