Twitch.ChatMessage

WebSocket event schema, payload, and examples

Properties

message
object required
user
object required
messageId
string
meta
object required
anonymous
boolean required
text
string
emotes
Emote[]
parts
TwitchMessagePartBase[]
isReply
boolean required
reply
object required
isTest
boolean required
sharedChatSource
object required
isInSharedChat
boolean required
isSharedChatHost
boolean required
isFromSharedChatGuest
boolean required

Schema

The JSON Schema for the event payload, if available.
schema.json
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "TwitchMessageEvent",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "message": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/ChatMessage"
        }
      ]
    },
    "user": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/TwitchUser"
        }
      ]
    },
    "messageId": {
      "type": [
        "null",
        "string"
      ]
    },
    "meta": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/TwitchMessageMetaData"
        }
      ]
    },
    "anonymous": {
      "type": "boolean"
    },
    "text": {
      "type": [
        "null",
        "string"
      ]
    },
    "emotes": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/definitions/Emote"
      }
    },
    "parts": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/definitions/TwitchMessagePartBase"
      }
    },
    "isReply": {
      "type": "boolean"
    },
    "reply": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/TwitchMessageReply"
        }
      ]
    },
    "isTest": {
      "type": "boolean"
    },
    "sharedChatSource": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/TwitchBaseUser"
        }
      ]
    },
    "isInSharedChat": {
      "type": "boolean"
    },
    "isSharedChatHost": {
      "type": "boolean"
    },
    "isFromSharedChatGuest": {
      "type": "boolean"
    }
  },
  "definitions": {
    "ChatMessage": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "internal": {
          "type": "boolean"
        },
        "msgId": {
          "type": [
            "null",
            "string"
          ]
        },
        "clientNonce": {
          "type": [
            "null",
            "string"
          ]
        },
        "userId": {
          "type": [
            "null",
            "string"
          ]
        },
        "username": {
          "type": [
            "null",
            "string"
          ]
        },
        "role": {
          "$ref": "#/definitions/ViewerRole"
        },
        "subscriber": {
          "type": "boolean"
        },
        "subscriptionTier": {
          "type": [
            "null",
            "string"
          ]
        },
        "displayName": {
          "type": [
            "null",
            "string"
          ]
        },
        "color": {
          "type": [
            "null",
            "string"
          ]
        },
        "channel": {
          "type": [
            "null",
            "string"
          ]
        },
        "message": {
          "type": [
            "null",
            "string"
          ]
        },
        "isHighlighted": {
          "type": "boolean"
        },
        "isMe": {
          "type": "boolean"
        },
        "isCustomReward": {
          "type": "boolean"
        },
        "isAnonymous": {
          "type": "boolean"
        },
        "isReply": {
          "type": "boolean"
        },
        "reply": {
          "oneOf": [
            {
              "type": "null"
            },
            {
              "$ref": "#/definitions/ReplyData"
            }
          ]
        },
        "bits": {
          "type": "integer",
          "format": "int32"
        },
        "firstMessage": {
          "type": "boolean"
        },
        "returningChatter": {
          "type": "boolean"
        },
        "hasBits": {
          "type": "boolean"
        },
        "emotes": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/Emote"
          }
        },
        "cheerEmotes": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/CheerEmote"
          }
        },
        "badges": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/Badge"
          }
        },
        "monthsSubscribed": {
          "type": "integer",
          "format": "int32"
        },
        "isTest": {
          "type": "boolean"
        },
        "isInSharedChat": {
          "type": "boolean"
        },
        "isFromSharedChatGuest": {
          "type": "boolean"
        },
        "sourceRoomId": {
          "type": [
            "null",
            "string"
          ]
        },
        "sourceMsgId": {
          "type": [
            "null",
            "string"
          ]
        },
        "sourceBadges": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/Badge"
          }
        }
      }
    },
    "ViewerRole": {
      "type": "integer",
      "description": "",
      "x-enum-names": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enum-varnames": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enumNames": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enum-descriptions": [
        null,
        null,
        null,
        null,
        null
      ],
      "x-enumDescriptions": [
        null,
        null,
        null,
        null,
        null
      ],
      "enum": [
        0,
        1,
        2,
        3,
        4
      ]
    },
    "ReplyData": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "userId": {
          "type": [
            "null",
            "string"
          ]
        },
        "userLogin": {
          "type": [
            "null",
            "string"
          ]
        },
        "userName": {
          "type": [
            "null",
            "string"
          ]
        },
        "msgId": {
          "type": [
            "null",
            "string"
          ]
        },
        "msgBody": {
          "type": [
            "null",
            "string"
          ]
        },
        "threadMsgId": {
          "type": [
            "null",
            "string"
          ]
        },
        "threadUserLogin": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "Emote": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": [
            "null",
            "string"
          ]
        },
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "startIndex": {
          "type": "integer",
          "format": "int32"
        },
        "endIndex": {
          "type": "integer",
          "format": "int32"
        },
        "imageUrl": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "CheerEmote": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": [
            "null",
            "string"
          ]
        },
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "startIndex": {
          "type": "integer",
          "format": "int32"
        },
        "endIndex": {
          "type": "integer",
          "format": "int32"
        },
        "imageUrl": {
          "type": [
            "null",
            "string"
          ]
        },
        "bits": {
          "type": "integer",
          "format": "int32"
        },
        "color": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "Badge": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "version": {
          "type": [
            "null",
            "string"
          ]
        },
        "imageUrl": {
          "type": [
            "null",
            "string"
          ]
        },
        "info": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "TwitchUser": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": [
            "null",
            "string"
          ]
        },
        "login": {
          "type": [
            "null",
            "string"
          ]
        },
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "type": {
          "type": [
            "null",
            "string"
          ]
        },
        "role": {
          "$ref": "#/definitions/ViewerRole2"
        },
        "badges": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/TwitchBadge"
          }
        },
        "color": {
          "type": [
            "null",
            "string"
          ]
        },
        "subscribed": {
          "type": "boolean"
        },
        "subscriptionTier": {
          "type": [
            "null",
            "string"
          ]
        },
        "monthsSubscribed": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "ViewerRole2": {
      "type": "integer",
      "description": "",
      "x-enum-names": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enum-varnames": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enumNames": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enum-descriptions": [
        null,
        null,
        null,
        null,
        null
      ],
      "x-enumDescriptions": [
        null,
        null,
        null,
        null,
        null
      ],
      "enum": [
        0,
        1,
        2,
        3,
        4
      ]
    },
    "TwitchBadge": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "version": {
          "type": [
            "null",
            "string"
          ]
        },
        "imageUrl": {
          "type": [
            "null",
            "string"
          ]
        },
        "info": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "TwitchMessageMetaData": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "internal": {
          "type": "boolean"
        },
        "clientNonce": {
          "type": [
            "null",
            "string"
          ]
        },
        "firstMessage": {
          "type": "boolean"
        },
        "returningChatter": {
          "type": "boolean"
        },
        "isHighlighted": {
          "type": "boolean"
        },
        "isMe": {
          "type": "boolean"
        },
        "isCustomReward": {
          "type": "boolean"
        },
        "isTest": {
          "type": "boolean"
        }
      }
    },
    "TwitchMessagePartBase": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": [
            "null",
            "string"
          ]
        },
        "text": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "TwitchMessageReply": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "msgId": {
          "type": [
            "null",
            "string"
          ]
        },
        "userId": {
          "type": [
            "null",
            "string"
          ]
        },
        "userLogin": {
          "type": [
            "null",
            "string"
          ]
        },
        "userName": {
          "type": [
            "null",
            "string"
          ]
        },
        "msgBody": {
          "type": [
            "null",
            "string"
          ]
        },
        "threadMsgId": {
          "type": [
            "null",
            "string"
          ]
        },
        "threadUserLogin": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "TwitchBaseUser": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": [
            "null",
            "string"
          ]
        },
        "login": {
          "type": [
            "null",
            "string"
          ]
        },
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "type": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    }
  }
}

