Skip to main content

Slack

KhunQuant connects to Slack using Socket Mode, which establishes a persistent WebSocket connection to Slack's servers. No inbound public URL is required — all traffic is initiated outbound from your machine, making this the easiest channel to run behind a firewall or NAT.

Capabilities

  • Direct message and channel message send/receive
  • Threaded replies (channel messages are automatically threaded)
  • Typing indicator
  • Processing placeholder message ("Thinking...")
  • Emoji acknowledgement reactions (✅)
  • File uploads
  • Allow-listing by Slack user ID
  • Dedicated reasoning output channel

Configuration

Add to ~/.khunquant/config.json:

{
"channels": {
"slack": {
"enabled": true,
"bot_token": "xoxb-YOUR-BOT-TOKEN",
"app_token": "xapp-YOUR-APP-TOKEN",
"allow_from": [],
"group_trigger": {
"mention_only": true
},
"typing": {
"enabled": true
},
"placeholder": {
"enabled": true,
"text": "Thinking..."
},
"reasoning_channel_id": ""
}
}
}

Store tokens in ~/.khunquant/.security.yml:

channels:
slack:
bot_token: "xoxb-..."
app_token: "xapp-..."
FieldTypeDescription
enabledboolEnable the Slack channel
bot_tokenSecureStringBot User OAuth Token (xoxb-) for sending messages
app_tokenSecureStringApp-Level Token (xapp-) for Socket Mode connection
allow_from[]stringAllowlist of Slack user IDs (empty allows all)
group_trigger.mention_onlyboolOnly respond in channels when the bot is @mentioned
typing.enabledboolShow typing indicator while generating a response
placeholder.enabledboolPost a temporary placeholder while processing
placeholder.textstringText of the placeholder message
reasoning_channel_idstringChannel ID for streaming reasoning output separately

Setup steps

  1. Go to api.slack.com/apps and click Create New App → From scratch.

  2. Under Settings → Socket Mode, enable Socket Mode and generate an App-Level Token with the connections:write scope. Copy the token (xapp-).

  3. Under OAuth & Permissions → Bot Token Scopes, add the following scopes:

    ScopePurpose
    chat:writeSend messages
    im:historyRead DM history
    im:readAccess DM channels
    reactions:writeAdd emoji reactions
    files:writeUpload files
    channels:historyRead channel messages
    app_mentions:readDetect @mentions
  4. Click Install to Workspace and copy the Bot User OAuth Token (xoxb-).

  5. Under Event Subscriptions, enable events and subscribe to: message.im, message.channels, and app_mention.

  6. Add both tokens to .security.yml.

  7. Start KhunQuant.

Finding your user ID

In Slack, click your profile photo → Profile → the three-dot menu → Copy member ID. Use this value in allow_from.

Long messages

Responses exceeding Slack's character limit are automatically split across multiple messages so no content is truncated.