Skip to content

redis-developer/chat-sdk-slackbot-distributed-locking

Repository files navigation

Slack support triage bot with Chat SDK and Redis

This repo is a sample app for a Slack support triage bot that:

  • Uses chat, @chat-adapter/slack, and @chat-adapter/state-redis
  • Persists thread subscriptions and triage state in Redis
  • Prevents duplicate replies when Slack retries events
  • Coordinates multiple workers with Redis-backed per-thread leases

Quickstart

npm i -g localtunnel
pnpm install
cp .env.example .env.local
docker compose up -d redis
pnpm dev
lt --port 3000

Open http://localhost:3000 for setup instructions.

Environment variables

See .env.example.

  • REDIS_URL is required.
  • SLACK_BOT_TOKEN and SLACK_SIGNING_SECRET are required for the live Slack webhook.
  • OPENAI_API_KEY is optional. Without it, the app falls back to a deterministic heuristic analyzer.
  • OPENAI_MODEL defaults to gpt-4.1-mini.

Slack app setup

  1. Open the Slack app manifest flow.
  2. Paste slack-manifest.yml.
  3. Replace https://your-domain.com/api/webhooks/slack with your public webhook URL.
  4. Install the app and copy the bot token and signing secret into .env.local.

The sample uses one webhook route:

  • POST /api/webhooks/slack

Commands and actions

The primary UX is the triage card buttons:

  • Hand off to human
  • Close triage

Optional slash commands are included for demo completeness:

  • /triage-status slack:C123:1710000000.000100
  • /triage-handoff slack:C123:1710000000.000100
  • /triage-close slack:C123:1710000000.000100

Tests

pnpm test
pnpm lint

The test suite covers the Redis-backed control path:

  • Slack event idempotency
  • Per-thread lease expiry and takeover
  • New triage replies and follow-up updates
  • Human handoff and close behavior

Docker

Run the full stack with:

docker compose up -d --build

This starts:

  • The Next.js app on http://localhost:3000
  • Redis on redis://localhost:6379

About

A Slack support triage bot that uses Chat SDK for webhook normalization, Redis for coordination and state persistence, and OpenAI (optionally) for AI-powered issue classification.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors