Chat Command Bot
Create a resilient chat bot that authenticates with Twitch, joins a channel, listens for commands, and responds with live data fetched from Helix. The bot automatically reconnects and reports errors to keep you in control.
Get started
- Install project dependencies with
npm install. -
Run
npx velho-setupto walk through the interactive OAuth helper, or manually create a.envfile with the required credentials listed on this page. - Give your bot account chat permissions by visiting the generated authorization URL and completing consent.
-
Start the bot with
npx tsx 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.