I need help to create my first chatbot

Hello,

I am trying to create my first chatbot with the twitch example in the guide: Example Chatbot Guide | Twitch Developers

I have filed the constants on the top of the code but I do not find the BOT_USER_ID . When I use the API and get users infos, I only have my user ID.

How can I find this ID?

Thank you for your help!

That would indicate you’ve authenticated as your user. If you want to use a different account to act as a bot you need to create that account on Twitch with the name you want, and while logged in as that account go through the OAuth process to get an access token for that user, and you can use Get Users to get the user id of that account you’ve created to be a bot.

Hello, thank you! Is it possible to act as a bot with my main account? Or do I necessary have to create another account to create the bot ? To understand if create another account is a choice or required.

yes but it will send messages as you.

Any account can “operate like a bot” (coz thats just a script using a users token) it just has to authentiate the relevant scopes to a clientID

So whoever is authenticated to the ClientID and thus have the oAuth token for is whom you can send messages as.

So you can use your account ID as the BOT_USER_ID if you want, but it is recommended to use a second account. Much easier to moderate/temp ban your bot account if it goes haywire than trying to ban yourself from your own channel

Thank you! For now I will try with my main account and create another account after.

I used the example code without use the first line (import WebSocket from ‘ws’:wink: ) because I have put the code on my server because sockets are enabled.

I see “Validated token” so it seems that the auth works, but I have an error : “Uncaught (in promise) TypeError: websocketClient.on is not a function”

Is it because I deleted the first line? When I use it I have an error.

I don’t know so much about sockets :wink: