This is an example project for how to connect patreon-api.ts
with Cloudflare Workers to send Discord messages on a new post.
- Clone / copy
/examples/cloudflare-webhook/
locally - Install dependencies:
npm install
- Get the webhook secret from Patreon by registering a new webhook using the Patreon API.
- Update the secrets on Cloudlfare to use your webhook
- Deploy the worker with
npm run deploy
to your Cloudflare account - Create a post on Patreon and view the Discord message!
- Create a new file
secrets.json
in./src/
and defineCLIENT_ID
,CLIENT_SECRET
,CAMPAIGN_ID
,WEBHOOK_URI
,ACCESS_TOKEN
,REFRESH_TOKEN
. - Run
src/generate.ts
(may need to run withts-node
ortsc
) - Copy the secret
Update the following secrets using wrangler
:
DISCORD_WEBHOOK_URL
: the url of the Discord webhook. You can click theCopy url
button in the Discord client to get the urlPATREON_WEBHOOK_SECRET
: the webhook secret of your Patreon clients webhook.HTML_MD_KEY
: the key to use for the HTML to Markdown API. If you use a different converter you do not have to specify this secret