Skip to content

vishkrish200/supermemory-slack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Supermemory Slack Connector

Seamlessly sync Slack conversations to Supermemory for intelligent knowledge management

A production-ready Cloudflare Workers-based connector that integrates Slack workspaces with Supermemory, enabling real-time message synchronization and historical backfills with enterprise-grade security and scalability.

Deploy with Wrangler

πŸš€ Features

Real-time Synchronization

  • Live message ingestion via Slack Events API
  • Thread-aware processing with complete conversation context
  • File attachment handling with secure URL management
  • Multi-channel support with granular control

Historical Backfill

  • Cursor-based pagination for efficient historical data retrieval
  • Configurable document limits per channel to control costs
  • Progress tracking and resumability for large workspaces
  • Rate limit-aware processing (~50 req/min compliance)

Enterprise Security

  • Token encryption using AES-GCM before database storage
  • Request signature verification using Slack's HMAC-SHA256
  • Automatic token rotation and revocation support
  • GDPR compliance with user data deletion capabilities

Production-Ready Infrastructure

  • Multi-environment deployment (development, staging, production)
  • Comprehensive observability with metrics and logging
  • Rate limiting to prevent API abuse
  • Error handling with exponential backoff retry logic

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Slack API     │───▢│ Cloudflare      │───▢│   Supermemory   β”‚
β”‚                 β”‚    β”‚ Workers         β”‚    β”‚   API           β”‚
β”‚ β€’ Events API    β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ β€’ OAuth Flow    β”‚    β”‚ β€’ Rate Limiting β”‚    β”‚ β€’ /v3/memories  β”‚
β”‚ β€’ Web API       β”‚    β”‚ β€’ Encryption    β”‚    β”‚ β€’ Knowledge     β”‚
β”‚                 β”‚    β”‚ β€’ Transformationβ”‚    β”‚   Storage       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                       β”‚ Cloudflare D1   β”‚
                       β”‚                 β”‚
                       β”‚ β€’ Teams/Tokens  β”‚
                       β”‚ β€’ Channels      β”‚
                       β”‚ β€’ Sync Logs     β”‚
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

src/
β”œβ”€β”€ index.tsx           # Main Worker entry point
β”œβ”€β”€ auth.ts            # Better Auth configuration
β”œβ”€β”€ api.ts             # API route handlers
β”œβ”€β”€ slack/
β”‚   β”œβ”€β”€ index.ts       # Slack router and main handlers
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ client.ts  # Slack API client with rate limiting
β”‚   β”‚   └── transformer.ts # Message transformation logic
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── signature.ts # Request signature verification
β”‚   β”œβ”€β”€ types/         # TypeScript interfaces
β”‚   └── handlers/      # Event-specific handlers
β”œβ”€β”€ db/
β”‚   β”œβ”€β”€ schema.ts      # Database schema definitions
β”‚   └── slackOperations.ts # Database operations
β”œβ”€β”€ middleware/
β”‚   β”œβ”€β”€ rateLimit.ts   # General rate limiting
β”‚   └── slackRateLimit.ts # Slack-specific rate limiting
└── utils/
    β”œβ”€β”€ cipher.ts      # Encryption utilities
    └── key.ts         # Key management

🚦 Quick Start

Prerequisites

1. Clone and Install

git clone https://github.com/supermemoryai/slack-connector.git
cd slack-connector
npm install

2. Configure Environment

# Copy environment template
cp .dev.vars.example .dev.vars

# Edit with your credentials
nano .dev.vars

3. Setup Database

# Create D1 database
wrangler d1 create supermemory-slack

# Apply migrations
npm run drizzle:migrate

4. Deploy

# Development
npm run dev

# Production
npm run deploy

5. Configure Slack App

πŸ”§ Create & Configure Slack App:

For experienced developers (10-15 min setup):

For detailed step-by-step instructions:

Generate app manifest:

# Create manifest for your environment
npm run manifest:generate -- --env production

# Then follow the setup guide to create your Slack app

πŸ“– Detailed Setup

For comprehensive deployment instructions, including production configuration, security setup, and troubleshooting, see our documentation:

For automated setup, use our interactive configuration tool:

npm run setup:deployment

πŸ”§ Development

Local Development

# Start local development server
npm run dev

# Run tests
npm test

# Lint code
npm run lint

# Generate database migrations
npm run drizzle:generate

Environment Variables

