Twitch (plugin)
Twitch chat은 IRC 연결을 통해 지원됩니다. OpenClaw는 Twitch user(bot account)로 연결되어 channel에서 메시지를 받고 보냅니다.Plugin 필요
Twitch는 plugin으로 제공되며 core install에 번들되어 있지 않습니다. CLI 설치(npm registry):빠른 설정(beginner)
- bot용 전용 Twitch 계정을 만들거나 기존 계정을 사용합니다.
- credential 생성: Twitch Token Generator
- Bot Token 선택
chat:read,chat:writescope가 선택됐는지 확인- Client ID와 Access Token 복사
- Twitch user ID 찾기: https://www.streamweasels.com/tools/convert-twitch-username-to-user-id/
- token 설정:
- Env:
OPENCLAW_TWITCH_ACCESS_TOKEN=...(default account only) - 또는 config:
channels.twitch.accessToken - 둘 다 있으면 config가 우선합니다(env fallback은 default account 전용).
- Env:
- gateway 시작
allowFrom 또는 allowedRoles)을 설정하세요. requireMention 기본값은
true입니다.
최소 구성:
이것이 의미하는 것
- Gateway가 소유하는 Twitch channel integration
- 결정론적 라우팅: reply는 항상 Twitch로 돌아감
- 각 account는 격리된 session key
agent:<agentId>:twitch:<accountName>에 매핑 username은 인증하는 bot account,channel은 join할 chat room
설정(상세)
Credential 생성
Twitch Token Generator 사용:- Bot Token 선택
chat:read,chat:writescope 확인- Client ID와 Access Token 복사
bot 구성
Env var (default account only):접근 제어(권장)
allowFrom을 권장합니다. role 기반 access가
필요하면 대신 allowedRoles를 사용하세요.
가능한 역할: "moderator", "owner", "vip", "subscriber", "all".
왜 user ID인가? username은 바뀔 수 있어 impersonation 위험이 있습니다.
user ID는 영구적입니다.
Twitch user ID 찾기:
https://www.streamweasels.com/tools/convert-twitch-username-%20to-user-id/
Token refresh (선택)
Twitch Token Generator에서 만든 token은 자동 갱신할 수 없습니다. 만료되면 다시 생성하세요. 자동 token refresh가 필요하면 Twitch Developer Console에서 직접 app을 만들고 config에 추가하세요.Multi-account 지원
channels.twitch.accounts를 사용하면 account별 token을 설정할 수 있습니다.
공통 패턴은 gateway/configuration을 참고하세요.
예시(하나의 bot account로 두 channel 참가):
접근 제어
Role-based restriction
User ID allowlist (가장 안전)
Role-based access (대안)
allowFrom은 강한 allowlist입니다. 설정되면 그 user ID만 허용됩니다.
role 기반 access가 필요하면 allowFrom을 비워 두고 allowedRoles만
설정하세요.
@mention 요구 비활성화
기본적으로requireMention은 true입니다. 모든 메시지에 응답하게 하려면:
문제 해결
먼저 진단 명령을 실행하세요.bot이 메시지에 응답하지 않을 때
접근 제어 확인: user ID가allowFrom에 있는지 확인하거나, 테스트를 위해
일시적으로 allowFrom을 제거하고 allowedRoles: ["all"]을 설정하세요.
bot이 channel에 있는지 확인: bot은 channel에 지정된 chat room에 join되어
있어야 합니다.
Token 문제
“Failed to connect” 또는 authentication error:accessToken이 OAuth access token 값인지 확인 (보통oauth:prefix 포함)- token에
chat:read,chat:writescope가 있는지 확인 - token refresh를 쓴다면
clientSecret,refreshToken이 설정됐는지 확인
Token refresh가 동작하지 않을 때
refresh event 로그 확인:clientSecret제공 여부 확인refreshToken제공 여부 확인
Config
Account config:username- Bot usernameaccessToken-chat:read,chat:write를 가진 OAuth access tokenclientId- Twitch Client IDchannel- join할 channel (필수)enabled- account 활성화 (기본true)clientSecret- 선택: 자동 token refreshrefreshToken- 선택: 자동 token refreshexpiresIn- token 만료까지 남은 초obtainmentTimestamp- token 발급 시각allowFrom- user ID allowlistallowedRoles- role 기반 접근 제어 ("moderator" | "owner" | "vip" | "subscriber" | "all")requireMention- @mention 요구 (기본true)
channels.twitch.enabled- 채널 시작 활성화/비활성화channels.twitch.username- Bot username (single-account 간소 구성)channels.twitch.accessToken- OAuth access tokenchannels.twitch.clientId- Twitch Client IDchannels.twitch.channel- join할 channelchannels.twitch.accounts.<accountName>- multi-account 구성
Tool actions
agent는twitch action을 호출할 수 있습니다.
send- channel에 메시지 전송
Safety & ops
- token은 비밀번호처럼 취급 - git에 커밋하지 마세요
- 장기 실행 bot에는 자동 token refresh 사용
- 접근 제어는 username보다 user ID allowlist 권장
- token refresh event와 connection status를 logs로 모니터링
- token scope 최소화 -
chat:read,chat:write만 요청 - 막혔을 때: 다른 process가 session을 잡고 있지 않은지 확인한 뒤 gateway 재시작
Limits
- 메시지당 500자 (단어 경계에서 자동 chunking)
- Markdown은 chunking 전에 제거
- 별도 rate limiting 없음(Twitch 기본 rate limit 사용)