You have just read a blog post written by Jason McIntosh.
Thank you kindly for your time and attention today.
I wanted to set up one of my social Slacks such that a notification would automatically appear in the main chat-channel when I, or another of our circle of friends, started broadcasting gameplay on Twitch. I got it working, more or less! You’ll need a certain level of nerdcraft to follow the path I found, including access to a Linux server and knowledge of crontasks.
I could find no official integrations between Twitch and Slack, but I easily found multiple pages of GitHub projects claiming to do fill this need. Most have no documentation. Of those that do, the only one that I could get to work is Jeremy Bernard’s twitch-to-slack, albeit after some struggling. It requires a more recent version of Node.js than Debian — my preferred Linux distribution — makes easily available through its standard package manager. Happily, a friend taught me about NodeSource, which offers some Node-upgrading incantations specifically for Debian, and that got me on-track quite nicely.
Configuring the program presented a bit of a puzzle as well, but I managed to piece together the disparate advice from several of these half-baked projects’ README.md files into this list of steps:
When filling out this registration form, I found, one needn’t have a meaningful value for the “Redirect URI”; twitch-to-slack performs no authorization magic. I just wrote my personal URL in there, to no ill effect. And I selected “Chat Bot” as my application category.
At any rate, Twitch will reward you with a “Client Secret” string, which you’ll need, so copy it somewhere.
Add an “incoming webhook” to your Slack. Follow the prompts via the Slack website, and land eventually on a screen that provides you with a Webhook URL. You’ll need to copy this down, too.
Per the twitch-to-slack documentation, copy the file config.json.example to config.json.
Paste the Twitch Client Secret you generated earlier, in double quotes, as the value for this new JSON file’s “clientToken” key.
Paste the Slack Webhook URL you generated earlier, in double quotes, as the value for the “slackHookUrl” key.
Set the file’s “chaineID” value to a JSON-formatted array of Twitch user IDs you wish to track. For example,
["jmacdotorg", "asmadigames" ].
Set “notificationOnStatusChange” to
And that should do it. You can test the script on the command line by running
nodejs index.js while inside the twitch-to-slack directory. You can temporarily set the “chaineID” array to contain the ID of any currently-online Twitch channel — if all else is well, then a notification should show up within the Slack channel you specified back when you set up the webhook. (While testing, you may wish to aim the webhook to a private channel that only you can see, so as not to spam other Slack users.)
Once you feel satisfied that the script works as intended, set up a crontask to run the script regularly. I have my server simply run
nodejs /path/to/twitch-to-slack/index.js every minute. It does get confused every so often, mailing me a random dirty-data error a few times per week, but not so much I feel bothered to try fixing it. It otherwise works just as it should.
Good luck, and happy broadcast-notifying!
To share a response that links to this page from somewhere else on the web, paste its URL here.