Twitchapon (attempt)

Twitchapon is a program to invoke events in OBS via Twitch channel points. For now it is only sound effects but functionality will be extended (probably).

In retrospective the current setup scheme is amazingly not user-friendly and honestly barely usable :D

I should implement some kind of web-interface for initial setting up and managing the internal state once I muster up the willpower to tinker with stuff on Go again.

Intro

Twitch channel points redemption for OBS is strangely void area - bried search showed me only one free/open-source solution that is made with JS that I’m not really fond of. Rest of results were Reddit threads where people ask “how do I make this” and replies with links to proprietary paid(!) services. I’ve found at least 2 of those services that provide basic OBS integration with Twitch channel points, and they all require some tinkering to work anyway.

Since the feature itself requires tuning by design (because of how twitch made its API and how OBS is built) I thought that simple open-source tool would definitely suffice my needs and maybe even be useful to someone else.

It is an early version, more like public alpha, but it is fully working at its current state and being used by me :3

Requirements and installation

Operating systems: GNU/Linux (amd64/aarch64), Windows (amd64/aarch64), MacOS (amd64/aarch64)

Streaming software: OBS (no idea about Streamlabs OBS)

OBS-Websocket plugin - download and install the latest 4.x.x version for your operating system/obs.

Twitchapon program - Grab binary here:

arch/os Windows GNU/Linux MacOS
AMD64 get get get
AARCH64 get get get

Or you can build it from source easily. You’ll just need Go and that’s it.

After you’ve installed and set up obs-websocket plugin you only need to unzip the archive, fix a config file and launch the program.

Twitch Settings

To be able to subscribe to points redeem events on your channel first you need to obtain an access token for twitch application. It is completely free and can be done with just couple of clicks. Log into Twitch Developer Console and register a new application using the button there or via this link:

register the application

The name can be anything you want (just don’t put “twitch” there, it won’t be created like that).

It is important to set OAuth redirect url to the localhost address with the provided port. You can use default 8081 or some other if you want, just be sure to set that in config file later.

After the application is registered you need to open its settings and create the application secret token - it will be used to receive channel points alerts locally.

create the secret token

Just press “New Secret” button there - and the token will appear just above this button.

tokens

Write down “Client ID” and “Client Secret” values, they will be used in the config file and the application!

The config file is a simple JSON; the sample config is provided in the archive, you just need to edit it and put values from your Twitch account and OBS-Websocket parameters and you’re all set. Don’t forget to change the user_name parameter to the name of your account/twitch channel!

{
	"local_server": "localhost:8081",
	"twitch": {
		"user_name": "bsandro",
		"client_id": "dipwpn8cx945f93qc6lx35piulc2ag",
		"client_secret": "7pif653jbs7b400j1uvwbaz12x0dr9"
	},
	"obs": {
		"host": "localhost",
		"port": "4444",
		"password": "1q2w3e4r5t"
	},
	"sounds": ["Tutturu!", "Selamat Pagi!"]
}

OBS-Websockets Settings

"OBS" block is the config of your obs-websocket plugin:

obs-websockets plugin settings

"Sounds" is a list of your channel rewards that should trigger sounds in OBS.

Sound Alerts Settings

In order to trigger sound effects in OBS you have to add your sound files to it as media sources and name that sources exactly like you’ve named twitch rewards; for now the mapping is 1-to-1.

obs sounds as sources

Launching

Once you’ve filled the config file and launched the OBS you can start the program. It doesn’t display much now, just a terminal window (example for Windows):

windows terminal

You have to copy the URL from that window and paste it into your browser - it will ask for the authorization and then once you’ve approved it redirect to the local server with the info needed for program to work. No private data about your tokens or info is being shared anywhere apart from your own computer at this part - the callback address is the local webserver inside of the twitchapon.

After all the redirects browser should display a success message in case if everything is fine; at this point you’re all set up and ready to use channel rewards as sound triggers. You can close the browser tab as it is no longer used, but don’t close the terminal window because it is the basically the main program container. You can close it once you’re done with the stream for a day.

Next time you want to launch it just open the OBS first and then start the program; you have to copy-paste that address in your browser every time (because that’s how token is being renewed for now); in future some caching mechanism will be implemented but for now approving the app access in browser on every launch is the only way to work with it.

Rationale behind the project

A little side project of mine to handle Twitch channel points redemptions in OBS. The initial idea was to trigger some animations programmatically, so I made a program that subscribes to events on my twitch channel via official API and listens for channel points redemption. There was a separate GUI program that launched some silly animation on magenta “chromakey” background, so it could be added as a source to the OBS. First program was able to trigger events in second one and so it went off.

Good friend of mine suggested that I make it playing sounds or trigger some filters in OBS for example; if playing sounds could be easily implemented in my existing stuff the OBS interaction is completely different thing. After some tinkering with OBS Python scripting I threw the idea away and went with the obs-websocket plugin that allows issuing commands and receiving events from OBS. At first I wanted to make the connection layer from scratch (like I did with twitch api) but since my attention span is of a squirrel I chose a much quicker route with existing library goobs.

Plans and possible feedback

This is a very first version of the program; I hope I’ll be able to add more features, including but not limited to:

If you have any additional feedback or interesting ideas about program functionality or possible features you can email me freely: brian.drosan <at> gmail.com.

Since courts and legal disputes are extremely widespread in 2021 and beyound I’ll just state here that I don’t take responsibility for any damage to your computer or local network or pretty much anything from using this program. It is fully open source with a permissive license so you’re free to check the source code, build or modify it as you please without any limitations.