Set up a !dadjoke Command in Streamer Bot

Written By :

Category :

Streamer Bot

Posted On :

Share This :

This’ll be nice and easy. Let’s set up a !dadjoke command and action in streamer bot. Your chat will be able to type !dadjoke and your bot will spit out a random groaner. This should only take a few minutes and we’ll learn how to consume a text-based API endpoint with streamer bot.

Use the iCanHasDadJoke API

The easiest way to do this command in Streamer Bot is to use an external API that provides the random result. If you can find or make an API endpoint that returns a simple text result it’s the easiest and we can use a simple Fetch URL subaction. (documentation for fetch URL here)

To generate a random dad joke, we’re using the icanhazdadjoke.com API, specifically with the /nightbot parameter at the end which forces it to return text only. (it’s not a typo, you want to use /nightbot at the end to force it to return text only, even if you’re using streamer bot or streamelements or whatever)

Ultimately, the URL that you should copy and paste is: https://icanhazdadjoke.com/nightbot

Setting Up the Action

I’ll assume you already have Streamer Bot installed and connected to your channel and stuff. If you haven’t, go see this guide on how to set up streamer bot. Then come back here when you’re done.

Now In the Action tab of Streamer Bot, right-click and choose Add. Name the action how you want and you can leave everything else at default unless you wish to assign this action to a particular group or queue.



In the action, you’ll want to start by adding a Fetch Url subaction by right clicking and choosing Core > Network > Fetch URL



In the dialog for the Fetch Url subaction, put https://icanhazdadjoke.com/nightbot as the Url. Put dadJoke in as the variable name (or whatever you want, just adjust the instructions in the next step). This will allow us to use %dadJoke% in our output.



Click ok to save, and add a “Send Message To Channel” subaction by right-clicking, and choosing Twitch -> Chat -> Send Message to Channel.



In the popup for this subaction just put the %dadJoke% variable and press OK. (If you used a different variable in the previous step, use that here instead.


Setting Up the Command

Now our action is all set up and we just need to set up the command. Keeping our action selected, right-click in the top right panel of the actions tab labeled “Triggers”. Right click to add a new trigger and choose Core > Commands > Command Triggered.



In the dialog that pops up, click the “Create Command” button and we’ll get a form to create our !dadjoke command. On the form use !dadjoke as the name as well as the command, and ensure that the enabled checkbox is checked, then click OK.



The small popup for the trigger should still be present and this new command should be selected. Now you can just click Ok, and we’re done!



Users should now be able to type !dadjoke in chat and the bot will spit out the result of the API.


Import Code

U0JBRR+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fjC5P8irPuUy6PArNp3Q4h63Zu8qWUB1I2XF5cNq+2PsVy1YiIu/xVSKnued/D+g0XfjLaTnSluLei644U/29s3Lf3Gtvo+VCgAA


Don’t want to build it yourself? Here’s an Import code you can use. Click Import at the top of Streamer Bot and paste this code in the Import String Field.

You should see 1 action and 1 command ready to import so go ahead and click import. Make sure you go to the commands tab and enable the command by right-clicking on it and choosing enabled.



Enjoy, and feel free to send this along to anyone else who might like to set up a !dadjoke command in streamer bot.

Video Tutoral