Skip to content

twitch_message()

Handle Twitch chat messages and commands in a Flow script.

Updated View as Markdown
For humans
Flow functionFlow Pro scriptingBase functions

This article covers the following platforms

twitch_message receives Twitch chat messages. It only runs if the user has enabled the Twitch integration in the Flow settings. If the user set a command in the script settings, it runs only when that command is found within the message; otherwise, every message comes through.

twitch_message((message) => {
  const example_message = {
    "tags": {
      "badge-info": {
        "founder": "51"
      },
      "badges": {
        "moderator": "1",
        "founder": "0",
        "bits": "1000"
      },
      "color": "#65C47F",
      "display-name": "runshotgun",
      "emotes": null,
      "first-msg": "0",
      "id": "9dcf58b7-e6a8-484d-9c16-280f2d384c4f",
      "mod": "1",
      "returning-chatter": "0",
      "room-id": "91420958",
      "subscriber": "1",
      "tmi-sent-ts": "1666907326935",
      "turbo": "0",
      "user-id": "84610723",
      "user-type": "mod"
    },
    "source": {
      "nick": "runshotgun",
      "host": "runshotgun@runshotgun.tmi.twitch.tv"
    },
    "command": {
      "command": "PRIVMSG",
      "channel": "#theskyloungetv"
    },
    "parameters": "Looking good!"
  }
});

message: A message from Twitch chat. See the example above for its structure.

The tags structure carries the most useful details. Which tags are defined depends on the type of message. A few examples:

// Bits
"bits": "10"

// Resub
"msg-id": "resub",
"msg-param-cumulative-months": "8",
"msg-param-months": "0",
"msg-param-multimonth-duration": "0",
"msg-param-multimonth-tenure": "0",
"msg-param-should-share-streak": "0",
"msg-param-sub-plan-name": "Channel\\sSubscription\\s(oohcando)",
"msg-param-sub-plan": "Prime",
"msg-param-was-gifted": "false",
"subscriber": "1",
"system-msg": "runshotgun\\ssubscribed\\swith\\sPrime.\\sThey've\\ssubscribed\\sfor\\s8\\smonths!"

// Highlighted message
"msg-id": "highlighted-message"

For more on the Twitch integration, see the official API documentation: https://dev.twitch.tv/docs/irc/example-bot

APIs

The following APIs are also available:

Navigation

Type to search…

↑↓ navigate↵ selectEsc close