@anura-gate/watcher-slack
v0.3.0
Published
GATE Watcher — Self-hosted Slack Bot. Tokens never leave your machine.
Maintainers
Readme
GATE Watcher — Slack
Self-hosted daemon that connects your Slack Bot to GATE cloud for security processing via Socket Mode. Your bot tokens never leave your machine.
How it works
Your Machine (Watcher) GATE Cloud
┌─────────────────────┐ ┌──────────────────┐
│ Slack Socket Mode │───────>│ Security pipeline │
│ (tokens stay HERE) │<───────│ (redact, policy, │
│ │ poll │ audit, forward) │
└─────────────────────┘ └──────────────────┘Quick Start (CLI)
cd gate-watcher-slack
npm install
# Create .env (or pass env vars directly)
cp .env.example .env
# Fill in GATE_KEY, GATE_INTEGRATION_ID, SLACK_BOT_TOKEN, SLACK_APP_TOKEN
npm startEmbed in Your App (SDK)
npm install @anura-gate/watcher-slackconst { GateSlackWatcher } = require("@anura-gate/watcher-slack");
const watcher = new GateSlackWatcher({
gateKey: "gk-xxx",
integrationId: "int_xxx",
botToken: "xoxb-xxx",
appToken: "xapp-xxx",
});
watcher.on("ready", (botUserId, botName, teamName) => {
console.log(`Slack connected: ${botName} in ${teamName}`);
});
// Every message after GATE security processing
watcher.on("message", (event, result) => {
console.log(`From: ${event.user}, Text: ${event.text}`);
console.log(`Security actions: ${result.securityActions}`);
console.log(`Blocked: ${result.blocked}`);
});
watcher.on("reaction", (event, result) => {
console.log(`Reaction: ${event.reaction} by ${event.user}`);
});
watcher.on("action_result", ({ action, success, error }) => {
console.log(`${action}: ${success ? "done" : error}`);
});
await watcher.start();
// Later...
await watcher.stop();SDK Events
| Event | Args | Description |
|---|---|---|
| ready | (botUserId, botName, teamName, teamId) | Connected to Slack |
| message | (event, result) | Message received and processed by GATE |
| reaction | (event, result) | Reaction added, processed by GATE |
| member_joined | (event, result) | Member joined a channel |
| mention | (event, result) | Bot mentioned in a channel |
| action | (action) | Outbound action received from GATE queue |
| action_result | ({ actionId, action, success, result, error }) | Outbound action completed |
| gate_error | ({ path, status, error }) | GATE API call failed |
| limit_reached | (type) | Plan limit hit |
| disconnected | (reason) | Disconnected from Slack |
| stopped | — | Watcher fully shut down |
SDK Options
| Option | Required | Default | Description |
|---|---|---|---|
| gateKey | Yes | — | Virtual key (gk-xxx) |
| integrationId | Yes | — | Integration ID (int_xxx) |
| botToken | Yes | — | Slack Bot User OAuth Token (xoxb-...) |
| appToken | Yes | — | Slack App-Level Token for Socket Mode (xapp-...) |
| gateUrl | No | "https://anuragate.com" | GATE cloud URL |
| heartbeatInterval | No | 30000 | ms between heartbeats |
| pollInterval | No | 3000 | ms between outbound polls |
| sessionId | No | — | Session ID for multi-tenant use |
| sessionLabel | No | — | Human-readable session label |
| sessionMetadata | No | {} | Arbitrary metadata for the session |
Setup
- Go to api.slack.com/apps and create a new app
- Under Socket Mode, enable Socket Mode and generate an App-Level Token with
connections:writescope — this is yourSLACK_APP_TOKEN(xapp-...) - Under OAuth & Permissions, add Bot Token Scopes:
chat:write,reactions:write,channels:history,groups:history,im:history - Install the app to your workspace and copy the Bot User OAuth Token — this is your
SLACK_BOT_TOKEN(xoxb-...) - Under Event Subscriptions, enable events and subscribe to:
message.channels,message.groups,message.im,reaction_added,member_joined_channel,app_mention - Go to GATE Dashboard → Integrations → Add Integration, select Slack, copy the Integration ID
- Copy your Virtual Key from the Keys page
Environment Variables
| Variable | Required | Description |
|---|---|---|
| GATE_KEY | Yes | Your GATE virtual key |
| GATE_INTEGRATION_ID | Yes | Integration ID from the dashboard |
| SLACK_BOT_TOKEN | Yes | Bot User OAuth Token (xoxb-...) |
| SLACK_APP_TOKEN | Yes | App-Level Token (xapp-...) |
| GATE_URL | No | Custom GATE cloud URL |
| WEB_PORT | No | Port for the dev dashboard (CLI only) |
Security model
- Slack tokens stored in
.envon YOUR machine - GATE cloud never sees or stores your credentials
- All message content passes through GATE's security pipeline
- Billing, limits, and security enforced server-side
