Skip to content

Instantly share code, notes, and snippets.

@SGTGunner
Created June 26, 2020 00:34
Show Gist options
  • Star 45 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save SGTGunner/50d6a3cc0d489cf779f77695ba3e22ea to your computer and use it in GitHub Desktop.
Save SGTGunner/50d6a3cc0d489cf779f77695ba3e22ea to your computer and use it in GitHub Desktop.

Github to Discord Webhook Tutorial

In this tutorial I'll show you how to create a Github webhook that will post updates from your Github account to a channel in Discord. The steps are simple so follow along!

Create a Webhook in a Discord Channel

First you need to create a webhook in a text channel. We're assuming you have both Manage Channel and Manage Webhooks permissions!

  • Go in a channel properties (Alternatively, Server Settings, Webhooks works too)
  • Click Webhooks
  • Click Create Webhook
  • Type in a name (this is for local reference, it's overriden by the incoming hook data)
  • Copy the Webhook URL (you can use the Copy button)
  • Click Save

WebhookDiscord

Note: Do NOT give the Webhook URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe!

Create the Github Webhook

In order to do this you need to be the owner of the github repository. Even Collaborators cannot access settings.

  • Click on Settings
  • Click on Webhooks
  • Click on Add Webhook
  • The Payload URL is the webhook URL with /github added to the end.
  • Leave Secret blank, change the Content-Type to application/json
  • Select what type of events you want
  • Click Add Webhook

WebhookGithub

Note: The "test" payload will not show anything in your channel. That is normal. You will need to actually take an action in order to show any activity. However, make sure the test payload has a green checkmark, and the response is 204.

Troubleshooting

I'm getting a 400 error!

Make sure to add /github at the end of the webhook URL.

Can I change the Avatar and Name of the hook's messages?

No, Github controls that part, so they're choosing the name and Avatar.

I'm not getting the events I want (or too many)

Under Which events would you like to trigger this webhook?, select Let me select individual events.

Check the events you'd like to receive. There are a lot of them.

Enjoy!

That's it. That's all you had to do. Now go code!

@qssns
Copy link

qssns commented Apr 24, 2022

400 error, also with the /github

@Animan8000
Copy link

Is there a way or alternative to get Release notifications (with patch notes) from a public repository you don't own, in a Discord channel?

@ivelin
Copy link

ivelin commented Aug 18, 2022

Great gist! Thank you!

@DinnerMonster
Copy link

You will still get the 400 error until you actually create an event ie: open/close an issue etc (I know a little misleading). After that, it should be cleared up ✔️

image

@kid1194
Copy link

kid1194 commented Apr 1, 2023

Thanks a lot buddy..

@AsfandSoomro
Copy link

Thanks brother

@mhawkinsbasis
Copy link

Thank you for this, really appreciate it!

@Joblyn
Copy link

Joblyn commented Jun 28, 2023

Very helpful. Thanks @SGTGunner

@faceless613
Copy link

Thanks

@jonaspleyer
Copy link

Worked like a charm for me. Thank you!

@vycos-zen
Copy link

thank you

@sunnamed434
Copy link

sunnamed434 commented Sep 16, 2023

If you get 400/404, simply make a Commit in this repo and if you see a message in discord webhook then its fine

@Sp1d3rmanj0e
Copy link

Thank you!

@Coding4Hours
Copy link

Thank you!

@Milkywayrules
Copy link

ah, thank you, dude!

@MintedLizardGutz
Copy link

nvm how do I insert the webhook to discord

@jhelmink
Copy link

You might want to update this to note that only certain events will come through (despite getting a 204 response)

discord/discord-api-docs#6203 (comment)

No plans to add to the list :(

@MadalitsoNyemba
Copy link

Works great👌

@zobbo
Copy link

zobbo commented Mar 9, 2024

Followed and worked first time. Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment