简体中文 | English
This guide explains how to create and configure a Slack App so AskHuman's "Slack channel" works. The channel uses a Slack App + Socket Mode long connection (WebSocket) + bot + direct message (DM) model, and needs no public network to send/receive messages and card interactions.
- Open Slack API → Your Apps → Create New App → From scratch.
- Enter an app name, pick the target workspace → Create App.
Avatar: set the app icon under Settings → Basic Information → Display Information. The repo ships two images you can use as the avatar (dark / light background), or for other uses: dark · light.
- In the sidebar, Settings → Socket Mode → turn on Enable Socket Mode.
- You'll be prompted to create an App-Level Token: name it anything, add the scope
connections:write→ Generate. - Record the generated App-Level Token (starts with
xapp-; enter it in AskHuman settings).
- In the sidebar, Features → OAuth & Permissions → under Scopes → Bot Token Scopes, Add an OAuth Scope and add:
| Scope | Purpose |
|---|---|
chat:write |
Send / update messages and interactive cards |
im:write |
Open a DM channel with the target user |
im:history |
Receive message events the user sends in the DM |
files:read |
Download images / files the user sends in the DM (human → AI) |
files:write |
Upload -f attachments (AI → human file sending) |
- Scroll up to OAuth Tokens → Install to Workspace (re-install after any scope change).
- After installing, record the Bot User OAuth Token (starts with
xoxb-; enter it in AskHuman settings).
- In the sidebar, Features → Event Subscriptions → turn on Enable Events.
Under Socket Mode no Request URL is needed; events arrive over the long connection.
- Expand Subscribe to bot events → Add Bot User Event → add
message.im: used to receive text / images / files the user sends in the DM. - Save. If prompted to reinstall the app, do so.
- In the sidebar, Features → Interactivity & Shortcuts → turn on Interactivity.
Under Socket Mode no Request URL is needed either; the
block_actionsinteraction from tapping the card's "Submit" button is delivered over the long connection. - Save.
Since 2021 Slack disables users from messaging a bot by default (it's now opt-in). Skip this and, in the DM with the bot, you'll see "Sending messages to this app has been turned off" with a greyed-out input box — which blocks the "Auto-detect" 4-digit code and any images / files you try to send back while answering.
- In the sidebar, Features → App Home → find Show Tabs.
- Turn on the Messages Tab toggle.
- Check Allow users to send Slash commands and messages from the messages tab.
- Save, then refresh your Slack client (reinstall the app if needed); the DM input box will then work.
Open AskHuman settings → "Channels" → "Slack", enable the toggle, then fill in:
| Field | Description |
|---|---|
| Bot Token | Bot User OAuth Token (xoxb-…, used for all Web API calls) |
| App-Level Token | App-Level Token (xapp-…, scope connections:write, used to open the Socket Mode connection) |
| User ID | The recipient/answering user's Slack User ID (U…, DM). Click "Auto-detect": it validates both tokens, then asks you to DM the bot a 4-digit code from the target account to fill it in precisely |
Then click "Test connection": it validates the Bot Token (auth.test plus sending a test DM to that user) and the App Token (apps.connections.open returns a connection URL). If both pass, you're set.
If you can't find the User ID, use "Auto-detect". Manually: in Slack, open the target user's profile → More (···) → Copy member ID.
- Questions are sent per-question as a Block Kit in-message form: checkboxes (multi-select predefined options) + a multiline input (free text) + a "Submit" button. Tapping "Submit" completes the question (the interaction comes over Socket Mode; the transport acks each frame on receipt to satisfy Slack's 3-second requirement, handled automatically).
- On submit / when preempted, the card is replaced via
chat.updatewith a static terminal state: the question is kept, selected options (✓) and the note (💬) are echoed back, and a status line is added ("Submitted" / "Answered via X" / "Cancelled"), with all controls removed. - Images / files sent in the DM during answering are accumulated into that question's answer; plain text is ignored (use the card's input field for free text).
- If the card fails to deliver, it automatically falls back to "plain text + numbered options": reply with option numbers (comma-separated for multiple, e.g.
1,3), type free text, or send images / files. - With multiple channels enabled, the whole conversation is a single race: whichever side finishes answering all questions first wins, and the others finalize automatically (the Slack card updates to an "Answered via X" terminal state).
| Symptom | Likely cause |
|---|---|
| DM input box is greyed out / "Sending messages to this app has been turned off" | The App Home Messages Tab isn't enabled for user messaging (see step 6); refresh or reinstall the app afterwards |
Test connection reports invalid_auth / not_authed |
Wrong Bot Token, or you changed scopes without re-installing to the workspace |
| Test connection reports an App Token error | Wrong App-Level Token, or it lacks the connections:write scope |
| No incoming user messages / auto-detect keeps waiting | The message.im event isn't subscribed, or Socket Mode isn't enabled, or App Home messaging (step 6) isn't enabled; reinstall the app after changes |
| Tapping the card's "Submit" does nothing | The Interactivity toggle is off |
| File send / download permission errors | Missing files:write / files:read scope (effective after reinstall) |
Sending reports channel_not_found |
im:write not granted, so the DM channel can't be opened |
| Want to confirm long-connection events arrive | Run with ASKHUMAN_SLACK_DEBUG=1 and inspect the frame logs in ~/.askhuman/slack-debug.log |