Skip to content

Commit a968d15

Browse files
sjf-oasjf
andauthored
feat(slack): enable Enterprise Grid identity, DMs, routing, actions, approvals, and presence (#121373)
* refactor(slack): detect Enterprise Grid installs at runtime * fix(slack): preserve enterprise bot identity * style(slack): format enterprise identity test * fix(slack): scope enterprise config by workspace * fix(slack): preserve qualified binding casing * feat(slack): enable enterprise presence polling * fix(slack): normalize enterprise binding accounts * fix(slack): require workspace-scoped Grid targets * docs(slack): document Enterprise policy target forms * fix(slack): preserve Grid pairing workspace scope * refactor(slack): simplify scoped target formatting * fix(slack): repair Enterprise Grid CI checks * chore: refresh generated Slack metadata * refactor(slack): simplify optional workspace scope * test(slack): infer installation state handle types * chore: resolve plugin SDK baseline conflict * fix(ci): regenerate plugin SDK API baseline on Linux * fix(slack): allow standalone workspace sends --------- Co-authored-by: Sarah Fortune <[email protected]>
1 parent 5fad24c commit a968d15

69 files changed

Lines changed: 2439 additions & 1390 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/.generated/plugin-sdk-api-baseline.sha256‎

Lines changed: 113 additions & 113 deletions
Large diffs are not rendered by default.

‎docs/channels/slack.md‎

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ uses the org-installed bot token:
156156
slack: {
157157
enabled: true,
158158
mode: "socket",
159-
enterpriseOrgInstall: true,
160159
appToken: { source: "env", provider: "default", id: "SLACK_APP_TOKEN" },
161160
botToken: { source: "env", provider: "default", id: "SLACK_BOT_TOKEN" },
162161
slashCommand: { enabled: true, name: "openclaw" },
@@ -257,7 +256,6 @@ the enterprise account with the same Request URL path:
257256
slack: {
258257
enabled: true,
259258
mode: "http",
260-
enterpriseOrgInstall: true,
261259
botToken: { source: "env", provider: "default", id: "SLACK_BOT_TOKEN" },
262260
signingSecret: {
263261
source: "env",
@@ -277,29 +275,35 @@ the enterprise account with the same Request URL path:
277275
}
278276
```
279277

280-
At startup, OpenClaw verifies `enterpriseOrgInstall` with Slack `auth.test`.
281-
An org-installed token without the flag, or a workspace token with the flag,
282-
fails startup. Slack remains the source of truth for which workspaces have
283-
granted the installation; OpenClaw then applies the configured channel, user,
284-
DM, and mention policies to each delivered event. Enterprise accounts reject all
285-
bot-authored `message` and `app_mention` events before dispatch, regardless of
286-
`allowBots`, because org installs do not provide a stable workspace-qualified
287-
bot identity for loop prevention.
278+
At startup, OpenClaw uses Slack `auth.test` to detect whether the token belongs
279+
to a workspace installation or an Enterprise Grid org-wide installation. No
280+
installation-mode setting is required. Slack remains the source of truth for
281+
which workspaces have granted the installation; OpenClaw then applies the
282+
configured channel, user, DM, and mention policies to each delivered event.
283+
Enterprise installs reject bot-authored `message` and `app_mention` events by
284+
default. Set `allowBots` on the account or channel to admit them under the same
285+
loop-prevention rules used by workspace installs. OpenClaw retains the org
286+
installation's `auth.test` `user_id` and `bot_id` for that check.
288287

289288
Enterprise support accepts direct Socket Mode or HTTP message, mention,
290289
membership, reaction, pin, channel-created, channel-renamed, Block Kit action,
291290
modal, and configured shortcut and slash-command payloads plus
292-
workspace-qualified outbound messages. Add any shortcuts to the app manifest's
291+
workspace-qualified outbound messages and presence polling. Add any shortcuts to the app manifest's
293292
`features.shortcuts` list; OpenClaw accepts their callback IDs through the same
294293
interaction path. The manifest examples register the single `/openclaw`
295294
command; native command mode still requires the administrator-managed command
296295
entries described below. Relay mode, channel-ID-change events, App Home, Agent
297-
and Assistant lifecycle events, and bindings
298-
remain unavailable for an enterprise account. Slack-native approvals that
299-
originate from a delivered, workspace-qualified Slack turn are supported;
300-
approval buttons use the same listener-owned, workspace-scoped interaction
301-
path. Slack action tools are supported for enterprise accounts across every
302-
group listed in [Actions and gates](#actions-and-gates); the configured
296+
and Assistant lifecycle events, configured ACP bindings, and runtime
297+
current-conversation bindings remain unavailable for an enterprise account.
298+
Static agent route bindings are supported when a binding without a peer
299+
specifies `match.teamId`, or a peer ID uses
300+
`team:<team-id>:channel:<channel-id>` or
301+
`team:<team-id>:user:<user-id>`.
302+
Slack-native approvals that originate from a delivered, workspace-qualified
303+
Slack turn are supported; approval buttons use the same listener-owned,
304+
workspace-scoped interaction path. Slack action tools are supported for
305+
enterprise accounts across every group listed in
306+
[Actions and gates](#actions-and-gates); the configured
303307
`channels.slack.actions.*` gates and OAuth scopes still apply. Inbound
304308
membership, reaction, pin, channel-created, and channel-renamed notifications
305309
use validated listener-owned, workspace-scoped event routing. Outbound
@@ -320,33 +324,35 @@ validated listener-owned client remains in the active event turn. The
320324
in-memory send queue and thread-participation records are partitioned by that
321325
event's workspace; the client itself is never serialized or persisted.
322326

323-
Channel policy keys may use the `"*"` wildcard, raw stable Slack channel IDs,
324-
or the `channel:<id>` form. `dm.groupChannels` entries accept only the raw or
325-
`channel:<id>` forms. OpenClaw normalizes either ID form to the raw channel ID
326-
for runtime matching; `slack:`, `group:`, and `mpim:` prefixes fail startup.
327-
User allowlists may use raw stable Slack user IDs or the `slack:<id>` and
328-
`user:<id>` forms. `toolsBySender` keys may use raw IDs, `id:<id>`,
329-
`channel:slack:<id>`, or `"*"`. Names, slugs, display names, and email addresses
330-
fail startup. IDs must use Slack's canonical uppercase prefix and body (for
331-
example, `C0123456789` or `U0123456789`); lowercase and short lookalikes fail
332-
startup. Enterprise accounts cannot enable
327+
Channel policy keys accept raw stable Slack channel IDs, `channel:<id>`, or the
328+
`"*"` wildcard. `dm.groupChannels` accepts raw stable channel IDs or
329+
`channel:<id>`, but not `"*"`. OpenClaw normalizes the ID forms to the raw
330+
channel ID for runtime matching; the channel prefixes `slack:`, `group:`, and
331+
`mpim:` fail startup.
332+
333+
User policy entries in `allowFrom`, `reactionAllowlist`, and per-channel `users`
334+
accept raw stable Slack user IDs, `slack:<user-id>`, `user:<user-id>`, or `"*"`.
335+
Enterprise `toolsBySender` keys accept raw stable user IDs, `id:<user-id>`,
336+
`channel:slack:<user-id>`, or `"*"`. Names, slugs, display names, and email
337+
addresses fail startup. IDs must use Slack's canonical uppercase prefix and body
338+
(for example, `C0123456789` or `U0123456789`); lowercase and short lookalikes
339+
fail startup. Enterprise accounts cannot enable
333340
`dangerouslyAllowNameMatching`. Enterprise accounts may set the global
334-
`mentionPatterns.mode`, but `mentionPatterns.allowIn` and
335-
`mentionPatterns.denyIn` fail startup because bare Slack channel IDs are not
336-
workspace-qualified and can be reused across workspaces. Workspace installs
337-
retain the existing scoped mention-pattern behavior. Each accepted workspace
341+
`mentionPatterns.mode`. Enterprise `mentionPatterns.allowIn` and
342+
`mentionPatterns.denyIn` entries use
343+
`team:<team-id>:channel:<channel-id>`; bare channel IDs fail startup because
344+
they can be reused across workspaces. Workspace installs retain the existing
345+
bare-channel scoped mention-pattern behavior. Each accepted workspace
338346
gets separate routing, session, transcript, dedupe, history, and cache identity
339347
even when Slack IDs overlap. Within the `message` stream, ordinary user messages
340348
and user-authored `file_share` events are supported; other message subtypes are
341349
rejected before authorization or system-event handling.
342350

343-
Enterprise DMs must either be disabled (`dm.enabled=false` or
344-
`dmPolicy="disabled"`) or explicitly open with `dmPolicy="open"` and
345-
an effective account `allowFrom` containing the literal `"*"`. An empty
346-
allowlist or user-specific IDs without `"*"` fails startup. Pairing and
347-
per-user DM allowlists are rejected because Slack user IDs are not
348-
workspace-qualified in those authorization stores. Channel and sender policy
349-
continues to apply to channel messages.
351+
Enterprise DMs support the same `disabled`, `open`, `allowlist`, and `pairing`
352+
policies as workspace installs. Pairing approvals are stored as
353+
`team:<team-id>:user:<user-id>` and are applied only to events from that
354+
workspace. Explicit account `allowFrom` entries remain organization-wide;
355+
channel and sender policy continues to apply to channel messages.
350356

351357
## Install
352358

@@ -1901,17 +1907,17 @@ Slack does not send presence changes through the Events API or Socket Mode. Open
19011907
- `auto`: monitor DMs, MPIMs, and Slack threads active in the last 24 hours with at most 8 observed human participants. Top-level channel sessions are excluded.
19021908
- `on`: monitor the same conversations without the participant cap and include top-level channel sessions. Use a per-channel override to force or suppress one channel.
19031909

1904-
OpenClaw polls at most 45 unique users per minute per Slack account, seeds the first result without waking the agent, and only wakes on an observed `away` to `active` transition. A durable 8-hour cooldown applies per Slack account and user, even if that person participates in several threads. The event routes only to that person's most recently active eligible conversation and tells the agent to consult memory/wiki and known timezone context before deciding whether to send one short greeting. The agent may stay silent.
1910+
OpenClaw polls at most 45 unique workspace-user pairs per minute per Slack account, seeds the first result without waking the agent, and only wakes on an observed `away` to `active` transition. A durable 8-hour cooldown applies per Slack account, workspace, and user, even if that person participates in several threads. The event routes only to that person's most recently active eligible conversation and tells the agent to consult memory/wiki and known timezone context before deciding whether to send one short greeting. The agent may stay silent.
19051911

1906-
The bot token needs `users:read`, which is already included in the recommended manifest. Presence events are unavailable for Enterprise Grid org-wide installs.
1912+
The bot token needs `users:read`, which is already included in the recommended manifest. Enterprise Grid org-wide installs create a workspace-scoped polling client only after an authorized event identifies that workspace; presence state, cooldowns, and delivery targets remain partitioned by workspace.
19071913

19081914
## Configuration reference
19091915

19101916
Primary reference: [Configuration reference - Slack](/gateway/config-channels#slack).
19111917

19121918
<Accordion title="High-signal Slack fields">
19131919

1914-
- mode/auth: `identity`, `mode`, `enterpriseOrgInstall`, `botToken`, `appToken`, `userToken`, `signingSecret`, `webhookPath`, `accounts.*`
1920+
- mode/auth: `identity`, `mode`, `botToken`, `appToken`, `userToken`, `signingSecret`, `webhookPath`, `accounts.*`
19151921
- DM access: `dm.enabled`, `dmPolicy`, `allowFrom` (legacy: `dm.policy`, `dm.allowFrom`), `dm.groupEnabled`, `dm.groupChannels`
19161922
- compatibility toggle: `dangerouslyAllowNameMatching` (break-glass; keep off unless needed)
19171923
- channel access: `groupPolicy`, `channels.*`, `channels.*.users`, `channels.*.requireMention`, `implicitMentions.*`

‎docs/gateway/config-channels.md‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -473,20 +473,22 @@ WhatsApp runs through the gateway's web channel (Baileys Web). It starts automat
473473
- **Socket mode** requires both `botToken` and `appToken` (`SLACK_BOT_TOKEN` + `SLACK_APP_TOKEN` for default account env fallback).
474474
- **HTTP mode** requires `botToken` plus `signingSecret` (at root or per-account).
475475
- **User identity** (`identity: "user"`) posts and reads as the authorizing human. It requires `userToken` plus `appToken` in Socket Mode, or `userToken` plus `signingSecret` in HTTP mode. No bot token or bot user is required. See [User identity](/channels/slack#user-identity-post-as-a-real-person) for user scopes and event subscriptions.
476-
- `enterpriseOrgInstall: true` opts an account into the Slack Enterprise Grid
477-
org-wide event path. Startup verifies the bot token with `auth.test` and
478-
fails when the configured mode does not match Slack's installation identity.
479-
Enterprise DMs must be disabled or use `dmPolicy: "open"` with an effective
480-
`allowFrom: ["*"]`. Channel and user policies must use stable Slack IDs;
481-
mutable names and unsupported channel prefixes fail startup. V1 handles only
482-
direct Socket Mode or HTTP `message` and `app_mention` events with immediate
483-
replies; relay, commands, interactions, App Home, reaction event listeners,
484-
pins, action tools, native approvals, bindings, deferred delivery, and
485-
proactive sends are unavailable. Listener-owned acknowledgment, typing, and
486-
status reactions remain available with `reactions:write`; inbound reaction
487-
notifications and reaction action tools are unavailable. See
476+
- Slack detects Enterprise Grid org-wide installations automatically from the
477+
bot token with `auth.test`; no installation-mode setting is required.
478+
Enterprise DMs support `disabled`, `open`, `allowlist`, and workspace-scoped
479+
`pairing`. Channel and user policies must use stable Slack IDs; mutable names
480+
and unsupported channel prefixes fail startup. Mention-pattern channel
481+
scopes and static route-binding peers use workspace-qualified Slack targets.
482+
Direct Socket Mode or HTTP messages, mentions, workspace-qualified actions,
483+
deferred delivery, proactive sends, supported event listeners and
484+
interactions, static route bindings, and Slack-native approvals from
485+
workspace-qualified turns are supported. Relay, channel-ID-change events,
486+
App Home, Agent and Assistant lifecycle events, configured ACP bindings, and
487+
runtime current-conversation bindings remain unavailable. See
488488
[Enterprise Grid org-wide installs](/channels/slack#enterprise-grid-org-wide-installs)
489489
for the least-privilege manifest, setup workflow, and complete restrictions.
490+
- The retired `enterpriseOrgInstall` key is removed by `openclaw doctor --fix`
491+
at the Slack root and account levels.
490492
- `botToken`, `appToken`, `signingSecret`, and `userToken` accept plaintext
491493
strings or SecretRef objects.
492494
- Slack account snapshots expose per-credential source/status fields such as

0 commit comments

Comments
 (0)