Skip to content

epetousis/up-webhook-ingester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UpBank Webhook Ingester

An AWS Lambda function to ingest UpBank payloads and forwards them to Discord, so that my friends can laugh at me

Feel free to use this yourself or reuse the type definitions.

A screenshot of the bot in action in Discord

Note Looking for the original TypeScript version? Check out the js-legacy branch!.

Important clarification

This was hacked together in like a day or two for fun with near-zero knowledge of Rust (and lots of potential panic points that need to be fixed), please don't judge too hard.

How to install

Warning: this uses AWS Lambda.

  1. Install cargo-lambda.
  2. Clone this repo.
  3. Run cargo lambda build --release to build a release version (as we want those extra optimisations for our production server - we don't need debug information.)
  4. Run cargo lambda deploy --enable-function-url. You may need to add --region [aws region] --profile [profile] to the end of the deploy script in package.json if you use the AWS CLI with more than one account or region.
  5. POST to https://api.up.com.au/api/v1/webhooks (you can use a tool like Insomnia or Postman) with a Bearer Auth header using your Personal Access Token as a value (e.g. Authorization: Bearer up:demo:uFHtxi6JnFtqrx1o), and with this body:
{
	"data": {
		"attributes": {
			"url": "https://my-shitty-host.com/?name={name}"
		}
	}
}

Where url is the endpoint for your Lambda function, as returned by cargo. The name parameter should be changed to the name value that is in the env.conf.

The response from this request will provide a bunch of data relating to the webhook resource that was created. Save the value of data.attributes.secretKey, as we will need this later.

  1. You'll need to create a webhook in Discord for each channel you want the bot to post in, In your desired Discord channel, create a webhook by going to Edit Channel -> Integrations -> View Webhooks, and clicking New Webhook, and then save the URL. You can have multiple webhooks in the discord_webhooks array inside your config, and these webhooks can be from multiple different servers.

  2. Create a env.conf file in the root code directory and replace the comments with your appropriate values:

USER_DETAILS=[{
    "discord_webhooks": ["/* Webhook URLs for channel specific webhooks */"],
    "name": "/* The name to use for Discord messages */",
    "auth_token": "/* Up Bank API Personal Token */",
    "webhook_secret": "/* Up Bank Webhook Secret retrieved from the API's `data.attributes.secretKey` prop upon webhook creation */"
}]
  1. Run cargo lambda deploy again (with your relevant flags).
  2. Test with a webhook ping. If you don't see a ping, check the CloudWatch logs on AWS.
  3. Lose all self esteem

About

Ingests Up Bank webhooks and forwards them to Discord

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published