@capybara-hq/plugin-slack 0.0.0-stage → 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.capybara-plugin/plugin.json +65 -0
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +168 -2
- package/THIRD-PARTY-NOTICES.txt +294 -0
- package/app-manifest.yaml +46 -0
- package/dist/index.mjs +38978 -0
- package/package.json +19 -4
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "slack",
|
|
4
|
+
"version": "0.1.0-rc.0",
|
|
5
|
+
"publisher": "Capybara",
|
|
6
|
+
"description": "Slack (channel@1 bot over Socket Mode with Block Kit cards, identity-source@1 Sign in with Slack, directory@1)",
|
|
7
|
+
"homepage": "https://github.com/capybara-hq/plugins/tree/main/plugins/slack#readme",
|
|
8
|
+
"extension": {
|
|
9
|
+
"entry": "./dist/index.mjs",
|
|
10
|
+
"manifest": {
|
|
11
|
+
"name": "slack",
|
|
12
|
+
"version": "0.1.0-rc.0",
|
|
13
|
+
"sdk": "^0.1.0-rc.0",
|
|
14
|
+
"provides": [
|
|
15
|
+
"channel@1",
|
|
16
|
+
"identity-source@1",
|
|
17
|
+
"directory@1"
|
|
18
|
+
],
|
|
19
|
+
"requires": [],
|
|
20
|
+
"optional": [],
|
|
21
|
+
"permissions": {
|
|
22
|
+
"network": [
|
|
23
|
+
"slack.com",
|
|
24
|
+
"wss-primary.slack.com"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"config": {
|
|
28
|
+
"deployment": [
|
|
29
|
+
{
|
|
30
|
+
"path": "apiUrl",
|
|
31
|
+
"secret": false,
|
|
32
|
+
"hot": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"path": "clientId",
|
|
36
|
+
"secret": false,
|
|
37
|
+
"hot": false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "clientSecret",
|
|
41
|
+
"secret": true,
|
|
42
|
+
"hot": false
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "openidUrl",
|
|
46
|
+
"secret": false,
|
|
47
|
+
"hot": false
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"org": [
|
|
51
|
+
{
|
|
52
|
+
"path": "botToken",
|
|
53
|
+
"secret": true,
|
|
54
|
+
"hot": false
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"path": "teamId",
|
|
58
|
+
"secret": false,
|
|
59
|
+
"hot": false
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,169 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @capybara-hq/plugin-slack
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official Slack plugin. It provides three capabilities:
|
|
4
|
+
|
|
5
|
+
- `channel@1` (bot): receives events over [Socket Mode](https://docs.slack.dev/apis/events-api/using-socket-mode)
|
|
6
|
+
(no public callback URL needed), sends messages through the Web API, and renders approval / question /
|
|
7
|
+
connection / binding cards as Block Kit.
|
|
8
|
+
- `identity-source@1` (Sign in with Slack, OpenID Connect): sign in to Capybara with a Slack account.
|
|
9
|
+
- `directory@1` (directory sync): syncs Slack workspace members into org members.
|
|
10
|
+
|
|
11
|
+
All three use the same identity key: `identities.source` = `slack:<team id>`, `external_id` = the Slack user id (`U…`).
|
|
12
|
+
When the same person appears through sign-in, a DM to the bot and directory sync, it maps to one identity row and one account.
|
|
13
|
+
|
|
14
|
+
The Slack docs cited here were consulted on 2026-10-20.
|
|
15
|
+
|
|
16
|
+
## Create the Slack app
|
|
17
|
+
|
|
18
|
+
1. Open <https://api.slack.com/apps> → **Create New App** → **From a manifest**, pick the workspace, and paste this directory's
|
|
19
|
+
[`app-manifest.yaml`](./app-manifest.yaml) (format: [App manifest reference](https://docs.slack.dev/reference/app-manifest)).
|
|
20
|
+
It turns on Socket Mode and Interactivity, subscribes to the events `message.im`, `app_mention`, `message.channels`,
|
|
21
|
+
`message.groups`, `team_join` and `user_change`, and requests these bot scopes:
|
|
22
|
+
|
|
23
|
+
| scope | Purpose |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `chat:write` | Send and update replies and cards |
|
|
26
|
+
| `im:history` | Receive DM messages |
|
|
27
|
+
| `app_mentions:read` | Receive messages that @-mention the bot in channels |
|
|
28
|
+
| `channels:history` / `groups:history` | Receive thread replies in public / private channels |
|
|
29
|
+
| `users:read` | Look up the speaker's display name and avatar; people-change events; directory `users.list` |
|
|
30
|
+
| `users:read.email` | Read emails during directory sync (the bot itself does not use it) |
|
|
31
|
+
|
|
32
|
+
2. **Basic Information → App-Level Tokens → Generate Token and Scopes**: add the scope `connections:write`
|
|
33
|
+
to get the app-level token `xapp-…` (Socket Mode uses it to call `apps.connections.open`).
|
|
34
|
+
3. **Install App → Install to Workspace** to get the bot token `xoxb-…`.
|
|
35
|
+
4. In the Capybara org settings, enable the `slack` plugin, then **create a new channel connection**: pick Slack as the plugin, fill in `appToken` (`xapp-…`) and
|
|
36
|
+
`botToken` (`xoxb-…`), and bind an agent. Both are stored in the secret store, and the API only returns "set".
|
|
37
|
+
5. In Slack, DM the bot, or add the bot to a channel and @-mention it. The first conversation gets a binding card; click the button to confirm the binding on the web page.
|
|
38
|
+
|
|
39
|
+
Note: apps that use Socket Mode cannot currently be listed in the public Slack Marketplace, and one app can hold at most 10 concurrent
|
|
40
|
+
Socket Mode connections ([Using Socket Mode](https://docs.slack.dev/apis/events-api/using-socket-mode)). At any moment Capybara has only one
|
|
41
|
+
replica hold one connection per channel connection.
|
|
42
|
+
|
|
43
|
+
In long-connection mode the connection is held by one `gateway` replica; with several gateways the
|
|
44
|
+
connections are spread by fair share (`channels.shareSlack`, see
|
|
45
|
+
[Roles and scaling](https://github.com/capybara-hq/core/blob/main/docs/deploy/README.md#roles-and-scaling)).
|
|
46
|
+
|
|
47
|
+
## Webhook inbound mode (optional)
|
|
48
|
+
|
|
49
|
+
Socket Mode is the default. A connection can instead receive events over HTTPS webhooks, when the
|
|
50
|
+
deployment exposes a gateway replica and sets `channels.webhookBaseUrl` (see
|
|
51
|
+
[Deploying: webhook](https://github.com/capybara-hq/core/blob/main/docs/deploy/README.md#webhook-optional)). Switch the connection to webhook mode in the web app (Channels →
|
|
52
|
+
connection → Overview → Inbound mode); the connection page then shows its webhook URL.
|
|
53
|
+
|
|
54
|
+
1. Copy **Basic Information → App Credentials → Signing Secret** into the connection's
|
|
55
|
+
`signingSecret`. Every request is verified with it (HMAC-SHA256 over `v0:<timestamp>:<body>`)
|
|
56
|
+
and must be at most 5 minutes old; without it every webhook request is refused.
|
|
57
|
+
2. In the app settings, turn **Socket Mode** off, then use the webhook URL as the **Event
|
|
58
|
+
Subscriptions → Request URL** (Slack verifies it with a `url_verification` challenge, which the
|
|
59
|
+
plugin answers) and as the **Interactivity & Shortcuts → Request URL** (card buttons).
|
|
60
|
+
3. `appToken` is optional in webhook mode: only Socket Mode uses it.
|
|
61
|
+
|
|
62
|
+
Both modes parse events the same way (same message and card-click ids), so the kernel's dedupe
|
|
63
|
+
still drops a redelivery that arrives across a mode switch.
|
|
64
|
+
|
|
65
|
+
## Sign in with Slack (login)
|
|
66
|
+
|
|
67
|
+
[Sign in with Slack](https://docs.slack.dev/authentication/sign-in-with-slack/) is based on OpenID Connect.
|
|
68
|
+
|
|
69
|
+
1. In the app settings, add
|
|
70
|
+
`<http.publicUrl>/api/v1/auth/sso/slack/callback` under **OAuth & Permissions → Redirect URLs** (for example `https://capybara.example.com/api/v1/auth/sso/slack/callback`;
|
|
71
|
+
the `redirect_uri` the kernel sends must equal it or be a sub-path of it).
|
|
72
|
+
2. The login flow requests the scopes `openid`, `email` and `profile` in the authorization URL (`openid` is required; `email` gives the email and
|
|
73
|
+
`email_verified`, `profile` gives the name and avatar). Do **not** add them to the app's Bot / User Token Scopes: Slack requires the
|
|
74
|
+
Sign in with Slack scopes to be requested in a different OAuth flow from the other scopes; installing the app (bot) and signing in are two separate flows.
|
|
75
|
+
3. Put the Client ID and Client Secret from **Basic Information → App Credentials** into the deployment-level config (see below), and add `slack`
|
|
76
|
+
to the kernel config `auth.loginSources`. "Slack" then appears on the login page.
|
|
77
|
+
|
|
78
|
+
How the plugin works: the authorization URL is `https://slack.com/openid/connect/authorize` (`response_type=code`, `state`, `nonce`);
|
|
79
|
+
the callback exchanges the authorization code at `openid.connect.token` (`client_secret_post`) and **verifies the ID token** (JWKS
|
|
80
|
+
`https://slack.com/openid/connect/keys` verifies the RS256 signature, `iss = https://slack.com`, `aud = clientId`, not expired,
|
|
81
|
+
`nonce` matches the one sent at the start), then calls `openid.connect.userInfo` with the access token to get the email, name and avatar (its user / workspace must match
|
|
82
|
+
the ID token). `email_verified` is used as-is as the email-verified flag.
|
|
83
|
+
|
|
84
|
+
**No PKCE**: neither Slack's OIDC docs nor its [discovery](https://slack.com/.well-known/openid-configuration) declare
|
|
85
|
+
PKCE; Slack's [PKCE](https://docs.slack.dev/authentication/using-pkce) applies only to `oauth.v2.*`, and once enabled the app irreversibly
|
|
86
|
+
becomes a public client. The plugin ignores the PKCE parameters the kernel supplies; login is protected by the kernel's state (single use, bound to the browser that started the login), the nonce
|
|
87
|
+
(checked inside the verified ID token) and the client secret.
|
|
88
|
+
|
|
89
|
+
Note: users from any Slack workspace can complete Sign in with Slack (as with other identity sources, login only creates an account and does not join any org;
|
|
90
|
+
org membership comes from invitations or directory sync). Merging into an existing account by verified email applies only to identity-source tenants the admin trusts.
|
|
91
|
+
|
|
92
|
+
## Directory (directory@1)
|
|
93
|
+
|
|
94
|
+
When enabling the `slack` plugin in the org settings, fill in the org-level config `teamId` (the workspace id, `T…`) and `botToken` (`xoxb-…`; it may be the same bot token as a
|
|
95
|
+
channel connection uses, but the config is stored separately and goes through the secret store). The bot token needs:
|
|
96
|
+
|
|
97
|
+
| scope | Purpose |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `users:read` | [`users.list`](https://docs.slack.dev/reference/methods/users.list) lists members |
|
|
100
|
+
| `users:read.email` | Member emails (without it `users.list` returns no emails) |
|
|
101
|
+
|
|
102
|
+
- The tenant is the **workspace**: `teamId` accepts only `T…`; an enterprise id (`E…`) would split one person into two identity rows. Each page first calls `auth.test`:
|
|
103
|
+
a token from an org-level install (`is_enterprise_install`) or a token whose `team_id` is not `T…` is rejected; the workspace the token belongs to must also equal
|
|
104
|
+
`teamId`, otherwise the sync errors (to avoid recording another workspace's people as this tenant). For Enterprise Grid, use each workspace's own bot token.
|
|
105
|
+
- `users.list` paginates by cursor (200 per page; Slack recommends at most 200); it excludes bots (`is_bot`), Slackbot (`USLACKBOT`),
|
|
106
|
+
**guests** (`is_restricted` multi-channel guests, `is_ultra_restricted` single-channel guests; guests do not become org members and can be invited manually if needed),
|
|
107
|
+
and, under Enterprise Grid, members of other workspaces whose own `team_id` differs from `teamId`; people with `deleted = true` are reported as departed
|
|
108
|
+
(`active = false`), and the kernel only revokes memberships that were added by directory sync.
|
|
109
|
+
- Emails are always reported as **unverified**: the `users.list` docs do not say whether `profile.email` is verified (only OIDC's
|
|
110
|
+
`email_verified` at login counts).
|
|
111
|
+
- Rate limits: `users.list` is Tier 2 (20+ requests/minute). On HTTP 429 the sync waits per `Retry-After` and retries within the same sync, at most 3 times and
|
|
112
|
+
at most 30 seconds cumulative per page; beyond that it errors, the kernel records the run as incomplete (it only adds people and removes no one), and the next sync tries again.
|
|
113
|
+
- People-change events (`team_join`, `user_change`, received through the channel connection) trigger a sync.
|
|
114
|
+
- When `teamId` / `botToken` are not filled in (the org only uses the bot), the plugin's `configured()` returns false: the kernel does not scan or sync, and records no audit
|
|
115
|
+
or warning; a manual sync returns 409 `directory.not_configured`. It is not treated as an empty directory.
|
|
116
|
+
|
|
117
|
+
## Behavior
|
|
118
|
+
|
|
119
|
+
- **DMs**: every text message goes to the kernel. **Channels**: only messages that @-mention the bot (a new message gets a thread reply under it), and replies inside threads
|
|
120
|
+
(the kernel currently handles only those that @-mention the bot). Edits, deletions, messages from the bot itself and other bots, and other messages with a `subtype` are ignored;
|
|
121
|
+
file shares with a caption (`file_share`, only the text is taken) and thread replies also sent to the channel (`thread_broadcast`) are handled as text.
|
|
122
|
+
M4 handles text only. The text has the bot @-mention removed (only the whitespace on both sides of the @ is tidied; indentation and line breaks are kept) and `&` / `<` / `>` are unescaped.
|
|
123
|
+
In link addresses inside model replies, `<`, `>` and `|` are percent-encoded, so model text cannot inject control sequences such as `<!channel>`.
|
|
124
|
+
- **ids**: message id = `<channel id>:<ts>` (unique and stable within a connection); group-chat thread id = `<channel id>:<thread_ts>`, which is the message id of the thread's root message;
|
|
125
|
+
the card-click `eventId` = `<channel>:<card message ts>:<clicker>:<action_ts>` (the payload is the same on redelivery, so it is stable).
|
|
126
|
+
The speaker's tenant = the Slack team id (for an external member of a shared channel, `user_team`), on the same basis as `verify` (the `team_id` of `auth.test`).
|
|
127
|
+
- **Ack**: the kernel acks only after `onEvent` resolves; a reject is not acked, and Slack redelivers (three times in total: immediately, after about 1 minute and after about 5 minutes,
|
|
128
|
+
see [Events API](https://docs.slack.dev/apis/events-api/)).
|
|
129
|
+
- **Format**: the model reply's Markdown is converted to [mrkdwn](https://docs.slack.dev/messaging/formatting-message-text);
|
|
130
|
+
a single text is capped at 4000 characters (beyond that `chat.update` returns `msg_too_long`, see [chat.update](https://docs.slack.dev/reference/methods/chat.update)),
|
|
131
|
+
and longer text is split into several messages; when an edit is too long it reports `too_large` and the kernel sends a new message instead.
|
|
132
|
+
- **Streaming edits**: `minEditIntervalMs = 2500` (`chat.update` is Tier 3, about 50 per minute, counted per workspace, see
|
|
133
|
+
[chat.update](https://docs.slack.dev/reference/methods/chat.update) and
|
|
134
|
+
[Rate limits](https://docs.slack.dev/apis/web-api/rate-limits)); under more concurrency, 429 + Retry-After is the backstop.
|
|
135
|
+
- **Reconnect**: managed by the plugin (SDK auto-reconnect is turned off). When Slack recycles a connection normally it reconnects immediately; consecutive short-lived (under 10 seconds) connections back off exponentially
|
|
136
|
+
(with jitter), and after 5 in a row, or on receiving `link_disabled`, it reports an error; the kernel records `last_error` and backs off.
|
|
137
|
+
- **Idempotency**: `chat.postMessage` has no idempotency parameter, so `idempotencyKey` is ignored.
|
|
138
|
+
- **Profile**: the display name / avatar come from the `user_profile` carried by the event, otherwise from `users.info` (cached per process for 10 minutes, at most 1000 people,
|
|
139
|
+
1.5 second timeout; if the lookup fails it is left out).
|
|
140
|
+
- **Permission manifest**: `network: ["slack.com", "wss-primary.slack.com"]`, shown only and not enforced; login (OIDC) and the directory also use
|
|
141
|
+
`slack.com`. The WSS host for Socket Mode is
|
|
142
|
+
assigned by Slack and is not fixed (for example `wss-primary.slack.com`, `wss-backup.slack.com`, `wss-111.slack.com`); the manifest's domain
|
|
143
|
+
validation does not support wildcards, so only the main one is listed.
|
|
144
|
+
|
|
145
|
+
## Channel connection config
|
|
146
|
+
|
|
147
|
+
| Field | Description |
|
|
148
|
+
|---|---|
|
|
149
|
+
| `botToken` | Bot token (`xoxb-…`, secret) |
|
|
150
|
+
| `appToken` | App-level token (`xapp-…`, secret); required for Socket Mode, unused in webhook mode |
|
|
151
|
+
| `signingSecret` | Signing Secret (secret); required in webhook mode, unused with Socket Mode |
|
|
152
|
+
|
|
153
|
+
## Deployment-level config
|
|
154
|
+
|
|
155
|
+
| Field | Default | Description |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| `apiUrl` | `https://slack.com/api/` | Web API root URL; change it only in tests or when going through a proxy |
|
|
158
|
+
| `openidUrl` | `https://slack.com/` | Root URL for the OIDC authorization page and JWKS; change it only in tests or when going through a proxy (the ID token's `iss` is fixed at `https://slack.com`) |
|
|
159
|
+
| `clientId` | — | Client ID for Sign in with Slack; leave empty if you don't use login |
|
|
160
|
+
| `clientSecret` | — | Client Secret for Sign in with Slack (secret, masked in logs); leave empty if you don't use login |
|
|
161
|
+
|
|
162
|
+
The deployment-level config lives under the kernel config `extensionConfig.slack`.
|
|
163
|
+
|
|
164
|
+
## Org-level config
|
|
165
|
+
|
|
166
|
+
| Field | Description |
|
|
167
|
+
|---|---|
|
|
168
|
+
| `teamId` | The Slack workspace id for directory sync (`T…`) |
|
|
169
|
+
| `botToken` | The bot token for directory sync (`xoxb-…`, secret) |
|