Examples
Chat Command Bot
Create a resilient chat bot that joins a channel, listens for commands, and responds with live data fetched from Helix.
Environment
TWITCH_CHANNEL_LOGIN, TWITCH_CLIENT_ID, TWITCH_CLIENT_SECRET, TWITCH_CHAT_USERNAME,
TWITCH_CHAT_TOKEN — the setup CLI writes them to .env for you.
Get started
- Install project dependencies with
bun install. - Run
bunx velho-setupto walk through the interactive OAuth helper, or manually create a.envfile with the required credentials listed above. - Give your bot account chat permissions by visiting the generated authorization URL and completing consent.
- Start the bot with
bun run examples/CHAT_COMMAND_BOT.ts. The script validates your environment variables and connects to chat. - Type commands such as
!uptime,!title, or!helpfrom the channel to see the bot respond.
What you can do
- Listen for chat messages and filter them by channel or user roles.
- Fetch uptime and title information via the Helix API and reply instantly in chat.
- Handle reconnects and error conditions with informative logging for on-call teams.
- Expand the
handleCommandfunction to support moderation or loyalty workflows.
Operational tips
- Swap
autoJoinfor a dynamic list if the bot needs to monitor multiple channels. - Persist the broadcaster ID instead of requesting it on every command to minimise Helix calls.
- Combine this bot with EventSub notifications to announce follows, subs, and channel point rewards.