As a tie-in to my DIY Stream Deck, I wrote a Python script for OBS Studio that allows you to send messages to Twitch chat using OBS’s built-in hotkey system.


The 21.0 update for OBS added support for Python and Lua scripting, using a new scripting console and an extension of the C API. In the words of the developers, scripting allows you to “quickly extend, add features, or automate the program without needing to build a native plugin module.”

Since my non-embedded C++ still needs some work, I decided to try writing this program as a Python script rather than a C++ plugin.

Setting Properties

Via the scripts window, the chat script has access to Qt GUI elements in OBS such as text boxes, lists, and buttons. The user can fill in these fields to customize the script without having to modify any configuration files. With the initial release of the script, these configuration options include:

  • Channel: the channel on Twitch to post messages in
  • User: the username of the user posting messages
  • Oauth: the access key required for authentication to Twitch servers
  • Messages: the custom list of messages that can be sent

These settings are stored with the rest of your OBS settings and are reloaded on startup. There are also two buttons on the bottom of the panel for testing authentication and test sending the first message in the list.

(Note: I wanted the test message button to use the user-selected message in the list, but that property doesn’t appear to be exposed by the API, at least not yet.)

Hotkey Hooking

Each message added to the message list gets its own custom hotkey that can be modified in the OBS settings window. These work like any other hotkey in the program and are saved with their message in the script settings.

The list of messages is extensible, and will add / remove hotkeys as list items are changed. Reordering the message list will also reorder how items appear in the OBS hotkey settings.

Talking to Twitch Chat

Aside from the OBS API functions, the real meat of the script is the code for communicating with Twitch chat itself. Twitch chat is just IRC, so I’m using Python 3’s built-in socket library to handle all of the networking.

After a hotkey has been pressed, the script will open a connection to the Twitch server, authenticate, and then send a message. With version 1.0, this connection is released after a short period to avoid overhead and let repeated messages through without re-authenticating. All messages are rate-limited to the global limit based on the system time, which prevents the user from accidentally receiving a temporary site-wide chat ban for spam.

Any network errors are raised as exceptions if a test button is pressed, but are suppressed if triggered from a hotkey message. This is to alert the user if there is a problem during setup, but otherwise hide issues to avoid interruptions during streaming.

Using the Script

If you’d like to use the script yourself, it’s quite easy. Download the script from GitHub or the OBS resource page and follow the instructions in the README. By far the most difficult part is getting the OBS scripting console to work. You will need to install Python and point OBS to the installation directory. If you load the script and no properties appear, the Python installation / link is not set up correctly.

The script is licensed under GPL v3; it’s free software, so you can use it, modify it, and distribute it so long as you abide by the license.

Although I think it’s obvious, I’ll stress here that this is a 3rd party plugin for OBS. I have no affiliation or endorsement as a developer from either Twitch or OBS.


This was a fun script to write, and it makes me want to see what else I could with OBS scripting / plugins in the future.

I may end up converting this to a C++ plugin at some point, to avoid users having to install and configure Python to use it. But that’s a project for another day.


  1. I searched everywhere for this functionality. Thank you for making this. I plan on trying it out in the next few days. I will be using the Roccat Power Grid (Free) app on an Android phone. I will now be able to press a single button and post links to my YT and Social medias in the Twitch chat. I’m curious what else you would use it for?
  2. Hi, Excuse me for my basic question. I cant get the obs scripts running. I’ve installed Python, then I configure the installation path in obs, but they still do not working. Could you give me an idea about what I need or what Im doint wrong?

    Another question, is possible from a script, to stop and resume the obs screen capturing?


    Emilio Gustavo Ormeño
    1. Double-check that your Python version is correct for your version of OBS. If you have 64-bit OBS you need 64-bit Python, ditto for 32-bit.

      It should be possible to start/stop recording from a script, although I haven’t messed with the OBS API in several months so I couldn’t tell you how off the top of my head. Depending on what you’re doing you might also want to look into the OBS Sockets plugin.

  3. My Python installing path is correct, Python is fully and correct installed on the computer, but the script will not show any properties. They are both 64-bit (I double checked that first). Could the new OBS update be messing with it?


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.