Attempting to understand how twitch webhooks work with discord webhooks?

I’ve been reading over this stuff for the past couple of days and I have to admit I’m a bit lost so forgive me if the question has been asked before. To start with, I am working on a discord bot (written with node and discordjs) and am attempting to setup functionality where when a streamer goes live, they get a notification in a channel - now I know twitch has webhooks that help with this, but I’m not entirely sure I understand how this all works under the hood.

I’m assuming I would need a web server of some sort (or maybe a library like node-fetch?) that handles communications between twitch and discord - but I don’t know how webhooks relate to this. I’m not asking for specific hand-holding here, I just would like to know in broad strokes, if I have say, a twitch user’s client ID, how would I go from that, to them getting a live notification in a discord server? I apologize if this isn’t the best way of describing the topic, I’m just not really familiar with web-related programming so a lot of this is going over my head.

Twitch Webhooks will send a notification to your server when an event on the topic you’ve subscribed to happens.

Simply put, you would:

  1. Send a subscribe request to Twitch for a particular topic, eg Stream Changed would be used for streams going online/offline/changing.
  2. Twitch sends a verification GET request to your webserver, to ensure it’s accessible and indeed wants that subscription. Your web server has to respond with the challenge that Twitch sent.
  3. Once you finish the verify step, Twitch will POST notifications to your web server when that topic triggers.
  4. Your web server, on receiving that notification, would need to respond to Twitch a 2xx status code, then from the notification your server would work out if the stream went online, offline, or if it was just a change of title/game. If it was going live, your server would then send whatever message you want to the Discord Webhook.

The 2 systems, Twitch Webhooks and Discord Webhooks, are 2 separate things, it’s up to your server to create the subscriptions it needs and maintain them with Twitch, and then to format the message however you like for Discord, there’s no interconnection between the two directly.

1 Like

Ah, I think that makes things a bit clearer now, thanks!