This release is a pre-release and may not be stable for production use.
@elizaos/plugin-twitch
Twitch chat integration plugin for elizaOS agents.
Features
- Real-time Chat: Connect to Twitch channels and participate in chat
- Multi-channel Support: Join and monitor multiple channels simultaneously
- Role-based Access Control: Filter interactions by user roles (broadcaster, moderator, VIP, subscriber)
- Mention Detection: Optionally only respond when @mentioned
- Token Refresh: Automatic OAuth token refresh (when configured)
- Markdown Stripping: Automatically converts markdown to plain text for Twitch
Installation
npm install @elizaos/plugin-twitch
Prerequisites
- Twitch Developer Account: Register your application at Twitch Developer Console
- OAuth Token: Generate a token with
chat:readandchat:editscopes at Twitch Token Generator
Configuration
Set the following environment variables:
Required
| Variable | Description |
|---|---|
TWITCH_USERNAME |
Bot's Twitch username |
TWITCH_CLIENT_ID |
Application client ID from Twitch Developer Console |
TWITCH_ACCESS_TOKEN |
OAuth access token with chat:read and chat:edit scopes |
TWITCH_CHANNEL |
Primary channel to join (without # prefix) |
Optional
| Variable | Description | Default |
|---|---|---|
TWITCH_CLIENT_SECRET |
Application client secret (for token refresh) | - |
TWITCH_REFRESH_TOKEN |
OAuth refresh token (for automatic refresh) | - |
TWITCH_CHANNELS |
Comma-separated list of additional channels | - |
TWITCH_REQUIRE_MENTION |
Only respond when @mentioned | false |
TWITCH_ALLOWED_ROLES |
Comma-separated roles allowed to interact | all |
Allowed Roles
all- Anyone can interactowner/broadcaster- Channel owner onlymoderator- Moderatorsvip- VIP userssubscriber- Subscribers
Usage
Basic Setup
import twitchPlugin from "@elizaos/plugin-twitch";
const agent = new Agent({
plugins: [twitchPlugin],
});
Actions
TWITCH_SEND_MESSAGE
Send a message to a Twitch channel.
// User: "Send a message saying 'Hello everyone!'"
// Agent will send to the current channel
TWITCH_JOIN_CHANNEL
Join a new Twitch channel.
// User: "Join the channel xqc"
// Agent will join #xqc
TWITCH_LEAVE_CHANNEL
Leave a Twitch channel.
// User: "Leave the channel xqc"
// Agent will leave #xqc (cannot leave primary channel)
TWITCH_LIST_CHANNELS
List all channels the bot is currently in.
// User: "What channels are you in?"
// Agent will list all joined channels
Providers
twitchChannelState
Provides context about the current Twitch channel:
- Channel name
- Whether it's the primary channel
- List of all joined channels
- Bot username
twitchUserContext
Provides context about the user in the conversation:
- User ID and username
- Display name
- Roles (broadcaster, moderator, VIP, subscriber)
- Chat color
Events
The plugin emits the following events:
| Event | Description |
|---|---|
TWITCH_MESSAGE_RECEIVED |
A chat message was received |
TWITCH_MESSAGE_SENT |
A message was sent |
TWITCH_JOIN_CHANNEL |
Bot joined a channel |
TWITCH_LEAVE_CHANNEL |
Bot left a channel |
TWITCH_CONNECTION_READY |
Connected to Twitch |
TWITCH_CONNECTION_LOST |
Connection lost |
Message Limits
- Maximum message length: 500 characters
- Messages longer than 500 characters are automatically split
Security Considerations
- Token Security: Never expose your access token in client-side code
- Scope Limitation: Only request necessary OAuth scopes
- Role Filtering: Use
TWITCH_ALLOWED_ROLESto restrict who can interact - Mention Requirement: Enable
TWITCH_REQUIRE_MENTIONin busy channels
Troubleshooting
Connection Issues
- Verify your OAuth token is valid and not expired
- Check that the username matches the token owner
- Ensure the client ID is correct
Authentication Errors
- Regenerate your OAuth token
- Verify scopes include
chat:readandchat:edit - Check for typos in environment variables
Message Not Sending
- Verify you have joined the target channel
- Check that the channel name is correct (no # prefix)
- Ensure your token has
chat:editscope
Multi-language Support
This plugin supports:
- TypeScript - Full implementation with @twurple/chat
- Python - Full implementation with twitchio
- Rust - Full implementation with native WebSocket
License
MIT
Metadata
Release files for elizaos-plugin-twitch 2.0.0a5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| elizaos_plugin_twitch-2.0.0a5.tar.gz | 18.3 kB | Without provenance | Details for elizaos_plugin_twitch-2.0.0a5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| elizaos_plugin_twitch-2.0.0a5-py3-none-any.whl | Python 3 | none | any | Details for elizaos_plugin_twitch-2.0.0a5-py3-none-any.whl |
Total release size: 36.3 kB
Release files / elizaos_plugin_twitch-2.0.0a5.tar.gz
| Download URL | elizaos_plugin_twitch-2.0.0a5.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fbfc97797247870d03976af8e643b0def24dbd08550ff5c36569d30db186033
|
|
BLAKE2b-256 checksum How to use checksums |
5a3741ebe751b8d3cc4fcf727b939e445a330fdfb4cbf70d40175bbdfb111a96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / elizaos_plugin_twitch-2.0.0a5-py3-none-any.whl
| Download URL | elizaos_plugin_twitch-2.0.0a5-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afb79c4e03717b1cfba6f68cf69f5af726b7d854af28e58fe28d220c08677e79
|
|
BLAKE2b-256 checksum How to use checksums |
94934ae0dc513dfd7bb22d63f9f19a0636ef3909db89de59245563436444d823
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for elizaos-plugin-twitch 2.0.0a5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.