Required

  • SLACK_CLIENT_ID - From your Slack app's Basic Information
  • SLACK_CLIENT_SECRET - From your Slack app's Basic Information
  • SLACK_SIGNING_SECRET - From your Slack app's Basic Information
  • SUPERMEMORY_API_KEY - Your Supermemory API key
  • SECRET - Encryption key for token storage (32+ characters)

Optional

  • SLACK_BOT_TOKEN - For testing (usually obtained via OAuth)
  • SLACK_USER_TOKEN - For testing (usually obtained via OAuth)
  • SUPERMEMORY_API_URL - API endpoint (default: https://api.supermemory.ai)

πŸ” Security

Token Management

  • All Slack tokens are encrypted using AES-GCM before database storage
  • Tokens are automatically rotated and can be revoked on demand
  • Encryption keys are managed through Cloudflare Workers Secrets

Request Verification

  • All incoming Slack requests are verified using HMAC-SHA256 signatures
  • Timestamp validation prevents replay attacks
  • Request body integrity is maintained throughout processing

Rate Limiting

  • Slack API rate limits are respected with intelligent backoff
  • Per-team, per-method rate limiting prevents abuse
  • Configurable thresholds for different API tiers

πŸ“Š Monitoring & Observability

Built-in Metrics

  • Events received per workspace
  • Memories created success/failure rates
  • Latency tracking from event receipt to memory creation
  • Rate limit monitoring and prevention
  • Error rates with detailed categorization

Logging

  • Structured JSON logging throughout the application
  • Request tracing with correlation IDs
  • Performance metrics and bottleneck identification
  • Security event auditing

Dashboards

Access real-time metrics through:

  • Cloudflare Workers Analytics Dashboard
  • Custom metrics via Workers Observability
  • Logs accessible via wrangler tail

πŸ› οΈ API Reference

OAuth Endpoints

  • GET /auth/slack/install - Initiate Slack OAuth flow
  • GET /auth/slack/callback - Handle OAuth callback

Slack Integration

  • POST /slack/events - Receive Slack events
  • POST /slack/interactive - Handle interactive components

Management

  • GET /health - Health check endpoint
  • GET /api/status - System status and metrics

Webhook Events Supported

  • message.channels - Public channel messages
  • message.groups - Private channel messages
  • message.im - Direct messages
  • message.mpim - Group direct messages
  • file_shared - File attachments

πŸš€ Deployment

Environment-Specific Deployment

# Deploy to staging
wrangler deploy --env staging

# Deploy to production
wrangler deploy --env production

Secrets Management

# Set production secrets
wrangler secret put SLACK_CLIENT_SECRET
wrangler secret put SUPERMEMORY_API_KEY
wrangler secret put SECRET

Database Migrations

# Apply to production
npm run drizzle:migrate:prod

πŸ§ͺ Testing

Unit Tests

# Run all tests
npm test

# Run specific test files
npm test slackDatabase.spec.ts
npm test slackRateLimit.spec.ts

Integration Testing

# Test with local environment
npm run dev

# Test Slack webhook signature verification
curl -X POST http://localhost:8787/slack/events \
  -H "Content-Type: application/json" \
  -H "X-Slack-Signature: v0=..." \
  -H "X-Slack-Request-Timestamp: ..." \
  -d '{"type":"url_verification","challenge":"test"}'

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Ensure tests pass: npm test
  5. Lint your code: npm run lint
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Open a Pull Request

Code Style

  • Follow TypeScript best practices
  • Use Biome for consistent formatting
  • Add JSDoc comments for public APIs
  • Write comprehensive tests for new features

Submitting Issues

When reporting issues, please include:

  • Steps to reproduce the problem
  • Expected behavior
  • Actual behavior
  • Environment details (Wrangler version, Node.js version)
  • Relevant log output

πŸ” Troubleshooting

Common Issues

Signature Verification Failures

# Check signing secret
wrangler secret list
# Verify webhook URL in Slack app settings

Database Connection Errors

# Verify D1 database ID in wrangler.jsonc
wrangler d1 info supermemory-slack

Rate Limit Errors

# Monitor rate limit status
wrangler tail
# Adjust rate limiting configuration if needed

Debug Mode

# Enable verbose logging
export LOG_LEVEL=debug
npm run dev

For more troubleshooting information, see the Deployment Guide.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support


Made with ❀️ by the Supermemory team

About

Slack connector for Supermemory - sync conversations to your knowledge base via Cloudflare Workers

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published