Files
AutoGPT/autogpt_platform/copilot-bot/README.md
Bentlybro 9eaa903978 feat: CoPilot bot service using Vercel Chat SDK
Multi-platform bot service that deploys CoPilot to Discord, Telegram,
and Slack from a single codebase using Vercel's Chat SDK.

## What's included

### Core bot (src/bot.ts)
- Chat SDK instance with dynamic adapter loading
- onNewMention: resolves platform user → AutoGPT account
- Unlinked users get a link prompt via the platform-linking API
- Subscribed message handler with state management
- MVP echo response (CoPilot API integration next)

### Platform API client (src/platform-api.ts)
- Calls /api/platform-linking/resolve on every message
- Creates link tokens for unlinked users
- Checks link token status
- Chat session creation and SSE streaming (prepared for CoPilot)

### Serverless routes (src/api/)
- POST /api/webhooks/discord — Discord interactions endpoint
- POST /api/webhooks/telegram — Telegram updates
- POST /api/webhooks/slack — Slack events
- GET /api/gateway/discord — Gateway cron for Discord messages

### Standalone mode (src/index.ts)
- Long-running process for Docker/PM2 deployment
- Auto-detects enabled adapters from env vars
- Redis or in-memory state

## Stacked on
- feat/platform-bot-linking (PR #12615)
2026-04-02 15:54:29 +00:00

2.0 KiB

CoPilot Bot

Multi-platform bot service for AutoGPT CoPilot, built with Vercel Chat SDK.

Deploys CoPilot to Discord, Telegram, Slack, and more from a single codebase.

How it works

  1. User messages the bot on any platform (Discord, Telegram, Slack)
  2. Bot checks if the platform user is linked to an AutoGPT account
  3. If not linked → sends a one-time link URL
  4. User clicks → logs in to AutoGPT → accounts are linked
  5. Future messages are forwarded to CoPilot and responses streamed back

Setup

# Install dependencies
npm install

# Copy env template
cp .env.example .env

# Configure at least one platform adapter (e.g. Discord)
# Edit .env with your bot tokens

# Run in development
npm run dev

Architecture

src/
├── index.ts           # Standalone entry point
├── config.ts          # Environment-based configuration
├── bot.ts             # Core bot logic (Chat SDK handlers)
├── platform-api.ts    # AutoGPT platform API client
└── api/               # Serverless API routes (Vercel)
    ├── _bot.ts        # Singleton bot instance
    ├── webhooks/      # Platform webhook endpoints
    │   ├── discord.ts
    │   ├── telegram.ts
    │   └── slack.ts
    └── gateway/
        └── discord.ts # Gateway cron for Discord messages

Deployment

Standalone (Docker/PM2)

npm run build
npm start

Serverless (Vercel)

Deploy to Vercel. Webhook URLs:

  • Discord: https://your-app.vercel.app/api/webhooks/discord
  • Telegram: https://your-app.vercel.app/api/webhooks/telegram
  • Slack: https://your-app.vercel.app/api/webhooks/slack

For Discord messages (Gateway), add a cron job in vercel.json:

{
  "crons": [{ "path": "/api/gateway/discord", "schedule": "*/9 * * * *" }]
}

Dependencies

  • Chat SDK — Cross-platform bot abstraction
  • AutoGPT Platform API — Account linking + CoPilot chat