Skip to main content

Building your own dream Twitch chat commands

Moobot lets you build your own dream Twitch chat commands yourself.

You can build the chat commands yourself or use those built by others. Anyone can share and use these special commands across different Twitch channels.

This is especially useful if Moobot does not support the response tags you need, as you can get them from another service, whether it is yours or someone else's.

Moobot does this through its URL-fetching feature, which uses custom chat commands to receive a response directly from a remote service.

Building your own dream Twitch chat commandsBuilding your own dream Twitch chat commands

Using your own custom-built chat command

To use a custom-built chat command, add a new custom chat command, enable advanced options, and add one or more URL-fetch response tags to the command.

Fill out the required inputs to tell Moobot how to interact with the remote service.

Using your own custom-built chat commandUsing your own custom-built chat command

The request for custom-built chat commands

Moobot retrieves the response for the chat command via an HTTP or HTTPS request (GET or POST) to the destination of your choice.

The destination must return either a plain text or JSON response.

The request for custom-built chat commandsThe request for custom-built chat commands

The URL for custom-built chat commands

Moobot can insert dynamic data into the URL by using tags.

You can put the dynamic data into the URL's query string, or even as the domain, but Moobot requires the URL to be valid at all times.

Available tags for dynamic data in the URL

Tag Description
Username of the channel The Twitch channel's username.
User id of the channel The Twitch channel's user id.
User id of the user The Twitch user id of whoever used the command.
Username of the user The Twitch username of whoever used the command.
Display-name of the user The Twitch display-name of whoever used the command.
Command The chat command's name.
Command arguments The arguments provided to the chat command. E.g. if you use the command in Twitch chat like «!Command this is a text», the arguments will be equal to «this is a text».
Command argument 1-5 The n-th argument provided to the chat command. E.g. if you use the command in Twitch chat like «!Command A B C», the #1 argument will be equal to «A», and #3 will be equal to «C». If you do not give an argument in Twitch chat, the argument will be empty.
YouTube username The YouTube username attached to the chat command.
Last.fm username The Last.fm username attached to the chat command.
Riot Games account name The Riot Games account name attached to the chat command.
Riot Games region The Riot Games region attached to the chat command.
Apex Legends username The Apex Legends username attached to the chat command.
Apex Legends platform The Apex Legends platform attached to the chat command.
Whether the user is a Moobot regular Boolean «true» or «false».
Whether the user is a Twitch chat moderator Boolean «true» or «false».
Whether the user is a Twitch subscriber Boolean «true» or «false».
Whether the user is a Twitch VIP Boolean «true» or «false».
Current time for the set time zone In 24-hour format.
Current date for the set time zone In «DD-MM-YYYY» format, where «DD» is the date of the month, «MM» is the month, and «YYYY» is the year.

Transforming user input in the URL

Sometimes the URL requires a specific letter casing, which a user's input may affect.

You can transform any user input in the URL to make sure it complies with the URL's requirements.

Select in the «Processing of user input in the URL» input how you want to transform any user input.

Leave the input blank if the user input in the URL does not need any transforming.

Transforming user input in the URLTransforming user input in the URL
Processing type Result
Lower case the input The input «this is THE user INPUT» transforms to «this is the user input».
Upper case the input The input «this is THE user INPUT» transforms to «THIS IS THE USER INPUT».
Sentence case the input The input «this is THE user INPUT» transforms to «This is the user input».
Upper case the first letter The input «this is THE user INPUT» transforms to «This is THE user INPUT».
Upper case the first letter of any words The input «this is THE user INPUT» transforms to «This Is THE User INPUT».
Capitalize the input The input «this is THE user INPUT» transforms to «This Is The User Input».

URL security

The URL is only visible to Moobot Editors who can view your custom chat commands. Exercise caution when including private information or API keys.

JSON responses

For JSON responses, you must specify the location of your objects in the JSON using JSON pointers.

View the JSON Pointer RFC 6901 to see how to structure your JSON pointer.JSON responsesJSON responses

Example JSON-pointer #1

For the below JSON response, the JSON pointer «/status» will return «Message response».

{
"status": "Message response",
"delayed": true
}

Example JSON-pointer #2

For the below JSON response, the JSON pointer «/status/message» will return «Message response».

{
"status": {
"message": "Message response",
"code": 61
},
"delayed": true
}

Example JSON-pointer #3

For the below JSON response, the JSON pointer «/status/1/message» will return «Message response».

{
"status": [{
"message": "None",
"code": 60
}, {
"message": "Message response",
"code": 61
}],
"delayed": true
}

Built-in headers for your custom-built chat commands

Moobot sends several default headers with each of its URL-fetch requests.

Standard headers

Header Value
Moobot-version The version of the URL-fetch implementation that the request is using.
() Moobot-user-id The Twitch user id of whoever used the command.
() Moobot-user-name The Twitch username of whoever used the command.
Moobot-channel-id The Twitch channel's user id.
Moobot-channel-name The Twitch channel's username.

() Not present when the chat command is used in Discord.

Headers for Discord chat commands

Moobot only sends these headers when the chat command is used in Discord.

Header Value
Moobot-discord-user-id The Discord user id of whoever used the command.
Moobot-discord-user-name The Discord user name of whoever used the command.
Moobot-discord-user-display-name The Discord user display name of whoever used the command. This will be the same as the Discord user name if the user has not set a display name.
Moobot-discord-server-id The Discord server ID where the command was used.
Moobot-discord-room-id The Discord room ID where the command was used.

Error-checking your custom-built chat commands

The event log on your Moobot dashboard will display any errors that occur during a fetch. This is useful for debugging while setting up your command.

Unlike standard custom chat commands, Moobot will not post a response to Twitch chat if a request fails. In the chat command's edit menu, you can set a custom failure message to send instead.

Built-in restrictions

Custom-built chat commands have certain restrictions to prevent abuse:

  • Connections and read operations have short timeouts.
  • Requests do not follow redirects.
  • Moobot restricts the maximum size of the request's response.

If a request repeatedly fails these restrictions, Moobot may blacklist the URL temporarily. Persistent failures can result in a permanent blacklisting.

Sharing your custom-built chat commands

You can share a custom-built chat command by exporting it to a file or link. Anyone can then use that file or link to import the command into their own Moobot.

Use Moobot's Import & Export tool to share your commands.