Twitch Integration in Roblox

Introduction


A couple of days ago, I saw someone post in #platform-feedback:engine-features a feature request for Twitch integration. This made me remember an old hacky project of mine that simulated this type of thing and was based on the Twitch integration of Clustertruck. I dug up my old code - and surprise! it kinda works! (Which is shocking since it was from what I would consider the beginnings of my career)


Video



How It Works


  1. When the user joins the game, they are prompted to enter their channel name. This is their twitch.tv/<channelname>.

  2. The server then fetches the channel and a bot gets added to their stream watching for the verification command. The code is sent to the client and the user copy and pastes the command into their chat. Only the broadcaster can use the command - this allows us to verify that the user has access to the broadcaster’s account. Clustertruck (which was what inspired this project) requires the user to input their API key. Whether or not that is allowed by Roblox’s rules, I am doubtful so I believe this is a good workaround.

  3. The user clicks verify again to send one last request to the external server to make sure everything went through. The channel then gets added to a list in the game.

  4. Every ~30 seconds, the game chooses a random stream for voting. It will prompt the user with 3 randomly selected options that the users vote for. They only have to say the number (i.e. 1, 2, etc). In the video, you see me as the broadcaster vote for the option. This was just for testing purposes - in an actual setting you would not be able to vote for an option as that would be cheaty. The twitch bot then watches chat and collects the votes - only 1 vote per viewer.

  5. After the votes are collected, the external server sorts them and sends them to the game server. The game server then fires a function accordingly.


I am in no way an expert at the Twitch API or external server communication. This method of Twitch Integration is very hacky and requires an external server to work. AFAIK there is no official way to do this straight from Roblox. This is just a proof of concept and it technically works, however, I doubt that at a large scale it would run efficiently.

Test it for yourself here:

10 Likes

I think you should make “Twitch simulator”.

Really cool! If games integrated this into their code, watching ROBLOX streams would be much more interesting! :ok_hand:

I’m curious as to what you mean by “Twitch simulator”. It sounds like an interesting concept, but how do you suppose it would work with this system?

1 Like

I would love to see games integrating with Twitch/Youtube! I really do think that it is more fun when viewers participate.

Perhaps it might be worth going through and updating/securing my code and releasing it as open source :thinking:
In it’s current state I think my explanation is probably better than my actual code as the current code follows many bad practices and is very unsecure.

1 Like

This is really cool! If only Roblox had more than 50 viewers at a time on Twitch this would be pretty nice.

please bro please release it please