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 subscriber: Boolean, Ā«trueĀ» or Ā«falseĀ».
  • Whether the user is a Twitch VIP: Boolean, Ā«trueĀ» or Ā«falseĀ».
  • Tier of the user who triggered 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 needs to have a specific letter casing, which a user's input may affect.

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

Select in the Ā«User input processingĀ» input how you want to transform any user input.

Leave the input blank if 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.

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.