Help with Webhooks

Hey, I’m currently working on a service to forward Twitch webhooks to discord. I am encountering several issues though.

The main issue is with webhook creation. The documentation page is not entirely clear on how to setup the callback url, so I’ll explain what I have tried. I have sent the request to twitch’s servers with the correct topic, mode, and callback. On the callback server I have it setup where if it recieves a GET request from twitch, it will respond with the hub.challenge sent in the url query string along with a 202 accepted status code. Here is the core code I’m using for that. Language is Node.js using Express.

if(request.query['hub.challenge'] != null){
    response.status(202).send(request.query['hub.challenge']);
}

From there I get nothing else from Twitch, not sure if I am supposed to. I then test the event which triggers the webhook, gaining a follower in this case. I gain a follower and nothing is sent to the callback server. No post request, nothing. Have I done something wrong?

Thanks for the help in advance.

You don’t send a 202 you send a 200, with the bodt as the hub_challenge GET argument (which I’ve been receiving as hub_challenge rather than hub.challenge. So cross check what you are receiving

The response to the (cURL) subscribe request is a 202 Created.

You must only send 200’s to Twitch.

So:

if(request.query['hub.challenge'] != null){
    response.send(request.query['hub.challenge']);
}

Even with the 200 request the webhook isn’t functioning. Does twitch send a confirmation showing that the webhook was created? If so where does this get sent.

It’s challenge, not hub.challenge. Where did you get hub.challenge from?

Docs are wrong.

Hub.challenge is what twitch is sending

If you replied with the challenge correctly. Then all should be good

Looks like you are using node. So make sure you bound a POST route on express of that is what you are using. I can post my sample code when I’m back at a pc.

Looks like they changed it since release. The mock up I made to test webhooks on Tuesday used only challenge and no longer works but did at the time.

1 Like

Well the literal parameters sent to the server are:

{ 'hub.challenge': 'redacted',
  'hub.lease_seconds': '0',
  'hub.mode': 'subscribe',
  'hub.topic': 'topic_url' }

Oh!

Your Webhook expired the moment it was created.

Set it to a non zero positive to make the webhook last for a period of time (the max is 10 days 864000)

1 Like

Thanks so much! Did not know I this was a thing. Worked now :grinning:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.