Skip to content

Chat SDK

Build chatbots that work across Instagram, Facebook, Telegram, WhatsApp, Twitter/X, Bluesky, and Reddit through a single Chat SDK adapter.

Chat SDK is Vercel's unified TypeScript framework for building chatbots across messaging platforms. The @zernio/chat-sdk-adapter is the vendor official Zernio adapter, listed on chat-sdk.dev, letting you build a single chatbot that works across all Zernio-supported messaging platforms.

Why use this?

Even if Chat SDK shipped native adapters for every social platform, you'd still need to apply to Meta's developer program, go through App Review, get WhatsApp Business verification, apply for X elevated API access, register a Reddit OAuth app, and set up a Telegram bot. That's 6+ developer programs, review processes, OAuth app configurations, and ongoing token refresh management.

Zernio handles all of that. Your users connect their accounts through OAuth in the Zernio dashboard, and you get a single API key. No developer program applications, no app reviews, no token management.

Without ZernioWith Zernio
Apply to 6+ developer programsConnect accounts in a dashboard
Go through platform App ReviewsNo reviews needed
Build 7 OAuth app configurations1 API key
Manage token refresh per platformZernio handles token lifecycle
7 webhook endpoints to maintain1 webhook endpoint
Platform-specific error handlingUnified error responses

Setup

Install the adapter

bash
npm install @zernio/chat-sdk-adapter chat @chat-adapter/state-memory

For production, swap @chat-adapter/state-memory for a persistent state adapter like @chat-adapter/state-redis or @chat-adapter/state-pg. See State Adapters for all options.

Configure environment variables

bash
# Required: your Zernio API key (read-write)
ZERNIO_API_KEY=your_api_key

# Recommended: webhook secret for signature verification
ZERNIO_WEBHOOK_SECRET=your_webhook_secret

Get your API key from zernio.com/dashboard/api-keys. Make sure the key has read-write permissions.

Create your bot

typescript
import { Chat } from "chat";
import { createZernioAdapter } from "@zernio/chat-sdk-adapter";
import { createMemoryState } from "@chat-adapter/state-memory";

export const bot = new Chat({
  userName: "pizza-bot",
  adapters: {
    zernio: createZernioAdapter(),
  },
  state: createMemoryState(),
});

// Register a handler for incoming messages (use /.*/ to match every message)
bot.onNewMessage(/.*/, async (thread, message) => {
  const platform = (message.raw as any).platform;
  await thread.post(`Hello from ${platform}!`);
});

Add a webhook route

typescript
import { bot } from "@/lib/bot";

export async function POST(request: Request) {
  return bot.webhooks.zernio(request);
}
typescript
import express from "express";
import { bot } from "./lib/bot";

const app = express();

app.post("/api/chat-webhook", async (req, res) => {
  const response = await bot.webhooks.zernio(req);
  res.status(response.status).send(await response.text());
});

Configure your Zernio webhook

In the Zernio dashboard, create a webhook:

  • URL: https://your-app.com/api/chat-webhook
  • Events: Select message.received and comment.received
  • Secret: Set a strong secret (same as ZERNIO_WEBHOOK_SECRET)

Configuration

The adapter auto-detects credentials from environment variables. You can also pass them explicitly:

typescript
const adapter = createZernioAdapter({
  apiKey: "your-api-key",
  webhookSecret: "your-webhook-secret",
  baseUrl: "https://zernio.com/api",  // default
  botName: "My Bot",                   // default: "Zernio Bot"
});
Env VariableConfig KeyRequiredDescription
ZERNIO_API_KEYapiKeyYesAPI key for sending messages
ZERNIO_WEBHOOK_SECRETwebhookSecretRecommendedHMAC-SHA256 secret for webhook verification
ZERNIO_API_BASE_URLbaseUrlNoOverride API base URL
ZERNIO_BOT_NAMEbotNameNoBot display name

Accessing platform data

Every message includes the raw Zernio payload, so you can access platform-specific data:

typescript
bot.onNewMessage(/.*/, async (thread, message) => {
  const raw = message.raw as any;

  // Which platform sent this message
  console.log(raw.platform); // "instagram" | "facebook" | "telegram" | ...

  // Instagram-specific sender info
  if (raw.sender.instagramProfile) {
    console.log(raw.sender.instagramProfile.followerCount);
    console.log(raw.sender.instagramProfile.isVerified);
  }

  // WhatsApp phone number
  if (raw.sender.phoneNumber) {
    console.log(raw.sender.phoneNumber);
  }

  // Attachments (images, videos, etc.)
  for (const att of raw.attachments) {
    console.log(att.type, att.url);
  }
});

Supported features

FeatureSupportedNotes
Send messagesYesText across all platforms
Rich messages (cards)YesButtons and templates on FB, IG, Telegram, WhatsApp
Edit messagesPartialTelegram only
Delete messagesPartialTelegram, X (full); Bluesky, Reddit (self-only)
ReactionsPartialTelegram and WhatsApp
Typing indicatorsPartialFacebook Messenger and Telegram
AI streamingPartialPost+edit on Telegram; single post on others
File attachmentsYesVia media upload endpoint
Fetch messagesYesFull conversation history
Fetch thread infoYesParticipant details, platform, status
Webhook verificationYesHMAC-SHA256
Comment webhooksYescomment.received routed through handlers

API client

The adapter exports a standalone API client for direct Zernio API calls beyond what Chat SDK covers:

typescript
import { ZernioApiClient } from "@zernio/chat-sdk-adapter";

const client = new ZernioApiClient("your-api-key", "https://zernio.com/api");

// List conversations
const { data, pagination } = await client.listConversations({
  platform: "instagram",
  status: "active",
  limit: 20,
});

// Send a message with an attachment
await client.sendMessage(conversationId, {
  accountId: "acc-123",
  message: "Check this out!",
  attachmentUrl: "https://example.com/image.jpg",
  attachmentType: "image",
});

Prerequisites

  • A Zernio API key with read-write permissions
  • At least one connected social account
  • Inbox features available on your Zernio account (included with the Usage plan; AppSumo users need the Inbox add-on)
  • Node.js 20+ (for native fetch and crypto support)

Inbox features (including message.received webhooks) are bundled with every paid account on the Usage plan. AppSumo users need the Inbox add-on; contact support if you need to enable it.

Resources

  • GitHub repository
  • npm package
  • Chat SDK documentation
  • Zernio Webhook API
  • Zernio Inbox API