This is an old post (from 2015), the current Nightbot beta (basically 2016 and onwards) supports this “out of the box” so this is really not necessary to use anymore.

Nightbot’s song request/AutoDJ allows you to request YouTube songs (and Soundcloud, but YouTube is the most common one) while the streamer uses those requests and plays them during the stream. However, Moobot’s song request functions also allows you to request using a search query (e.g. by searching for the video title). This is a feature I missed with Nightbot, so I setup a little “tool” that allows you request songs (video ID’s/links work too, but currently not properly tested) by using a search query. The search query basically does a normal YouTube search and then it picks the first video after relevance (and thus popularity).

The usage of the command utilizes the alias, customapi urlfetch and query chat variables of Nightbot. Which means it basically uses the query after the command (what the viewer says), puts that into the custom API urlfetch GET link of my “tool”. The tool returns the video ID when passed a valid search query, this video ID is used by Nightbot together with !songrequest. This will request the song in the viewers name, and song requests are still limited to 2 songs per viewer at a time.

Update July 1st 2015: A recent change in Nightbot means that the $(query) variable replaces links with the username of who used the command. This means that you can’t use direct YouTube links or else it will request the wrong song. If you wish to use a specific video, only use the video ID or stick to only using search.

How to use: Create a command using the normal way (this cannot be “!songrequest” or else it overrides the original command and it won’t work), and put this into the “response”: -a !songrequest $(urlfetch$(querystring))

How viewers will use this: Let’s say you created a command called !sq, the viewers will basically just say !sq haddaway what is love, but replacing haddaway what is love with whatever artist/song the viewer wants to request. It should request the first video/song that YouTube returns back, which is sorted by relevance & popularity.

Important note: Nightbot waits a bit (5 seconds) before it sends a song request through, but there’s also a ~1-2 second delay (usually less) for the data (video ID) to be passed to Nightbot. This means that it takes a few seconds before the command goes through.

Not only that, but custom commands have a cooldown between uses and that unfortunately affects this tool. However, it is possible to create multiple commands with the same response and that should help if the viewers use all of them.

Update December 26th 2015: The new Nightbot beta already has a similar built-in function directly in the !songrequest command. If you still wish to use this for some reason, then you will have to modify your command a bit. After the command name (for example: !sq), you have to put: -a=!songrequest $(urlfetch$(querystring))

Adding an example command in chat (as a moderator) would look something like this: !commands add !requestexample -a=!songrequest $(urlfetch$(querystring))

Update July 2018: Streamlabs Chatbot also supports this in their bot (at least the most recent versions of it).

  • Click on the Song Request menu on Streamlabs Chatbot
  • Click the Settings button (the icon) in the top-right.
  • Click one of the $readapi... options under Mode.