Skip to content

feat(slack): native Sim app trigger mode via the preview-gated slack_v2 block#5892

Merged
TheodoreSpeaks merged 2 commits into
stagingfrom
feat/slack-sim-app-trigger
Jul 23, 2026
Merged

feat(slack): native Sim app trigger mode via the preview-gated slack_v2 block#5892
TheodoreSpeaks merged 2 commits into
stagingfrom
feat/slack-sim-app-trigger

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

What

Restores the native Sim Slack app mode for the slack_oauth trigger using the single-credential-picker design (not the old appType dropdown from #5323).

The trigger is only reachable through the preview-gated slack_v2 block, so the native mode inherits that gate — no separate env flag needed. (The original brief called for NEXT_PUBLIC_SLACK_SIM_APP_ENABLED; we dropped it since the slack_v2 preview already provides the staging-only gating.)

The official-app ingest endpoint and team_id fan-out routing already existed and are live on staging (PR #5323 backend survived #5800). This PR re-wires the picker + deploy path to reach them.

Changes

  • triggers/slack/shared.ts — re-add the SIM_SUBSCRIBED_EVENTS and SLACK_SIM_EVENT_OPTIONS derived exports (removed by improvement(slack): merge slack_v2 auth into one credential picker for accounts and custom bots #5800).
  • triggers/slack/oauth.ts — single credential picker (credentialKind: 'any') lists Sim OAuth accounts and reusable custom bots together, mirroring the slack_v2 block. The event dropdown resolves the selected credential's kind client-side (from the warmed credential list) and offers SLACK_SIM_EVENT_OPTIONS for an OAuth account, SLACK_ALL_EVENT_OPTIONS for a custom bot.
  • lib/webhooks/deploy.ts — the slack_oauth deploy branch discriminates by the resolved credential, not a UI field:
    • getSlackBotCredential succeeds → custom bot path (route by credential id), unchanged.
    • otherwise → native Sim app: validate eventType ∈ SIM_SUBSCRIBED_EVENTS (400), resolve the credential owner's token (not the deploying actor's), derive routingKey from Slack team_id via auth.test, route on slack_app with no path.
  • lib/webhooks/deploy.test.ts — export resolveWebhookConfigForBlock and add coverage for: custom-bot routing, cross-workspace bot rejection, non-simSubscribed event → 400, OAuth account → team_id routing (owner's token), and token-resolution failure → 400.

Checks

  • bunx vitest run lib/webhooks triggers/slack — 518 passed
  • bun run type-check — no new errors (5 pre-existing better-auth errors unchanged)
  • bun run lint:check — clean
  • bun run apps/sim/scripts/check-block-registry.ts origin/staging — pass
  • check:api-validation / check:client-boundary — pass

🤖 Generated with Claude Code

https://claude.ai/code/session_018asmKsWQ5Vi7T7wD9uHofz

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 23, 2026 6:02pm

Request Review

@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Deploy-time OAuth token refresh, workspace/credential binding, and webhook routing keys affect trigger delivery and multi-tenant isolation; behavior is covered by new tests but touches auth and webhook infrastructure.

Overview
Restores native Sim Slack app routing for the slack_oauth trigger while keeping custom bring-your-own bots, using one credential picker instead of a separate UI mode.

Trigger config — The Slack credential field accepts OAuth accounts and custom bots (credentialKind: 'any') with updated copy/labels. SIM_SUBSCRIBED_EVENTS is exported from the event catalog as the deploy-time allowlist for the shared app.

Deploy (resolveWebhookConfigForBlock) — For slack_oauth, the server picks the backend from the resolved credential: getSlackBotCredentialslack provider, route by credential id (with workspace checks); otherwise → workspace-scoped OAuth lookup, reject events not in SIM_SUBSCRIBED_EVENTS, refresh the credential owner’s token (not the deployer), auth.test via fetchSlackTeamId for team_id routing on slack_app, with clearer 400s for invalid/missing bots and tokens. The function is exported for unit tests.

Tests — New coverage for custom-bot routing, cross-workspace rejection, invalid bot/OAuth paths, unsupported Sim-app events, successful OAuth team_id routing, and token failure.

Reviewed by Cursor Bugbot for commit b59d165. Bugbot is set up for automated code reviews on this repo. Configure here.

@TheodoreSpeaks TheodoreSpeaks changed the title feat(slack): native Sim app trigger mode behind NEXT_PUBLIC_SLACK_SIM_APP_ENABLED feat(slack): native Sim app trigger mode via the preview-gated slack_v2 block Jul 23, 2026
Comment thread apps/sim/lib/webhooks/deploy.ts
Comment thread apps/sim/lib/webhooks/deploy.ts
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds native Sim Slack-app trigger deployment alongside reusable custom bots.

  • Unifies OAuth accounts and custom bots in one Slack credential picker.
  • Routes native-app triggers by Slack team ID while retaining credential-ID routing for custom bots.
  • Restores the shared-app event subscription catalog and adds deployment-path tests.

Confidence Score: 5/5

The pull request appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/webhooks/deploy.ts Adds credential-kind discrimination, workspace-scoped native OAuth resolution, event validation, owner-token lookup, and team-ID routing.
apps/sim/lib/webhooks/deploy.test.ts Adds focused coverage for custom-bot and native-app deployment routing and rejection paths.
apps/sim/triggers/slack/oauth.ts Changes the Slack trigger to a unified OAuth/custom-bot credential picker with static event options.
apps/sim/triggers/slack/shared.ts Derives the official Sim app’s subscribed event IDs from the shared Slack event catalog.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Slack trigger deployment] --> B{Credential resolves as custom bot?}
  B -->|Yes| C[Validate workflow workspace]
  C --> D[Route through slack by credential ID]
  B -->|No| E[Resolve OAuth credential in workflow workspace]
  E --> F[Validate shared-app event]
  F --> G[Resolve credential owner's token]
  G --> H[Call Slack auth.test]
  H --> I[Route through slack_app by team ID]
Loading

Reviews (2): Last reviewed commit: "fix(slack): address review — set credent..." | Re-trigger Greptile

Comment thread apps/sim/triggers/slack/oauth.ts Outdated
Comment thread apps/sim/lib/webhooks/deploy.ts
TheodoreSpeaks and others added 2 commits July 23, 2026 11:25
…ck_v2 block

Restore the native Sim Slack app mode for the slack_oauth trigger using a
single-credential-picker design. The trigger is only reachable through the
preview-gated slack_v2 block, so the mode inherits that gate — no separate env
flag.

- Re-add SIM_SUBSCRIBED_EVENTS / SLACK_SIM_EVENT_OPTIONS derived exports.
- Merge the trigger credential picker (credentialKind: 'any') so it lists Sim
  OAuth accounts and reusable custom bots together, mirroring the slack_v2 block.
- Event dropdown narrows to the Sim app's subscribed events when an OAuth
  account is selected, all events for a custom bot (resolved client-side from
  the warmed credential list).
- Deploy branch discriminates by the RESOLVED credential, not a UI field: a bot
  credential routes by credential id (custom app); otherwise validate the event
  against SIM_SUBSCRIBED_EVENTS, resolve the credential owner's token, derive
  routingKey from Slack team_id (auth.test), and route on the shared Sim app.
- The ingest endpoint and team_id fan-out routing already existed on staging.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018asmKsWQ5Vi7T7wD9uHofz
…rkspace, drop event narrowing

Review round 1 (Greptile 4/5 + Cursor Bugbot):

- deploy.ts: the native Sim-app (OAuth) branch now sets providerConfig.credentialId
  (runtime token resolution in the slack provider and credential-disconnect cleanup
  both key slack_app rows on it — without it, file downloads / reaction text fail and
  disconnect leaves the webhook active).
- deploy.ts: resolve the OAuth credential through resolveTriggerCredentialId
  (workspace- and oauth-scoped) so a pasted foreign/other-tenant credential id can't
  bind to the workflow; use the resolved canonical id for token owner lookup + routing.
- deploy.ts: a deleted/secretless custom bot credential (getSlackBotCredential → null
  but a service_account row exists) now returns the "reconnect the bot" error instead
  of the misleading "connected Slack account" message.
- oauth.ts: drop the credential-based event-option narrowing. The shared dropdown
  framework doesn't revalidate a stored value when its dependency changes, so switching
  a custom bot → Sim account left an orphaned event that failed deploy with a 400. The
  event picker now offers all events; the deploy path is the authoritative gate.
- tests: add broken-bot and workspace-not-resolvable cases; assert credentialId is set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018asmKsWQ5Vi7T7wD9uHofz
@TheodoreSpeaks
TheodoreSpeaks force-pushed the feat/slack-sim-app-trigger branch from 0a6c39e to b59d165 Compare July 23, 2026 18:25
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b59d165. Configure here.

@TheodoreSpeaks
TheodoreSpeaks merged commit 5adf68f into staging Jul 23, 2026
18 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the feat/slack-sim-app-trigger branch July 23, 2026 18:51
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