Requesting Twitch-specific capabilities

Twitch capabilities expose your bot to more messages and metadata than it would normally receive, which enriches the experience your bot can provide. By using the REQ subcommand specified in the IRC v3 capability negotiation specification, your bot can request the following Twitch-specific capabilities.

Capability Description Lets your bot send PRIVMSG messages that include Twitch chat commands and receive Twitch-specific IRC messages. Lets your bot receive JOIN and PART messages when users join and leave the chat room. Adds additional metadata to the command and membership messages. For the list of metadata available with each message, see Twitch tags. To request the tags capability, you must also request the commands capability.

Note that the capability strings are case sensitive.

To request Twitch-specific command messages like GLOBALUSERSTATE, ROOMSTATE, and USERSTATE, send the following commands capability message.


As you can see, the messages aren’t very useful: GLOBALUSERSTATE USERSTATE #foo ROOMSTATE #foo

But if you also request the tags capability:


You’ll get much richer messages:

@badge-info=;badges=;color=#0000FF;display-name=barbar;emote-sets=0,300374282;user-id=713936733;user-type= GLOBALUSERSTATE
@badge-info=;badges=;color=#0000FF;display-name=barbar;emote-sets=0,300374282;mod=0;subscriber=0;user-type= USERSTATE #barbar
@emote-only=0;followers-only=-1;r9k=0;rituals=0;room-id=728719755;slow=10;subs-only=0 ROOMSTATE #barbar

If your capabilities request succeeds, Twitch replies with the standard ACK subcommand message. CAP * ACK

If your bot requests a capability that the Twitch IRC server doesn’t support, the server replies with the standard NAK subcommand message that identifies the capabilities that were denied.


Here’s what the snippet of code might look like if you used this websocket package for Node.js.

client.on('connect', function(connection) {
    console.log('WebSocket Client Connected');
    connection.sendUTF('CAP REQ');

Next steps

After requesting capabilities, the next step is to authenticate your bot with the Twitch IRC server.