← Back to Architecture Patterns
Architecture Pattern

💬 Cross-Platform Chat Agent

Chat SDK delivers one AI agent across Slack, Teams, Discord, WhatsApp, Telegram, GitHub, and Linear. Single codebase, single deployment, with platform-specific rendering handled by adapters.

The Problem

Companies want AI assistants available everywhere — website, Slack, Teams, Discord, mobile. Without a unified approach, you build and maintain separate integrations for each platform:

  • Separate codebases per platform (7 platforms = 7 repos)
  • Different message formats, APIs, authentication flows
  • Agent logic duplicated and eventually drifts out of sync
  • Testing and deploying 7 separate services

The Chat SDK Solution

🔄 One Agent, All Platforms

Define your agent's capabilities once — tools, system prompt, model config. Chat SDK handles platform-specific message formatting, input parsing, and response rendering.

🔌 Platform Adapters

Each platform (Slack, Teams, Discord, etc.) has an adapter that translates between the platform's API and Chat SDK's unified interface. Add a new platform by adding one adapter.

💾 Unified Conversation State

Conversation history stored in Postgres/Redis. Platform-specific metadata (Slack thread_ts, Teams conversation id) handled transparently.

Rich Responses

Agent returns structured responses (text, buttons, forms, images). Each adapter renders these in the platform's native format — Slack blocks, Teams cards, Discord embeds.

Supported Platforms

Slack
Blocks API, slash commands, thread replies
Microsoft Teams
Adaptive Cards, bot framework, tab apps
Discord
Embeds, slash commands, buttons, modals
WhatsApp
Business API, templates, media messages
Telegram
Bot API, inline keyboards, rich messages
GitHub
Issues, PRs, discussions, slash commands
Linear
Issue management, automation, project context
Web (Next.js)
useChat() hook, streaming UI, rich components

Architecture

Webhook Receivers

Each platform sends messages to /api/webhook/{platform}. Route handlers parse platform-specific payloads into a unified Message format.

Chat SDK Core

Unified agent logic: system prompt, tools, model selection (via AI SDK), conversation management. Platform-agnostic.

AI SDK + AI Gateway

Model calls via AI SDK with AI Gateway for routing, failover, and cost tracking. streamText() for real-time responses.

Platform Adapters (Output)

Structured agent responses → platform-native format. Text becomes Slack blocks, Teams adaptive cards, Discord embeds.

State Store

Postgres for conversation history, user preferences. Redis for rate limiting and session cache.

🎯 SE Interview Takeaway

Chat SDK embodies the composable architecture principle: one core agent deployed on Vercel, with adapters for each platform. When a customer says "we need our AI assistant in Slack AND on our website AND in Teams," the answer is one Next.js app with Chat SDK — not three separate projects. This is a powerful sales conversation: one deployment, one billing, one codebase, all platforms.