I am trying to understand the relationship between a twitch developer app and building a chat bot. My understanding so far is – people build chat bots by creating a new Twitch user, then programmatically communicating with Twitch chat through IRC (often with the TMI library) using that bot account. You don’t need a developer app for this, just a phony user right?
I am also aware that there are Twitch developer apps, and one possible use case is to make a chat bot. But I’m not really seeing how or why. Biggest roadblock for me is: apps don’t have a username… so how are they supposed to chat?
If you can help me understand I would really appreciate it!
Logging into chat is done by using an oauth token with the chat_login scope. Oauth tokens are given to applications, when a user authorizes the application to communicate with Twitch on their behalf, limited by the scopes used in the auth process.
So you need an application to get the chat login token. If you want to do more with the API than just chat, you’ll also need a client ID to use the HTTP API.
Thanks yes but this is showing the ‘use a tool to generate an oauth password’ flow. I am looking for an example which is more like the flows described by @BarryCarlyon and @3ventic
You can get the chat oauth by logging in as your bot account and then logging into https://twitchapps.com/tmi. The password then is the entire string, oauth:oauth_string This website gets the permission for the chat_login scope for the account that requests it.
If you are wanting to get permission from another user, then you will need setup a web page that you register as a callback with Twitch (especially for user facing items). If you are just playing around through your own account, then you can point Twitch to localhost and you will need to setup a webpage that handles the requests back from Twitch.
That is all fairly well documented here:
There are examples using curl from the command line to do what you want.