package
Twitch adapter for Chat SDK: read and reply in Twitch channel chat with EventSub webhooks and the Helix Chat API, plus whispers
npm install @chat-adapter/twitchGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
npm package:
@chat-adapter/twitch
Twitch adapter for Chat SDK, using EventSub webhooks and the Twitch API. Read and reply in channel chat as a bot account, delete messages as a moderator, and send and receive whispers.
Documentation: chat-sdk.dev/adapters/official/twitch · Guides: vercel.com/kb/chat-sdk
pnpm add @chat-adapter/twitchTo scaffold a new Twitch bot with this adapter preselected:
npx create-chat-sdk@latest my-bot --adapter twitch memoryVisit the adapters directory to see other available official and vendor-official adapters.
import { Chat } from "chat";
import { createTwitchAdapter } from "@chat-adapter/twitch";
const bot = new Chat({
userName: "mybot",
adapters: {
twitch: createTwitchAdapter(),
},
});
bot.onNewMention(async (thread, message) => {
await thread.reply(message, `Hi @${message.author.userName}!`);
});
bot.onDirectMessage(async (thread) => {
await thread.post
When you call createTwitchAdapter() without arguments, it reads credentials from environment variables:
| Variable | Required | Description |
|---|---|---|
TWITCH_CLIENT_ID | Yes | Twitch application client ID |
TWITCH_CLIENT_SECRET | Yes | Twitch application client secret |
TWITCH_WEBHOOK_SECRET | Yes | EventSub webhook secret, 10 to 100 characters |
TWITCH_BOT_USERNAME | Yes, unless TWITCH_BOT_USER_ID is set | Bot account login |
TWITCH_BOT_USER_ID | No | Bot account user ID. Looked up from the login when unset. Set it with TWITCH_BOT_USERNAME to skip the Get Users call on startup |
TWITCH_USER_ACCESS_TOKEN | For whispers, unless TWITCH_REFRESH_TOKEN is set | Bot user access token with user:manage:whispers |
http://localhost:3000, which the Twitch CLI uses in the next step, and choose the Confidential client type.user:read:chat, user:write:chat, and user:bot. Add moderator:manage:chat_messages to delete messages and user:manage:whispers for whispers. The Twitch CLI can run this flow: twitch token --user-token --scopes "user:read:chat user:write:chat user:bot".channel:bot, or make the bot a moderator.bot.webhooks.twitch(request), then create the EventSub subscriptions once:await bot.initialize();
const twitch = bot.getAdapter("twitch");
await twitch.subscribeToChat("<broadcaster user ID>", "https://your-domain.com/api/webhooks/twitch");
await twitch.subscribeToWhispers("https://your-domain.com/api/webhooks/twitch");Chat uses an app access token that the adapter mints and refreshes with the client credentials grant. Only whispers need a user access token.
twitch:{broadcasterUserId}. Whispers use twitch:whisper:{userId}.@mention of the bot or a reply to one of its messages counts as a mention. The bot's own messages are ignored.thread.reply(message, ...) sends a Twitch reply with reply_parent_message_id. On incoming replies, message.replyTo holds the text and author of the message being replied to.·, and messages over 500 characters are cut at a word boundary.concurrency: "queue" or "concurrent" on Chat so messages that arrive during a slow reply aren't dropped.persistThreadHistory).If you use an AI coding agent such as OpenAI Codex, Claude Code, or Cursor, install the Chat SDK skill so it knows the SDK APIs, adapter patterns, and project conventions before writing code.
npx skills add vercel/chatThe skill references bundled documentation in node_modules/chat/docs, plus adapter guides and starter templates in the published package.
You can also install the Vercel Plugin for a broader agent toolkit: it includes the Chat SDK skill alongside specialist agents, agent slash commands, and more:
npx plugins add vercel/vercel-pluginThe plugin is optional; the skill alone is enough to build with Chat SDK.
For agent-readable documentation, see chat-sdk.dev/llms.txt (page index) or chat-sdk.dev/llms-full.txt (full text).
MIT
vercel-release-bot
infra+release@vercel.com
TWITCH_REFRESH_TOKEN |
| No |
| Bot refresh token for managed whisper token refresh |
TWITCH_ENCRYPTION_KEY | No | Base64 32-byte key used to encrypt the tokens stored in the state adapter |
Estimated unpacked size across 24 packages.
2.5 MB
Includes dependencies.