velho
Examples

Quick Start Bot

Spin up a simple Twitch bot that refreshes OAuth tokens with the velho CLI, connects to chat, and responds to commands like !ping.

Environment

TWITCH_CHANNEL_LOGIN, TWITCH_CLIENT_ID, TWITCH_CLIENT_SECRET, TWITCH_BOT_USERNAME, TWITCH_BOT_REFRESH_TOKEN

Get started

  1. Install dependencies with bun install.
  2. Run bunx velho-setup and follow the prompts to authenticate both the channel and bot accounts. The CLI writes the refresh token and channel details to .env.
  3. Confirm the required environment variables listed above are present. Update values manually if you prefer not to use the CLI helper.
  4. Start the bot with bun run examples/QUICK_START_BOT.ts. The script refreshes the chat token, joins your channel, and listens for commands.
  5. Send !ping in chat to verify the bot responds, then add your own branches in handleCommand.

What you can do

  • Refresh OAuth tokens on the fly using TwitchAuth.getUserAccessToken.
  • Respond to chat commands with friendly logging and automatic reconnect behaviour.
  • Extend the command handler to integrate with APIs, overlays, or moderation tools.
  • Add structured logging or metrics around connection events for production readiness.

Ideas for growth

  • Store refresh tokens in a secure secret manager instead of environment variables.
  • Use the Helix client to enrich command responses with live stream or channel metadata.
  • Pair with EventSub to react to follows, subscriptions, or channel point redemptions.

Resources

On this page