Slack Connector¶
Built-in connector for the Slack Web API using a bot token: post messages, manage channel membership, list channels, and look up users by email.
Developer workspace setup¶
- Create a workspace at slack.com (or use an existing dev workspace).
- Create an app at api.slack.com/apps → From scratch.
- Under OAuth & Permissions → Bot Token Scopes, add:
| Scope | Used by |
|---|---|
chat:write |
postMessage |
chat:write.public |
Post to public channels the bot has not joined (workspace policy permitting) |
channels:read |
listChannels (public) |
channels:manage |
inviteToChannel / removeFromChannel (public) |
groups:read |
listChannels (private) |
groups:write |
inviteToChannel / removeFromChannel (private) |
users:read |
Resolve users when extending commands |
users:read.email |
lookupUserByEmail (Slack gates email lookup behind this scope) |
- Install App to Workspace and copy the Bot User OAuth Token (
xoxb-…). - In Floh, create a connector instance of type slack and paste the token into Bot token (encrypted at rest).
- Invite the bot to any channel where it should post or manage membership (
/invite @YourBot).
Connection configuration¶
Create a connector instance via the Connectors API or UI with type slack.
| Field | Required | Secret | Description |
|---|---|---|---|
| botToken | Yes | Yes | Bot User OAuth Token (xoxb-…) |
Manual QA checklist¶
- [ ] Test connection (
testcommand) returns team and bot user. - [ ] postMessage to a channel ID (
C…) the bot has joined. - [ ] inviteToChannel with a Slack user ID (
U…). - [ ] removeFromChannel for the same user.
- [ ] listChannels returns expected channel names.
- [ ] lookupUserByEmail with a workspace email returns the matching
userId(SlackU…).
Local HTTP mocks¶
Optional overlay:
SlackHog captures outbound Web API calls for inspection. Floh’s connectorHttpRequest URL policy may reject private-network targets (for example http://localhost:…) from the server container unless you use a publicly reachable mock URL. Prefer unit tests with mocked HTTP and a real dev workspace for integration QA.
Channel and user identifiers¶
- Channels: use conversation IDs (
C…/G…), not#name, unless your workspace resolves names elsewhere. - Users:
inviteToChannelandremoveFromChanneltake Slack user IDs (U…). When a workflow only has an email address, runlookupUserByEmailfirst and feed itsuserIdoutput into the membership command. - lookupUserByEmail: pass a plain address (
you@company.com) or a single RFC-styleDisplay Name <you@company.com>string; only the first line is used. The connector callsusers.lookupByEmailvia POST JSON body (not the legacy GET query-string form) so the email address never appears in network-layer URL logs (proxy access logs,NODE_DEBUG=httptraces, etc.). - listChannels
limit: Floh clamps the value to 1–1000 before calling Slack (conversations.listhard-caps at 1000).
Troubleshooting¶
| Slack error / symptom | Typical cause |
|---|---|
restricted_action on removeFromChannel |
Workspace channel management policy: only certain roles may remove members, or the channel type (e.g. #general) is protected. Adjust policy under Settings → Administration → Workspace settings → Channel management, remove the user manually, or use a channel where the bot is allowed to manage membership. |
not_in_channel on invite / post |
The bot has not been added to that channel (/invite @YourBot). |
missing_scope |
Reinstall the app after adding bot scopes under OAuth & Permissions. |
Related code¶
| Area | Path |
|---|---|
| Connector definition | packages/server/src/modules/connectors/handlers/slack.ts |
| HTTP client & commands | packages/server/src/modules/connectors/handlers/slack-support/ |
| Unit tests | packages/server/test/unit/connectors/slack-*.test.ts |