Giter VIP home page Giter VIP logo

webhook-discord's Introduction

Heroku to Discord webhook middleware

Webhooks are a very powerful tool that allows you to send notifications from events in a service (for server webhooks) or receive notifications from events in a service (for client webhooks). For example:
Discord is a client webhook, meaning you can send messages to a channel without even needing a bot. (Discord-webhooks)
Github and Heroku are webhook servers, meaning they will send notifications of certain events. (Github-webhooks) (Heroku-webhooks)

This also means you can 'connect' a webhook server with a webhook client to send notifications, however the data sent by the server can be (and in almost all cases is) different, meaning if you directly connect both it will probably not work. For this you need a middleware, a server that converts the server message into the client format.
Discord has built-in middlewares for Github and a few others, so you don't need any special treatment to connect Github and discord; however for other services, in this case Heroku, this middleware isn't available (or I couldn't find one) so I created my own. This app is just a middle server that converts Heroku webhook events into Discord webhook events, to be notified of Heroku changes directly from Discord. The app is also hosted on Heroku if you want to test it directly.

Usage:

  • Create a discord webhook (from a channel: edit channel->Webhooks->create). You should get a url with this format: https://discordapp.com/api/webhooks/<id>/<key>
  • Now go to Heroku and add the following webhook, changing the two last paths to the ones in your previously created webhook: https://webhook-discord.herokuapp.com/<id>/<key>.

For example, if your Discord webhook was
https://discordapp.com/api/webhooks/123456789012345678/qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfgh
you should write
https://webhook-discord.herokuapp.com/123456789012345678/qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfgh
This will use my deployed server as a middleware (details in 'Sample server'). If you want to deploy your own server check 'Deploy custom server'.

New: If you access the url from your browser, a button will be displayed to send a 'test' message and check if the url is valid. Please note that once configured you don't need to access the browser for anything, Heroku is the one sending the messages.

Sample server

This app is hosted on Heroku, meaning you can follow the steps in 'Usage' to test directly. However note that the app is hosted on a free account, so it may take a few seconds to wake up, and also it may be abused in which case I will turn it off. Also note that although the app doesn't save/record any data (and I promise I will never do it), Heroku might save and keep a log of the petitions, so better not use it for sensible data. The sample server is: https://webhook-discord.herokuapp.com/

Deploy custom server

If you want to deploy your own copy for personal use, just:

  1. Fork the project (or copy/paste it, but forking is nicer and it will automatically comply with the license, otherwise you need to mention me).
  2. Deploy your fork to Heroku or any other web service. The app is ready-to-deploy on Heroku, but it is just a Flask one-file app so other services should be fine.
  3. Use your own url for the webhooks. In the second step of 'Usage' simply use your deployment url instead of mine.

Contributions

Although this project was made for personal use, if you want to send pull requests or make/suggest changes I'll be happy to discuss them. The conversion was manually made so it may not have all type of events into consideration.

Disclaimer

This app is not affiliated with nor endorsed by Heroku nor Discord. The names, logos and services belongs to their respective owners.

webhook-discord's People

Contributors

dependabot[bot] avatar smug246 avatar trianguloy avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.