11 KiB
| summary | read_when | ||
|---|---|---|---|
| Twitch chat bot support status, capabilities, and configuration |
|
Twitch (plugin)
Twitch chat support via IRC connection. Clawdbot connects as a Twitch user (bot account) to receive and send messages in channels.
Status: ready for Twitch chat via IRC connection with @twurple.
Plugin required
Twitch ships as a plugin and is not bundled with the core install.
Install via CLI (npm registry):
clawdbot plugins install @clawdbot/twitch
Local checkout (when running from a git repo):
clawdbot plugins install ./extensions/twitch
Details: Plugins
Setup
- Install the Twitch plugin and create a dedicated Twitch account for the bot.
- Generate your credentials (recommended: use Twitch Token Generator):
- Select Bot Token
- Verify scopes
chat:readandchat:writeare selected - Copy the Client ID and Access Token
- Configure credentials:
- Env:
CLAWDBOT_TWITCH_ACCESS_TOKEN=...(default account only) - Or config:
channels.twitch.accounts.default.accessToken - If both are set, config takes precedence (env fallback is default-account only).
- Env:
- Start the gateway.
- The bot joins your channel and responds to messages.
⚠️ Important: Strongly recommended to add requireMention and access control (allowFrom or allowedRoles) to prevent the bot from replying to all chat messages.
Minimal config:
{
channels: {
twitch: {
enabled: true,
username: "clawdbot", // Bot's Twitch account
accessToken: "oauth:abc123...", // OAuth Access Token (or use CLAWDBOT_TWITCH_ACCESS_TOKEN env var)
clientId: "your_client_id", // Client ID from Token Generator
channel: "vevisk", // Which Twitch channel's chat to join
requireMention: true, // (recommended) Only reply when mentioned
allowFrom: ["123456789"] // (recommended) Your Twitch user ID only (Convert your twitch username to ID at https://www.streamweasels.com/tools/convert-twitch-username-%20to-user-id/)
}
}
}
Recommended access control options:
requireMention: true- Only respond when the bot is mentioned with@botnameallowFrom: ["your_user_id"]- Restrict to your Twitch user ID onlyallowedRoles: ["moderator", "vip", "subscriber"]- Restrict to specific roles
Note: Twitch Token Generator provides the Client ID and Access Token (select Bot Token and verify chat:read + chat:write scopes) - no manual app registration needed.
Note: username is the bot's account, channel is which chat to join.
How it works
- Create a bot account (or use an existing Twitch account).
- Generate credentials using Twitch Token Generator (provides Client ID, Access Token, and optionally Refresh Token).
- Configure Clawdbot with the credentials.
- Run the gateway; it auto-starts the Twitch channel when a token is available (config first, env fallback) and
channels.twitch.enabledis notfalse. - The bot joins the specified
channelto send/receive messages. - Each account maps to an isolated session key
agent:<agentId>:twitch:<accountName>.
Key distinction: username is who the bot authenticates as (the bot's account), channel is which chat room it joins.
Token refresh (optional)
Tokens from Twitch Token Generator cannot be automatically refreshed - you'll need to generate a new token when it expires (typically after several hours).
For automatic token refresh, create your own Twitch application at Twitch Developer Console and add clientSecret and refreshToken to your config. The bot automatically refreshes tokens before they expire and logs refresh events.
Routing model
- Replies always go back to Twitch.
- Each account maps to
agent:<agentId>:twitch:<accountName>.
Multi-account support
Use channels.twitch.accounts with per-account tokens. See gateway/configuration for the shared pattern.
Example (one bot account in two different channels):
{
channels: {
twitch: {
accounts: {
ninjaChannel: {
username: "clawdbot",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "vevisk"
},
shroudChannel: {
username: "clawdbot",
accessToken: "oauth:def456...",
clientId: "uvw012...",
channel: "secondchannel"
}
}
}
}
}
Access control
Role-based restrictions
{
channels: {
twitch: {
accounts: {
default: {
username: "mybot",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "your_channel",
allowedRoles: ["moderator", "vip"]
}
}
}
}
}
Available roles: "moderator", "owner", "vip", "subscriber", "all".
Allowlist by User ID
Only allow specific Twitch user IDs (most secure):
{
channels: {
twitch: {
accounts: {
default: {
username: "mybot",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "your_channel",
allowFrom: ["123456789", "987654321"]
}
}
}
}
}
Why user IDs instead of usernames? Twitch usernames can change, which could allow someone to hijack another user's access. User IDs are permanent.
Find your Twitch user ID at: https://www.streamweasels.com/tools/convert-twitch-username-%20to-user-id/
Combined allowlist + roles
Users in allowFrom bypass role checks. Example:
- User
123456789can always message (bypasses role check) - All moderators can message
- Everyone else is blocked
{
channels: {
twitch: {
accounts: {
default: {
username: "mybot",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "your_channel",
allowFrom: ["123456789"],
allowedRoles: ["moderator"]
}
}
}
}
}
Require @mention
Only respond when the bot is mentioned:
{
channels: {
twitch: {
accounts: {
default: {
username: "mybot",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "your_channel",
requireMention: true
}
}
}
}
}
Capabilities & limits
Supported:
- ✅ Channel messages (group chat)
- ✅ Whispers/DMs (received but replies not supported - Twitch doesn't allow bots to send whispers)
- ✅ Markdown stripping (automatically applied)
- ✅ Message chunking (500 char limit)
- ✅ Access control (user ID allowlist, role-based)
- ✅ @mention requirement
- ✅ Automatic token refresh (with RefreshingAuthProvider)
- ✅ Multi-account support
Not supported:
- ❌ Native reactions
- ❌ Threaded replies
- ❌ Message editing
- ❌ Message deletion
- ❌ Rich embeds/media uploads (sends media URLs as text)
Troubleshooting
First, run diagnostic commands:
clawdbot doctor
clawdbot channels status --probe
Bot doesn't respond to messages
Check access control: Temporarily set allowedRoles: ["all"] to test.
Check the bot is in the channel: The bot must join the channel specified in channel.
Token issues
"Failed to connect" or authentication errors:
- Verify
accessTokenis the OAuth access token value (typically starts withoauth:prefix) - Check token has
chat:readandchat:writescopes - If using RefreshingAuthProvider, verify
clientSecretandrefreshTokenare set
Token refresh not working
Check logs for refresh events:
Using env token source for mybot
Access token refreshed for user 123456 (expires in 14400s)
If you see "token refresh disabled (no refresh token)":
- Ensure
clientSecretis provided - Ensure
refreshTokenis provided
Config
{
channels: {
twitch: {
enabled: true,
username: "clawdbot",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "vevisk",
clientSecret: "secret123...",
refreshToken: "refresh456...",
requireMention: true,
allowFrom: ["123456789"],
allowedRoles: ["moderator", "vip"],
accounts: {
default: {
username: "mybot",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "your_channel",
enabled: true,
clientSecret: "secret123...",
refreshToken: "refresh456...",
expiresIn: 14400,
obtainmentTimestamp: 1706092800000,
allowFrom: ["123456789", "987654321"],
allowedRoles: ["moderator"],
requireMention: true
}
}
}
},
plugins: {
entries: {
twitch: {
stripMarkdown: true
}
}
}
}
Account config:
username- Bot usernameaccessToken- OAuth access token withchat:readandchat:writeclientId- Twitch Client ID (from Token Generator or your app)channel- Channel to joinenabled- Enable this account (default:true)clientSecret- Optional: For automatic token refresh (from YOUR Twitch app)refreshToken- Optional: For automatic token refresh (from YOUR Twitch app)expiresIn- Token expiry in secondsobtainmentTimestamp- Token obtained timestampallowFrom- User ID allowlistallowedRoles- Role-based access control ("moderator" | "owner" | "vip" | "subscriber" | "all")requireMention- Require @mention (default:false)
Plugin config:
stripMarkdown- Strip markdown from outbound (default:true)
Provider options:
channels.twitch.enabled- Enable/disable channel startupchannels.twitch.username- Bot username (simplified single-account config)channels.twitch.accessToken- OAuth access token (simplified single-account config)channels.twitch.clientId- Twitch Client ID (simplified single-account config)channels.twitch.channel- Channel to join (simplified single-account config)channels.twitch.accounts.<accountName>- Multi-account config (all account fields above)
Tool actions
The agent can call twitch with action:
send- Send a message to a channel
Example:
{
"action": "twitch",
"params": {
"message": "Hello Twitch!",
"to": "#mychannel"
}
}
Safety & ops
- Treat tokens like passwords - Never commit tokens to git
- Use RefreshingAuthProvider for long-running bots
- Use user ID allowlists instead of usernames for access control
- Monitor logs for token refresh events and connection status
- Scope tokens minimally - Only request
chat:readandchat:write - If stuck: Restart the gateway after confirming no other process owns the session
Message limits
- 500 characters per message (Twitch limit)
- Messages are automatically chunked at word boundaries
- Markdown is stripped before chunking to avoid breaking patterns
- No rate limiting (uses Twitch's built-in rate limits)