This application serves as a webhook that posts a message in a specified Discord channel whenever certain actions are executed in Heroku (e.g., build initiated, application deployed, etc.). Essentially, it is middleman between a Discord bot and a Heroku webhook. It's built using Koa, a lightweight framework for Node.js.
Currently, it only supports notifications in a single Discord channel.
- Navigate to the Discord Developer Portal.
- Select the New Application button. Enter a unique name, then select the Create button.
- Once you create an application on the Discord Developer Portal, obtain the Application ID from the General Information page.
- Using a web browser, navigate to
https://discord.com/api/oauth2/authorize?scope=bot&permissions=536870912&client_id=<APPLICATION_ID>
- Select the server where the notifications should be posted, then select the Continue button.
- Ensure the Manage Webhooks option is selected on the subsequent screen, then select the Authorize button.
Create .env
file containing the following variables:
(Optional) Specify a name for the bot sending the message. If not specified, defaults to "Heroku Notifier"
(Optional) Specify a static message to use. If not specified, defaults to "APP build STATUS initiated by EMAIL"
The Discord bot's token
- Navigate Discord Developer Portal.
- Select the application under My Applications.
- Select Bot from the sidebar.
- Select the Add Bot button. Then select the Yes, do it! button.
- Under Build-A-Bot, under Token, select the Copy button.
The ID of the Discord channel in which to post the messages. Can be found by referencing the channel's URL using the browser-based version of Discord.
This key is used by Heroku to sign requests and is generated by Heroku when a webhook is created. See the Heroku Documentation for more details. The bridge will check all requests using this shared secret.
- In the Heroku dashboard, open the app for which to receive messages.
- Select More -> View webhooks.
- Select the Create Webhook button.
- Enter:
- Webhook Name (optional): How the webhook will be referenced in the control panel
- Payload URL (https): The URL where the bridge is hosted
- Secret (optional): A random string that will be used to sign requests; automatically generated if not specified
- Select the Event Types to subscribe. Then select the Add Webhook button.
- The secret will be displayed on the subsequent screen. (Note that this will be the only time it will be displayed.)
Only one secret is supported, so if you would like to receive messages for multiple Heroku applications, you can specify the same secret when creating the webhook for each application.
npm run build
npm run start