Skip to content

Commit 84e7aad

Browse files
improvement(slack): request the approved mention/assistant/DM scopes, advertised on v2 only (#5898)
Slack app review has since approved `app_mentions:read`, `assistant:write`, and `im:history` — they are live in the prod app manifest's `oauth_config.scopes.bot` — but the repo still had them commented out behind a stale "re-add once approved" TODO. Sim was therefore requesting a narrower grant than the app is entitled to, so newly connected accounts got tokens missing exactly the scopes backing three `simSubscribed` events on the native Sim app trigger: `app_mention` (app_mentions:read), assistant threads (assistant:write), and DMs (im:history). The requested scope set now matches the manifest's 20 approved bot scopes exactly. Scopes are per-credential, not per-block (one Slack app -> one `slack` provider -> one shared token, requested server-side via getCanonicalScopesForProvider), so the grant itself cannot be scoped to v2. What is per-block is what each picker advertises and treats as missing, so: - slack_v2 + the slack_oauth trigger advertise the full set (they host the native Sim app trigger that needs it). - The legacy v1 block stays pinned to the pre-expansion 17 scopes. It has no feature needing the new three, and advertising them there would flag every existing Slack credential as missing scopes and prompt a needless reconnect. Claude-Session: https://claude.ai/code/session_018asmKsWQ5Vi7T7wD9uHofz Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bc237a0 commit 84e7aad

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

apps/sim/blocks/blocks/slack.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ import { normalizeFileInput } from '@/blocks/utils'
77
import type { SlackResponse } from '@/tools/slack/types'
88
import { getTrigger } from '@/triggers'
99

10+
/**
11+
* Scopes added for the native Sim Slack app trigger (`slack_oauth`): the shared
12+
* app's `app_mention`, assistant-thread, and DM events don't deliver without
13+
* them. Advertised by `slack_v2` and the trigger only — the legacy block has no
14+
* feature that needs them, and listing them there would flag every existing
15+
* Slack credential as missing scopes and prompt a reconnect.
16+
*
17+
* This only controls what each picker *advertises* and treats as missing. The
18+
* authorization request itself is provider-wide
19+
* (`getCanonicalScopesForProvider('slack')`), so any reconnect grants the full
20+
* set regardless of which block started it.
21+
*/
22+
const SLACK_V2_ONLY_SCOPES = new Set(['app_mentions:read', 'assistant:write', 'im:history'])
23+
24+
/** Slack scopes the legacy v1 block advertises — the set from before the trigger expansion. */
25+
const SLACK_V1_ADVERTISED_SCOPES = getScopesForService('slack').filter(
26+
(scope) => !SLACK_V2_ONLY_SCOPES.has(scope)
27+
)
28+
1029
export const SlackBlock: BlockConfig<SlackResponse> = {
1130
type: 'slack',
1231
name: 'Slack',
@@ -107,7 +126,7 @@ export const SlackBlock: BlockConfig<SlackResponse> = {
107126
canonicalParamId: 'oauthCredential',
108127
mode: 'basic',
109128
serviceId: 'slack',
110-
requiredScopes: getScopesForService('slack'),
129+
requiredScopes: SLACK_V1_ADVERTISED_SCOPES,
111130
placeholder: 'Select Slack workspace',
112131
dependsOn: ['authMethod'],
113132
condition: {
@@ -2642,6 +2661,9 @@ function adaptSubBlockForV2(sb: SubBlockConfig): SubBlockConfig {
26422661
...rest,
26432662
credentialKind: 'any',
26442663
placeholder: 'Select Slack account or bot',
2664+
// Full set, unlike v1: v2 hosts the native Sim app trigger, whose events
2665+
// need the mention/assistant/DM scopes.
2666+
requiredScopes: getScopesForService('slack'),
26452667
credentialLabels: {
26462668
oauthGroup: 'Sim app',
26472669
oauthConnect: 'Connect the Sim app',

apps/sim/lib/oauth/oauth.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,9 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
782782
'groups:write',
783783
'chat:write',
784784
'chat:write.public',
785-
// TODO: Re-add once Slack app review approves these. Requesting a scope
786-
// the app is not yet approved for makes Slack reject the entire
787-
// authorization with "unapproved permissions requested", breaking connect.
788-
// 'assistant:write',
789-
// 'app_mentions:read',
790-
// 'im:history',
785+
'assistant:write',
786+
'app_mentions:read',
787+
'im:history',
791788
'im:write',
792789
'im:read',
793790
'users:read',

0 commit comments

Comments
 (0)