Twitch Twitter



The latest tweets from @TwitchSupport. You need to enable JavaScript to run this app. Connect your Twitch to hundreds of other services. Twitch is the world’s leading social video platform and community for gamers, video game culture, and the creative arts. Turn on Applets to grow your Twitch audience, and keep up with your favorite broadcasters' videos and livestreams.

Notifications

Overview

Twitch offers an Internet Relay Chat (IRC) interface for chat functionality. Chatbots allow you to interact programmatically with a Twitch chat feed using IRC standards; the bot connects to the Twitch IRC network as a client to perform these actions. This guide presents an easy bot example to get you started, along with next steps for using chatbots and IRC.

Building the Bot

We’ll build a simple chatbot that responds in chat when someone types !dice. (This is known as a chatbot command.) When triggered, it randomly generates a number between 1-6. We run the fully-functioning chatbot on Glitch, and then show how you can alternatively run it locally on your computer. Here’s what the end result looks like:

Get Environment Variables

To start, you’ll need three environment variables:

Twitch
VariableDescription
BOT_USERNAME

The account (username) that the chatbot uses to send chat messages. This can be your Twitch account. Alternately, many developers choose to create a second Twitch account for their bot, so it's clear from whom the messages originate.

CHANNEL_NAME

The Twitch channel name where you want to run the bot. Usually this is your main Twitch account.

OAUTH_TOKEN

The token to authenticate your chatbot with Twitch's servers. Generate this with https://twitchapps.com/tmi/ (a Twitch community-driven wrapper around the Twitch API), while logged in to your chatbot account. The token will be an alphanumeric string.

Run the Chatbot on Glitch

Glitch lets you instantly create, edit, and host an app in the cloud. The code for this tutorial is live and can be accessed here. Simply put your credentials (the environment variables above) in the .env file and click Run.

Now that the bot is running and connected to the Twitch IRC network, we can interact with it. On twitch.tv/<CHANNEL_NAME>, type !dice. You’ll see a number from 1 to 6.

Twitch Twitter Banner

Run the Chatbot Locally

If you prefer to build and run our bot example locally, follow these steps:

Twitter
  1. Download and install node.js if needed.
  2. On the command line, install tmi.js using the Node Package Manager.
    npm install tmi.js
  3. In bot.js below, replace the three environmental variables with the values obtained above.
  4. Run bot.js locally using node:
    node bot.js
  5. Now that the bot is running and connected to the Twitch IRC network, we can interact with it. On twitch.tv/<CHANNEL_NAME>, type !dice. You’ll see a number from 1 to 6.

bot.js

Next Steps

  • For more information about Twitch chatbots and IRC, see the Chatbots & IRC Guide.
  • To authenticate your chatbot in a production setting, we recommend you register your app (chatbot) and use the OAuth Authorization code flow. This enables you to authenticate programmatically. To learn more, see the Apps & Authentication Guide.
  • For help, reach out to @TwitchDev on Twitter or the Twitch chatbot forum.

Twitch uses a system of emotes which can be used in chat. Emotes such as Kappa or LUL can be typed or chosen from the global emotes list, with an image replacing the emote text when sent.

Many emotes used on Twitch display real people, and have varied meanings based on memes, in-jokes, or other references.

Twitch twitter icon

Twitch Support Twitter

In June 2020 the TwitchCop emote displaying a police officer blowing a whistle - originally added in 2017 - was removed. This followed continued protests over police brutality in the United States as part of the #BlackLivesMatter movement.

Twitch Twitter Button

List of global emotes on Twitch

Twitch Twitter Icon

Last updated: June 2020