I am still working on building my bot, and it is currently functioning very well. However, I would like to add some new features, and I’ve hit a roadblock with one of them: the “chatbot” badge. I am currently using a library (TMI.js), but I would like to move away from it and handle everything myself.
The issue isn’t with reading or sending messages—I have that part working—but I’ve noticed that my bot doesn’t display the “chatbot” badge. I’ve tried various authorization methods and approaches, but nothing seems to work.
For context, my bot has its own clientId, token, and refresh_token (obtained via the OAuth flow).
As I understand it, the OAuth flow needs to be authenticated using the streamer’s account—which, if I’m not mistaken, grants the channel:bot permission and ensures proper authentication. The problem is that if I do this, it feels like I’m no longer acting on behalf of my bot, but rather on behalf of the streamer… since the sender_id must correspond to the account that generated the token.
So, my question is: how should I correctly execute the OAuth flow?
For the Send Chat Message endpoint with an App token, you can go through the OAuth process twice, first with the user you wish to send messages as (ie, your bot account) with the user:write:chatand user:bot scopes, and then the channel you wish to send messages in goes through the OAuth process and grants your app the channel:bot scope.
Once those accounts have authed with your app, your app can then use the Client Credentials OAuth flow to get an App token which can then be used on that Send Chat Message endpoint with the broadcaster_id set to the channel you wish to send messages in, and sender_id set to the ID of your bot account.
Things are looking pretty good. I had misunderstood a subtle point, which resulted in me having two applications instead of one.
So, I’ve now consolidated this into a single application, with one token for the user side and another for the broadcast side.
However, I’m running into an issue with two subscriptions: channel.chat.notification and channel.chat.message.
When I attempt to subscribe, I receive a 403 error: message: 'subscription missing proper authorization'.
I’m struggling to see where the problem lies. I have the user:read:chat and user:bot scopes for the bot side, and the channel:bot scope for the broadcast side. Yet, whether I use the bot token, the broadcast token, or an app-access token (obtained via grant_type: 'client_credentials'), it still doesn’t work.
Additionally, when I send a message via the API, the bot is correctly identified as a “Bot,” but it doesn’t appear within the community.
So, if I understand the approach correctly: since I am using the credential flow for the app token, I can no longer use the websocket for this part—instead, according to the documentation, I must use the webhook. Is that right?