https://github.com/darckfast/notify-bot
Middleware function on vercel to forward webhooks from Patreon to Discord
https://github.com/darckfast/notify-bot
discord go patreon vercel
Last synced: 7 months ago
JSON representation
Middleware function on vercel to forward webhooks from Patreon to Discord
- Host: GitHub
- URL: https://github.com/darckfast/notify-bot
- Owner: Darckfast
- Created: 2024-11-13T06:14:29.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-10T12:47:07.000Z (7 months ago)
- Last Synced: 2025-03-10T12:50:43.401Z (7 months ago)
- Topics: discord, go, patreon, vercel
- Language: Go
- Homepage: https://notify-bot-chi.vercel.app
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Patreon -> Discord notify bot
This middleware functions allows you to use the Patreon's webhooks to feed notification into discord, and it doesn't require write/read permissions to Patreon's API
## Setting up webhooks on Patreon
Unfortunaly at the moment Patreon does not let you create the webhook with the required triggers on their portal page, so you must do throught their API### Create a Client on Patreon
Navigate to https://www.patreon.com/portal and go to "My Clients"
Click on "Create Client"

Fill the form, the information on the form itself is not relevant nor matters for what we need to do
Click on your client and copy the "Client Secret", this will be used to authenticate our request, for you to create the proper webhook
**CAREFUL, THIS TOKEN SHOULD NOT BE POSTED ANYWHERE, AS IT ALLOW ANYONE TO REQUEST PATREON API IN YOUR BEHALF, AND IT CAN ACCESS SENTISIVE INFORMATION ABOUT YOU AND YOUR MEMBERS**

### Setting up the webhook on Patreon
Before creating the webhook, we first need the know the "campaign" id of your page, to do that, make this GET request, using the token you copy from the previous step**Request**
```http
GET /api/oauth2/v2/campaigns HTTP/1.1
User-Agent: insomnia/10.1.1
Authorization: Bearer creator_access_token
Host: www.patreon.com
```**Response**
```json
{
"data": [
{
"attributes": {},
"id": "13117666",
"type": "campaign"
}
],
"meta": {
"pagination": {
"cursors": {
"next": null
},
"total": 1
}
}
}
```Before creating the webhook, the function need to have the ENV `API_KEY` set with any string, this will be included as query param when setting up the webhook on Patreon
To create the webhook, make the following request, the `uri` field must be a full URL to your function, including the query param `ak` which should be the same as the ENV `API_KEY`
**Request**
```http
POST /api/oauth2/v2/webhooks HTTP/1.1
Content-Type: application/json
Authorization: Bearer creator_access_token
Host: www.patreon.com
Content-Length: 311{
"data": {
"type": "webhook",
"attributes": {
"triggers": ["posts:publish"],
"uri": "https://your_url_to_this_function?ak=api_key_configured_on_this_function"
},
"relationships": {
"campaign": {
"data": {"type": "campaign", "id": "13117666"}
}
}
}
}
```**Response**
```json
{
"data": {
"attributes": {
"last_attempted_at": null,
"num_consecutive_times_failed": 0,
"paused": false,
"secret": "webhook_secret",
"triggers": [
"posts:publish"
],
"uri": "https://your_url_to_this_function?ak=api_key_configured_on_this_function"
},
"id": "756209",
"type": "webhook"
},
"links": {
"self": "https://www.patreon.com/api/oauth2/v2/webhooks/756209"
}
}
```From the response, you must set the ENV `PATREON_WEBHOOK_SECRET` with the `secret` value, this will be used to validate Patreon's webhook payload, and guarantee that Patreon is the source of the request
### Setting up Discord webhook
On "Integrations > Webhooks", create a new Webhook, set the channel, name, image and copy the webhook URL
The ENV `DISCORD_WEBHOOK` must be set with the URL copied above
### Customizing the message
The following ENVs must be set to customize the alert message and embed information```bash
ALERT_MESSAGE="Check out new post on Patreon"BANNER_IMAGE_URL=url_to_image
THUMBNAIL_IMAGE_URL=url_to_image
PATREON_NAME=Your patreon name
PATREON_URL=https://www.patreon.com/c/your_patreon
PATREON_ICON_URL=url_to_image
```