Twitch.ChatMessage
WebSocket event schema, payload, and examples
anonymous
boolean required
emotes
Emote[]
endIndex
integer required
imageUrl
string
name
string
startIndex
integer required
type
string
isFromSharedChatGuest
boolean required
isInSharedChat
boolean required
isReply
boolean required
isSharedChatHost
boolean required
isTest
boolean required
messageId
string
meta
object required
firstMessage
boolean required
firstMessageTimestamp
string required
internal
boolean required
isCustomReward
boolean required
isHighlighted
boolean required
isMe
boolean required
isTest
boolean required
returningChatter
boolean required
parts
TwitchMessagePartBase[]
text
string
type
string
reply
object required
msgBody
string
msgId
string
threadMsgId
string
threadUserLogin
string
userId
string
userLogin
string
userName
string
sharedChatSource
object required
id
string
login
string
name
string
type
string
text
string
user
object required
badges
TwitchBadge[]
imageUrl
string
info
string
name
string
version
string
color
string
id
string
login
string
monthsSubscribed
integer required
name
string
role
integer required
| Value | Name |
|---|---|
| 0 | Unknown |
| 1 | Viewer |
| 2 | Vip |
| 3 | Moderator |
| 4 | Broadcaster |
subscribed
boolean required
subscriptionTier
string
type
string
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": {
"user": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/TwitchUser"
}
]
},
"messageId": {
"type": [
"null",
"string"
]
},
"meta": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/TwitchMessageMetaData"
}
]
},
"anonymous": {
"type": "boolean"
},
"text": {
"type": [
"null",
"string"
]
},
"emotes": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/$defs/Emote"
}
},
"parts": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/$defs/TwitchMessagePartBase"
}
},
"isReply": {
"type": "boolean"
},
"reply": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/TwitchMessageReply"
}
]
},
"isTest": {
"type": "boolean"
},
"sharedChatSource": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/$defs/TwitchBaseUser"
}
]
},
"isInSharedChat": {
"type": "boolean"
},
"isSharedChatHost": {
"type": "boolean"
},
"isFromSharedChatGuest": {
"type": "boolean"
}
},
"$defs": {
"TwitchUser": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": [
"null",
"string"
]
},
"login": {
"type": [
"null",
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"type": {
"type": [
"null",
"string"
]
},
"role": {
"$ref": "#/$defs/ViewerRole"
},
"badges": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/$defs/TwitchBadge"
}
},
"color": {
"type": [
"null",
"string"
]
},
"subscribed": {
"type": "boolean"
},
"subscriptionTier": {
"type": [
"null",
"string"
]
},
"monthsSubscribed": {
"type": "integer"
}
}
},
"ViewerRole": {
"type": "integer",
"description": "",
"x-enum-names": [
"Unknown",
"Viewer",
"Vip",
"Moderator",
"Broadcaster"
],
"x-enum-descriptions": [
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"
},
"firstMessage": {
"type": "boolean"
},
"firstMessageTimestamp": {
"type": "string"
},
"returningChatter": {
"type": "boolean"
},
"isHighlighted": {
"type": "boolean"
},
"isMe": {
"type": "boolean"
},
"isCustomReward": {
"type": "boolean"
},
"isTest": {
"type": "boolean"
}
}
},
"Emote": {
"type": "object",
"additionalProperties": false,
"properties": {
"type": {
"type": [
"null",
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"startIndex": {
"type": "integer"
},
"endIndex": {
"type": "integer"
},
"imageUrl": {
"type": [
"null",
"string"
]
}
}
},
"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
{
"user": null,
"messageId": "CBmfc95i",
"meta": {},
"anonymous": false,
"text": null,
"emotes": [
{
"type": "",
"name": null,
"startIndex": -852,
"endIndex": -592,
"imageUrl": null
},
{
"type": "zNXjB",
"name": null,
"startIndex": 580,
"endIndex": 368,
"imageUrl": "KaTSMXIyt"
},
{
"type": null,
"name": null,
"startIndex": -884,
"endIndex": 755,
"imageUrl": null
},
{
"type": "15ek",
"name": "IamuT200um",
"startIndex": -414,
"endIndex": 956,
"imageUrl": "FzoqMvWb"
},
{
"type": "FAY3Dnqd",
"name": null,
"startIndex": 370,
"endIndex": 326,
"imageUrl": null
}
],
"parts": [
{
"type": null,
"text": null
},
{
"type": "hckYDP",
"text": ""
},
{
"type": null,
"text": null
},
{
"type": null,
"text": "ynwX5mpEs"
},
{
"type": "w",
"text": "UZygZ1HtkG"
}
],
"isReply": true,
"reply": null,
"isTest": true,
"sharedChatSource": null,
"isInSharedChat": false,
"isSharedChatHost": true,
"isFromSharedChatGuest": true
}
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);
});
 Â