Twitch
Configuración e instalación de bot de chat Twitch (IRC).
Soporta chat Twitch vía conexión IRC. OpenClaw se conecta a canales como un usuario de Twitch (cuenta bot) para recibir y enviar mensajes.
Instalación de Plugin Requerida
Twitch se proporciona como plugin y no viene incluido con la instalación core.
Instala vía CLI (registro npm):
openclaw plugins install @openclaw/twitch
Instalación local (cuando ejecutas desde repositorio git):
openclaw plugins install ./extensions/twitch
Detalles: ''/plugin''
Configuración Rápida para Principiantes
1. Crea una cuenta de Twitch dedicada para el bot (o usa una cuenta existente).
2. Genera credenciales: ''Twitch Token Generator''
- Selecciona Bot Token
- Confirma que los scopes incluyan ''chat:read'' y ''chat:write''
- Copia Client ID y Access Token
3. Encuentra tu ID de usuario de Twitch:
https://www.streamweasels.com/tools/convert-twitch-username-to-user-id/
4. Configura el token:
- Env: ''OPENCLAW_TWITCH_ACCESS_TOKEN=...'' (solo cuenta predeterminada)
- O config: ''channels.twitch.accessToken''
- Cuando ambos están establecidos, config tiene prioridad (env sirve como fallback de cuenta predeterminada).
5. Inicia el gateway.
''Importante:'' Por favor configura control de acceso (''allowFrom'' o ''allowedRoles'') para prevenir usuarios no autorizados de disparar el bot. ''requireMention'' por defecto es ''true''.
Configuración mínima:
{
channels: {
twitch: {
enabled: true,
username: "openclaw",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "vevisk",
allowFrom: ["123456789"],
},
},
}Qué es esto
- Un canal de Twitch gestionado por Gateway.
- Enrutamiento determinístico: las respuestas siempre van de vuelta a Twitch.
- Cada cuenta mapea a una clave de sesión aislada: ''agent:<agentId>:twitch:<accountName>''.
- ''username'' es la cuenta del bot (para auth), ''channel'' es la sala de chat a unir (requerido).
Configuración (detallada)
#
Generate credentials
Use ''Twitch Token Generator'':
- Select Bot Token
- Confirm scopes: ''chat:read'' and ''chat:write''
- Copy Client ID and Access Token
Este método no requiere registro manual de app, pero los tokens pueden expirar después de algunas horas.
#
Configure bot
Env (default account only):
OPENCLAW_TWITCH_ACCESS_TOKEN=oauth:abc123...
Or config:
{
channels: {
twitch: {
enabled: true,
username: "openclaw",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "vevisk",
},
},
}Cuando tanto env como config existen, config tiene prioridad.
#
Access control (recommended)
{
channels: {
twitch: {
allowFrom: ["123456789"]
},
},
}''allowFrom'' is a hard allowlist (most secure). If you want to control access by role, don't set ''allowFrom'', use ''allowedRoles'' instead.
''Available roles:'' ''"moderator"'', ''"owner"'', ''"vip"'', ''"subscriber"'', ''"all"''.
Why use user ID? Usernames can be changed and impersonated; user IDs are permanent.
Find user ID:
https://www.streamweasels.com/tools/convert-twitch-username-%20to-user-id/
Token refresh (optional)
Tokens generated by ''Twitch Token Generator'' cannot be auto-refreshed—you'll need to regenerate them after they expire.
Si quieres refresco automático de tokens, crea tu propia app de Twitch en ''Twitch Developer Console'' y agrégala a la config:
{
channels: {
twitch: {
clientSecret: "your_client_secret",
refreshToken: "your_refresh_token",
},
},
}El bot refrescará automáticamente los tokens antes de que expiren y registrará eventos de refresco.
Multiple accounts
Use ''channels.twitch.accounts'' to configure tokens for each account. See ''/gateway/configuration'' for shared structure.
Example (one bot account joining two channels):
{
channels: {
twitch: {
accounts: {
channel1: {
username: "openclaw",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "vevisk",
},
channel2: {
username: "openclaw",
accessToken: "oauth:def456...",
clientId: "uvw012...",
channel: "secondchannel",
},
},
},
},
}Nota: Cada cuenta necesita su propio token (usualmente un token por canal).
Access control (more examples)
#
Role-based restrictions
{
channels: {
twitch: {
accounts: {
default: {
allowedRoles: ["moderator", "vip"],
},
},
},
},
}#
User ID allowlist (most secure)
{
channels: {
twitch: {
accounts: {
default: {
allowFrom: ["123456789", "987654321"],
},
},
},
},
}#
Role access (alternative)
''allowFrom'' is a hard allowlist; once set, only these user IDs are allowed.
Si quieres permitir por rol, deja ''allowFrom'' vacío y usa ''allowedRoles'':
{
channels: {
twitch: {
accounts: {
default: {
allowedRoles: ["moderator"],
},
},
},
},
}#
Disable @mention requirement
Default ''requireMention=true''. To reply to all messages:
{
channels: {
twitch: {
accounts: {
default: {
requireMention: false,
},
},
},
},
}Troubleshooting
First run diagnostic commands:
openclaw doctor openclaw channels status --probe
#
Bot not responding
- Check access control: confirm your user ID is in ''allowFrom'', or temporarily remove ''allowFrom'' and set ''allowedRoles: ["all"]'' for testing.
- Check if bot has joined the channel specified in ''channel''.
#
Token issues
"Failed to connect" or auth errors:
- Confirm ''accessToken'' is an OAuth access token (usually starts with ''oauth:'')
- Confirm token scopes include ''chat:read'' and ''chat:write''
- If token refresh is enabled, confirm ''clientSecret'' and ''refreshToken'' are set
#
Token refresh not working
Check refresh events in logs:
Using env token source for mybot Access token refreshed for user 123456 (expires in 14400s)
Si ves "token refresh disabled (no refresh token)":
- Confirm ''clientSecret'' is provided
- Confirm ''refreshToken'' is provided
Configuration
Account config fields:
- ''username'': bot username
- ''accessToken'': OAuth access token with ''chat:read''/''chat:write''
- ''clientId'': Twitch Client ID (Token Generator or your app)
- ''channel'': channel to join (required)
- ''enabled'': whether to enable this account (default ''true'')
- ''clientSecret'': optional, for auto token refresh
- ''refreshToken'': optional, for auto token refresh
- ''expiresIn'': expiration seconds
- ''obtainmentTimestamp'': token acquisition timestamp
- ''allowFrom'': user ID allowlist
- ''allowedRoles'': role-based access control (''"moderator" | "owner" | "vip" | "subscriber" | "all"'')
- ''requireMention'': whether @mention is required (default ''true'')
Provider config fields:
- ''channels.twitch.enabled''
- ''channels.twitch.username'' (single account simplified config)
- ''channels.twitch.accessToken'' (single account simplified config)
- ''channels.twitch.clientId'' (single account simplified config)
- ''channels.twitch.channel'' (single account simplified config)
- ''channels.twitch.accounts.<accountName>'' (multi-account config)
Full example:
{
channels: {
twitch: {
enabled: true,
username: "openclaw",
accessToken: "oauth:abc123...",
clientId: "xyz789...",
channel: "vevisk",
clientSecret: "secret123...",
refreshToken: "refresh456...",
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"],
},
},
},
},
}Tool actions
Agent can call ''twitch'' actions:
- ''send'': send message to channel
Example:
{
action: "twitch",
params: {
message: "Hello Twitch!",
to: "#mychannel",
},
}Security & operations
- Treat tokens as passwords: don't commit to git
- Enable auto token refresh for long-term operation
- Use user ID allowlist for access control (not username)
- Monitor logs for refresh and connection status
- Request minimal scopes: ''chat:read'' and ''chat:write''
- If stuck: confirm no other process is using the session, then restart gateway
Limitations
- Single message 500 characters (auto-split at word boundaries)
- Markdown removed before splitting
- No additional rate limiting (relies on Twitch's built-in limits)