Skip to content

feat(eve): add ability to unsubscribe eve from Slack threads (v3)#1178

Draft
benpankow wants to merge 2 commits into
mainfrom
benpankow/unsubscribe-rd-3
Draft

feat(eve): add ability to unsubscribe eve from Slack threads (v3)#1178
benpankow wants to merge 2 commits into
mainfrom
benpankow/unsubscribe-rd-3

Conversation

@benpankow

@benpankow benpankow commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

This exploratory PR adds durable Slack thread subscriptions using the existing per-session Slack channel state, without introducing another storage method or adding framework-level code (entirely internal to Slack state).

The API progresses from mention-only behavior, to following active threads, to a custom subscription lifecycle.

1. Respond only to explicit mentions

This remains the default:

export default slackChannel({
  credentials: connectSlackCredentials("slack/my-agent"),
});

2. Respond to replies in active threads

export default slackChannel({
  credentials: connectSlackCredentials("slack/my-agent"),
  threadSubscription: true,
});

Messages outside active eve threads remain ignored.

3. Refine when a thread remains subscribed

export default slackChannel({
  credentials: connectSlackCredentials("slack/my-agent"),
  threadSubscription: {
    resolve({ current, isBotMentioned }, message) {
      if (isBotMentioned) return "subscribed";
      if (current === "unsubscribed") return current;

      const mentionsSomeone = /<@[A-Z0-9]+(?:\|[^>]+)?>/.test(message.text);
      return mentionsSomeone ? "unsubscribed" : current;
    },
  },
});

The resolver runs inside the durable session after state is hydrated. Returning "subscribed" dispatches the message; returning "unsubscribed" persists the state and ignores it before model execution. Explicit mentions can resubscribe the same session while preserving its history and state.

Screenshot 2026-07-23 at 9 57 15 AM

Test Plan

  • Added unit tests for default, subscribed-thread, unsubscribe, and resubscribe behavior
  • Manually verified the handoff behavior with a deployed Slack agent

Signed-off-by: benpankow <ben.pankow@vercel.com>
Signed-off-by: benpankow <ben.pankow@vercel.com>
@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
eve-docs Building Building Preview, Comment, Open in v0 Jul 24, 2026 5:25pm

@benpankow benpankow changed the title benpankow/unsubscribe rd 3 feat(eve): add ability to unsubscribe eve from Slack threads (v3) Jul 24, 2026
const delivery = readSlackMessageDeliveryData(payload.channelData);
if (delivery === undefined) return defaultDeliverResult(payload);

const current = adapterCtx.state.subscription as SlackSubscriptionState;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const current = adapterCtx.state.subscription as SlackSubscriptionState;
// Durable sessions created before `subscription` was added to
// `SlackChannelState` have no persisted value here. Default a
// missing/invalid value to "subscribed" so legacy threads follow
// (rather than throwing when the default resolver returns `current`).
const current: SlackSubscriptionState =
adapterCtx.state.subscription === "unsubscribed" ? "unsubscribed" : "subscribed";

Legacy durable Slack sessions lacking the new subscription state field cause the deliver hook to throw (session.failed) on non-mention messages instead of following/ignoring the thread.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant