How to add the !song command to the chat bot

Hi. I want to add the !song command to the chat bot I wrote. I found a video but did it using
This video :

I wonder if Spotify has such an API? I wrote a chat bot with tmi.js and node.js.

I’m open to advice.

If Spotify has an API the best place to check would be with Spotify, not here as Twitch can’t provide documentation or support for something that has nothing to do with them.

I’m writing here because many bots have this feature. Maybe you are using it in your own chatbot or investigating. I searched the internet before writing here and then decided to open up a topic.

You have to use the spotify API, and setup an auth to generate a token, and setup a refresh of the token. The tokens have a very short life span… an hour or something.

May also want to peek at the endpoint: Web API Reference | Spotify for Developers

I’m looking here now thank you.

This does the job.

Thank you :slight_smile: I will try…

I get the song with the request from the site. But when I add the !song command in the form of writing the error part. Do you have any suggestions about this?


request({url: 'İ NUMBER’S, json: true}, function(err, res, json) {
if (err) {
throw err;

client.on(‘message’, async (channel, userstate, message, self) => {

// Don't reply to messages from self or without the "!" as the first char
if (self || message[0] !== '!') {

// Run the !song command
	  // Output items
	  Console.log("Çalan Şarkı :  ",json);
	}, function(err) {
	  console.log('Şuan Şarkı çalmıyor..', err);

I have no idea where you are trying to run this, but the API works just fine. Check your chatbot documentation or the API-sites documentation on how to add it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.