Creating Nightbot Chat Alerts & Using Them To Encourage Repeat Twitch Prime Subscriptions

Nightbot is one of the most popular chat bots out there for Twitch, as you can freely and easily do a number of things that more complex bots or premium bots do. One thing that can be tricky though is getting your bot to thank users for subscribing as by default this feature doesn’t exist. By thanking a user you can also drop a link to your Streamer Sub Alert page encouraging them to add to their calendar their renewal date, which will hopefully lead to more subscriptions. Nightbot chat alerts right now don’t exist.

However, there are ways around this. You’ll need a Nightbot account, a Streamlabs account (both free), your Streamer Sub Alert Link (you can create it here) and a text editor for copy & pasting a few numbers.

1. Create a Nightbot Application for your Alert

To begin with, you need to create a Nightbot Application. This is a beta feature but you can do so by going to the Applications Page within Nightbot. Click “New App”. Give it a name & leave the redirect URL’s box empty. When created click on the “Edit” put (it’s pencil shaped) and click on the “New Secret” button that appears. Write down both the Client ID & Client Secret and save it somewhere.

Nightbot Chat Alert 1 - Create an App in Nightbox

2. Generate an Access Token

Now you need to generate an Access Token. This is done from your computer, there’s a few ways to do this but the quickest way to do this is using curl. Open the Command Line (Windows) or Terminal (Mac) and copy the following line of code.

curl -X POST "" -d "client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&grant_type=client_credentials&scope=channel_send"

Replace <CLIENT_ID> with the Client ID you created on the previous step and <CLIENT_SECRET> with the Client Secret you created in the previous step. When done you should get something back that has two curly brackets around it.

Nightbot Chat Alert Step 2 - Create an Access & Refresh Token using CURL

You can see it above, but it should look something like this.


Copy the <ACCESS_TOKEN> and <REFRESH_TOKEN> to a safe space.

Please note: The Access Token expires after every 30 days, and the refresh token expires after 60 days. so you’ll have to refresh tokens. Skip to the end of the article on how to do this.

3. Create the Chat Alert in Streamlabs to speak to Nightbot

You need an Alert Box within Streamlabs for this to work. Log into Streamlabs and navigate to the Alert Box Page, and then the subscriptions tab. Click on “Enable Custom HTML/JS” and paste in the following code in the JS window.

    url: "",
    method: "POST",
    headers: {
        "Authorization":"Bearer <ACCESS_TOKEN>",
    data: "message={name} is now subscribing! Thank you! @{name} to be notified when you need to resubscribe click here to get a calendar reminder <STREAMER_SUB_ALERT_ADD_TO_CALENDAR_URL>"

As before, replace <ACCESS_TOKEN> with the access token generated in step 2 and <STREAMER_SUB_ALERT_ADD_TO_CALENDAR_URL> with your Streamer Sub Alert URL.

Nightbot Chat Alert Step 3 - Paste JavaScript into the Subscription Alert Box.

To explain what happens here, when the alert box loads, a message is sent to your Nightbox to post a message. The messages is what is located in the speech marks next to data (so you can modify this) and is secure because of your access token.

To make sure it’s working, you can keep the HTML window of your widget open (or start a broadcast) and then click “Test Subscription”. Nightbot will fire a message, and that will be your test to make sure everything is working!

Nightbot Chat Alert Step 4 - Test

4. Refresh your Access Token Every 31-60 days

Your Access token expires every 30 days, whereas the refresh token expires every 60 days. Your bot will stop working after 30 days for these alerts, so it’s a good idea to set a calendar reminder to refresh them.

To do this, return to Terminal or the Command Line and type the following out:-

curl -X POST "" -d "client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&grant_type=refresh_token&refresh_token=<REFRESH_TOKEN>"

Replace <CLIENT_ID> and <CLIENT_SECRET> with the Client ID & Secret created in Step 1, and <REFRESH_TOKEN> with the Refresh token you’ve writen down in step 2. You’ll be sent a new Access token and a Refresh Token. Write these in your document, and also replace the Access Token in Step 3.

And that’s it! It’s a bit more work, but it allows you to keep using your favourite bot on your Twitch Channel. Have you created your own Nightbot Chat Alerts? Let me know how you get on!