Making the thank the follower for following

Asked Feb 18, 2024·2 replies·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

As the topic says, i cant make it work.

Im using this script in JS in streamlabs:

$.ajax({
url: "https://api.nightbot.tv/1/channel/send",
method: "POST",
headers: {
"Authorization":"Bearer """,
},
data: "message={name} is now following!"
});

And inside "" next to bearer i should have my nightbot token but i cant seem to find it. I tried with client secret and client id but doesnt work.

Can someone help me before i go crazy?

Thanks in advance.

2 replies

Hey @Olive Flamingo!

Remove the extra quotes ", according to the documentation, and usual API workflow, it should be:
"Authorization": "Bearer ACCESS_TOKEN"

You need to generate the ACCESS TOKEN with your CLIENT_SECRET and CLIENT_ID.
If it's unclear, I have a guide where I explain how to get the ACCESS_TOKEN, even though it's for another use of the API, it may help.

I seriously recommend reading through the entire OAuth 2 section of the API documentation.

The code you provided here uses JQuery, I don't know if Streamlabs supports it, I doubt it. Have you tried generating that code with an AI? I recommend against it, the AI aren't aware of the context your code will be used in, therefore it won't work most of the time.

By the way, this should interest you:
/t/nightbot-alerts-in-chat/1534589171388125265

Okey thanks alot, will try it out!