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, 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 Zernio | With Zernio |
|---|---|
| Apply to 6+ developer programs | Connect accounts in a dashboard |
| Go through platform App Reviews | No reviews needed |
| Build 7 OAuth app configurations | 1 API key |
| Manage token refresh per platform | Zernio handles token lifecycle |
| 7 webhook endpoints to maintain | 1 webhook endpoint |
| Platform-specific error handling | Unified error responses |
Setup
Install the adapter
npm install @zernio/chat-sdk-adapter chatConfigure environment variables
# Required: your Zernio API key (read-write)
ZERNIO_API_KEY=your_api_key
# Recommended: webhook secret for signature verification
ZERNIO_WEBHOOK_SECRET=your_webhook_secretGet your API key from zernio.com/dashboard/api-keys. Make sure the key has read-write permissions.
Create your bot
import { Chat } from "chat";
import { createZernioAdapter } from "@zernio/chat-sdk-adapter";
export const bot = new Chat({
adapters: {
zernio: createZernioAdapter(),
},
onNewMessage: async ({ thread, message }) => {
const platform = message.raw.platform;
await thread.post(`Hello from ${platform}!`);
},
});Add a webhook route
import { bot } from "@/lib/bot";
export async function POST(request: Request) {
return bot.webhooks.zernio(request);
}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.receivedandcomment.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:
const adapter = createZernioAdapter({
apiKey: "your-api-key",
webhookSecret: "your-webhook-secret",
baseUrl: "https://zernio.com/api", // default
botName: "My Bot", // default: "Zernio Bot"
});| Env Variable | Config Key | Required | Description |
|---|---|---|---|
ZERNIO_API_KEY | apiKey | Yes | API key for sending messages |
ZERNIO_WEBHOOK_SECRET | webhookSecret | Recommended | HMAC-SHA256 secret for webhook verification |
ZERNIO_API_BASE_URL | baseUrl | No | Override API base URL |
ZERNIO_BOT_NAME | botName | No | Bot display name |
Accessing platform data
Every message includes the raw Zernio payload, so you can access platform-specific data:
onNewMessage: async ({ message }) => {
const raw = message.raw;
// 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
| Feature | Supported | Notes |
|---|---|---|
| Send messages | Yes | Text across all platforms |
| Rich messages (cards) | Yes | Buttons and templates on FB, IG, Telegram, WhatsApp |
| Edit messages | Partial | Telegram only |
| Delete messages | Partial | Telegram, X (full); Bluesky, Reddit (self-only) |
| Reactions | Partial | Telegram and WhatsApp |
| Typing indicators | Partial | Facebook Messenger and Telegram |
| AI streaming | Partial | Post+edit on Telegram; single post on others |
| File attachments | Yes | Via media upload endpoint |
| Fetch messages | Yes | Full conversation history |
| Fetch thread info | Yes | Participant details, platform, status |
| Webhook verification | Yes | HMAC-SHA256 |
| Comment webhooks | Yes | comment.received routed through handlers |
API client
The adapter exports a standalone API client for direct Zernio API calls beyond what Chat SDK covers:
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
- The inbox addon enabled on your Zernio account
- Node.js 18+ (for native
fetchandcryptosupport)
The inbox addon is required to receive message.received webhook events. Contact support if you need to enable it.
Resources
Integrations
Automate social media posting via n8n, Make.com, Zapier, or OpenClaw. Schedule and cross-post to Twitter, Instagram, LinkedIn, TikTok & 10 more.
n8n
Verified n8n node for social media automation. Post to Twitter, Instagram, LinkedIn, TikTok & more with scheduling, media uploads, webhooks, and cross-posting.