Skip to main content

Building your own dream Twitch chat commands

Moobot lets you to build your own dream Twitch chat commands yourself, directly into the Twitch bot!

You can build the chat commands yourself, or use what someone else has already built. Anyone can share or use these special chat commands across different Twitch channels.

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

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

A custom-built chat command for dad jokes in Twitch chat

Using your own custom-built chat command

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

Fill out the required inputs, which tells Moobot how to use your remote service.

The URL-fetch section in the custom command edit-menu

The request for custom-built chat commands

Moobot will get the response for the chat command with an HTTP/HTTPS request, either using GET or POST, to the destination of your choice.

The destination will either have to return a plain text or JSON response.

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.

You can use these tags for dynamic data in your URL:

  • 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».
  • Tier of the user who sent the command: The Tier of whoever used the command.
  • 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.

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 given URL is only visible to the Moobot Editors who have access to view your custom chat commands, but use precaution when disclosing private information and keys in it.

JSON responses

For JSON responses you have to select the location of your objects in the JSON. You do this by using JSON pointers.

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

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 these default headers with each request:

  • 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.

() May not be present when you use the chat command in Discord.

Moobot only sends these default headers with the request when you use the chat command in Discord:

  • 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-discriminator: The Discord user discriminator of whoever used the command.
  • 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 occurring during a fetch. You can use this as a debugging tool while setting up your custom-built chat command.

Unlike normal custom chat commands, Moobot will not post the response to Twitch chat if a request fails. In the chat command's edit-menu you can set a custom (static) failure message to send in its place.

Built-in restrictions

The custom-built chat commands have certain restrictions in place to avoid abuse:

  • Connections and reads have small timeouts.
  • Requests do not follow redirects.
  • Moobot restricts the returned size of the request's response.

Keep in mind that Moobot will blacklist you temporarily if the request fails any of these restrictions.

A permanent blacklisting will happen if the request continues to fail the restrictions.

Sharing your custom-built chat commands

You can easily share a custom-built chat command by exporting it to a file and then sharing that file with others.

Anyone can then use that file to import your custom-built chat command into their own Moobot.

Use Moobot's Import & Export menu to export your custom-built chat command to a file.