Connecting Heroku Webhooks with Discord Connecting Heroku Webhooks with Discord heroku heroku

Connecting Heroku Webhooks with Discord


Heroku's webhook format is not compatible with Discord so you can't just put a Discord webhook URL into Heroku. You need a middle-man server to receive events from Heroku, and construct and send corresponding messages to Discord.


Without being able to see your code and the request structure you are using it will be hard to determine where the issue is coming from exactly, but one thing you might what to check is how you are sending the JSON payload to the Discord webhook URL.

Discord does not seem to accept the request unless you specify that the body of the payload is JSON. I discovered this because of an application I am working on currently. I know this answer is coming significantly after the fact, but it might help someone else down the line!


Found this JS code, should work (change params variable and where it says webhook to your webhook url)

let x = new XMLHttpRequest();x.open("POST", `<webhook link>`);x.setRequestHeader('Content-type', 'application/json');let params = {    username: "Webhook Bot",    content: "<message content as a string>"}x.send(JSON.stringify(params));

i should mention that to mention a channel instead of #channel-name you'll have to use <#channelid>, for example <#1234567890> instead of #foo-bar

(this is my first post, sorry if it's a bit bad)