Twitch

Twitch chat integration via IRC with role-based access control, mention gating, automatic token refresh, and multi-channel support.

Twitch is the dominant live-streaming platform with over 140 million monthly active users, and OpenClaw's Twitch integration brings AI agent capabilities into stream chat. Built on Twitch's IRC protocol, the plugin connects as a Twitch user (bot account) to receive and send messages in channel chat rooms, with role-based access control, user ID allowlists, automatic token refresh, and multi-channel support. The integration is group-chat only — Twitch doesn't support bot DMs through IRC. The bot joins a specified channel's chat and responds when @mentioned (requireMention defaults to true). Access control is critical: without allowFrom or allowedRoles, any viewer could trigger your AI agent. Available roles include moderator, VIP, subscriber, and owner, with user ID allowlists providing the most secure option since Twitch usernames can be changed. Tokens are the main operational consideration. Quick-start tokens from Twitch Token Generator work immediately but expire after several hours and can't be auto-refreshed. For production use, registering a Twitch application at the Developer Console provides client secret and refresh token support for automatic renewal. The plugin handles token refresh transparently, logging refresh events for monitoring. Messages are automatically chunked at 500 characters to comply with Twitch chat limits. Multi-account support lets a single OpenClaw instance join multiple channels with separate tokens and access control per channel. For streamers who want an AI co-host, moderators who need an intelligent chat assistant, or communities that want an always-on knowledge bot in their channel, the Twitch integration turns stream chat into an interactive AI experience.

Tags: streaming, gaming, twitch, live

Category: Streaming

Use Cases

  • AI co-host for live streams that interacts with chat
  • Mod-only AI assistant for stream management and lookups
  • Community knowledge bot in a Twitch channel
  • Interactive AI character for entertainment streams
  • Q&A bot for educational or tutorial streams
  • VIP-only AI concierge for subscriber engagement

Tips

  • Always set allowFrom with your user ID for security — open access in a Twitch channel is dangerous
  • Register a Twitch app at dev.twitch.tv/console for automatic token refresh in production
  • Use allowedRoles: ['moderator'] to let your mod team interact with the AI bot
  • Keep requireMention: true in busy channels to prevent the bot from responding to every message
  • Use multi-account to run the same bot in multiple channels with separate access control
  • Monitor gateway logs for token refresh events — failed refreshes mean the bot will go silent
  • Set up a dedicated Twitch account for the bot to keep it separate from your personal account
  • Use env var OPENCLAW_TWITCH_ACCESS_TOKEN for the default account to keep tokens out of config files

Known Issues & Gotchas

  • requireMention defaults to true — the bot only responds when @mentioned unless you disable it
  • Quick-start tokens from Twitch Token Generator expire after ~4 hours and cannot be auto-refreshed
  • For auto token refresh, you MUST register a Twitch application and provide clientSecret + refreshToken
  • Twitch usernames can be changed — always use numeric user IDs in allowFrom, never usernames
  • Without allowFrom or allowedRoles, ANY viewer can trigger the bot and burn your API tokens
  • Messages over 500 characters are auto-chunked — long AI responses may appear as multiple messages
  • Rate limits apply: non-mod bots can send 20 messages per 30 seconds (mods get 100/30s)
  • The bot account must have chat:read AND chat:write scopes — missing either will cause silent failures

Alternatives

  • Discord
  • IRC
  • Telegram
  • YouTube Live Chat

Community Feedback

Running OpenClaw as a Twitch chat bot is surprisingly smooth. The role-based access control means I can lock it down to mods-only or VIPs. Way more capable than typical Twitch bots since it has full LLM backing.

— Reddit r/Twitch

Set up OpenClaw on my stream as an AI co-host. The token refresh was annoying until I registered a proper Twitch app. Now it just works. Chat loves interacting with it.

— Reddit r/selfhosted

Twitch plugin is minimal but that's kind of the point — Twitch chat is text-only anyway. The user ID allowlist is essential. Without it, random viewers will spam your AI and burn tokens.

— GitHub Discussions

Frequently Asked Questions

Is the Twitch plugin bundled with OpenClaw?

No. Twitch is a separate plugin: openclaw plugins install @openclaw/twitch. It's not included in the core OpenClaw package.

Why do tokens from Twitch Token Generator expire?

Quick-start tokens from twitchtokengenerator.com are short-lived OAuth tokens that can't be refreshed. For persistent operation, register your own Twitch application at dev.twitch.tv/console to get a client secret and refresh token for automatic renewal.

Can the bot send DMs on Twitch?

No. Twitch's IRC protocol only supports channel (group) chat. The bot can only send and receive messages in the channel it's joined. For DM-capable alternatives, use Discord or Telegram.

How do I find my Twitch user ID?

Use the converter tool at streamweasels.com/tools/convert-twitch-username-to-user-id/ — enter your username and it returns the permanent numeric ID. Always use IDs instead of usernames in allowFrom since usernames can be changed.

Will the bot respond to every message in chat?

Not by default. requireMention is true by default, so the bot only responds when @mentioned. Set requireMention: false to respond to all messages, but combine this with strict allowFrom or allowedRoles to prevent token burn from random viewers.

What about Twitch's rate limits?

Non-moderator bots are limited to 20 messages per 30 seconds. Moderator accounts get 100 per 30 seconds. OpenClaw handles chunking automatically (500 char limit), but long responses split into multiple messages count against the rate limit.

Can I use the bot in multiple Twitch channels?

Yes. Use the accounts section under channels.twitch to configure multiple channel connections. Each account needs its own token (one token per channel connection).

Configuration Examples

Basic single-channel setup

channels:
  twitch:
    enabled: true
    username: "mybot"
    accessToken: "oauth:abc123..."
    clientId: "xyz789..."
    channel: "mychannel"
    allowFrom:
      - "123456789"

Role-based access with auto-refresh

channels:
  twitch:
    enabled: true
    username: "mybot"
    accessToken: "oauth:abc123..."
    clientId: "xyz789..."
    clientSecret: "your_client_secret"
    refreshToken: "your_refresh_token"
    channel: "mychannel"
    allowedRoles:
      - moderator
      - vip
    requireMention: true

Multi-channel setup

channels:
  twitch:
    accounts:
      main:
        username: "mybot"
        accessToken: "oauth:abc123..."
        clientId: "xyz789..."
        channel: "channel1"
        allowFrom:
          - "123456789"
      second:
        username: "mybot"
        accessToken: "oauth:def456..."
        clientId: "uvw012..."
        channel: "channel2"
        allowedRoles:
          - moderator

Installation

openclaw plugins install @openclaw/twitch