JSON Payload

An example JSON payload for the event, automatically generated using JSONSchemaFaker
example.json
{
  "anonymous": true,
  "emotes": [
    {
      "endIndex": -65294787,
      "imageUrl": null,
      "name": null,
      "startIndex": -56195156,
      "type": null
    },
    {
      "endIndex": -47838154,
      "imageUrl": null,
      "name": null,
      "startIndex": 90009349,
      "type": "deserunt"
    },
    {
      "endIndex": 13956262,
      "imageUrl": null,
      "name": null,
      "startIndex": 35585067,
      "type": null
    },
    {
      "endIndex": -39573314,
      "imageUrl": null,
      "name": "deserunt irure dolore eiusmod",
      "startIndex": 85065124,
      "type": null
    },
    {
      "endIndex": 49130459,
      "imageUrl": "ullamco culpa minim",
      "name": null,
      "startIndex": 61101458,
      "type": "ut est labore consequat"
    }
  ],
  "isFromSharedChatGuest": false,
  "isInSharedChat": true,
  "isReply": true,
  "isSharedChatHost": false,
  "isTest": true,
  "message": {
    "badges": [
      {
        "imageUrl": null,
        "info": null,
        "name": null,
        "version": "ut esse"
      },
      {
        "imageUrl": null,
        "info": "in esse proident dolore non",
        "name": "voluptate Duis minim Excepteur eiusmod",
        "version": null
      },
      {
        "imageUrl": null,
        "info": null,
        "name": "et ea nostrud",
        "version": "Duis quis fugiat ex minim"
      },
      {
        "imageUrl": null,
        "info": "ex pariatur cillum laboris",
        "name": null,
        "version": "ex fugiat Ut consequat"
      },
      {
        "imageUrl": "sunt est",
        "info": null,
        "name": "eiusmod consequat",
        "version": null
      }
    ],
    "bits": 39901746,
    "channel": null,
    "cheerEmotes": null,
    "clientNonce": "incididunt et tempor occaecat",
    "color": "fugiat nulla magna",
    "displayName": "ut",
    "emotes": null,
    "firstMessage": true,
    "hasBits": true,
    "internal": true,
    "isAnonymous": true,
    "isCustomReward": true,
    "isFromSharedChatGuest": false,
    "isHighlighted": true,
    "isInSharedChat": false,
    "isMe": false,
    "isReply": false,
    "isTest": true,
    "message": "Excepteur",
    "monthsSubscribed": -65931877,
    "msgId": null,
    "reply": null,
    "returningChatter": false,
    "role": 0,
    "sourceBadges": [
      {
        "imageUrl": "deserunt Duis ad",
        "info": "id Lorem",
        "name": null,
        "version": "nisi deserunt"
      },
      {
        "imageUrl": null,
        "info": null,
        "name": "laboris nulla reprehenderit",
        "version": "qui dolor deserunt sint aliquip"
      },
      {
        "imageUrl": null,
        "info": "ea",
        "name": "ad ex",
        "version": null
      },
      {
        "imageUrl": "veniam",
        "info": null,
        "name": "id",
        "version": null
      },
      {
        "imageUrl": null,
        "info": "ipsum nulla Lorem",
        "name": null,
        "version": "mollit ut dolor"
      }
    ],
    "sourceMsgId": null,
    "sourceRoomId": "ex minim",
    "subscriber": true,
    "subscriptionTier": null,
    "userId": null,
    "username": null
  },
  "messageId": null,
  "meta": {
    "clientNonce": "tempor non cillum consequat nisi",
    "firstMessage": true,
    "internal": true,
    "isCustomReward": false,
    "isHighlighted": false,
    "isMe": false,
    "isTest": true,
    "returningChatter": false
  },
  "parts": [
    {
      "text": "ea pariatur Lorem",
      "type": "sed velit in"
    },
    {
      "text": "fugiat",
      "type": null
    },
    {
      "text": "veniam irure anim labore",
      "type": null
    },
    {
      "text": null,
      "type": null
    },
    {
      "text": "quis dolor sit in",
      "type": null
    }
  ],
  "reply": null,
  "sharedChatSource": {
    "id": null,
    "login": "ut fugiat culpa ipsum eu",
    "name": null,
    "type": null
  },
  "text": "anim ex",
  "user": {
    "badges": null,
    "color": null,
    "id": null,
    "login": "nulla quis occaecat sed",
    "monthsSubscribed": -52490848,
    "name": "voluptate in proident dolor",
    "role": 4,
    "subscribed": false,
    "subscriptionTier": "ex do ullamco ut",
    "type": null
  }
}

Client Example

Example code showing how to subscribe to this event using the Streamer.bot WebSocket Client
index.js
// Initialize the Streamer.bot WebSocket Client
const client = new StreamerbotClient();

// Subscribe to "Twitch.ChatMessage" events and register a callback
client.on('Twitch.ChatMessage', ({ event, data }) => {
  // Code here will run every time the event is received!
  console.log('Received event:', event.source, event.type);
  console.log('Event data:', data);
});