Serverless bot to book activities on Better UK. Powered by AWS Lambda and Amazon EventBridge Scheduler.
Currently only supports booking via benefits (e.g. the discontinued Better Racquets membership which allows you to book one court per day for free), but the code can be easily extended to also support booking via credits.
- Terraform (tested on v.1.9.5)
- Amazon Web Services (AWS) Free Tier account with CLI v2 installed.
- Better UK with an appropriate membership type (e.g. Better Racquets).
- Poetry (tested on v1.7.1)
-
git clonethis project. -
cdinto<path-to-project>/book-better/terraform. -
Run
cp terraform.tfvars.example terraform.tfvarsto create a copy of a variable definition file. -
Open
terraform.tfvarsusing your favourite text editor, and modify the configuration as required. Configuration for more information. In general, you should only need to modify the following variables:better_venue_slugbetter_activity_slugbetter_activity_start_timebetter_activity_end_timebetter_usernamebetter_password
-
Run
terraform initto install all necessary Terraform providers. -
Run
terraform apply -var-file='terraform.tfvars', and follow the prompts as instructed. -
Verify your installation by running
aws lambda invoke --function-name=$(terraform output -raw lambda_name) response.jsonand inspectresponse.jsonusing your favourite text editor. You should see something like{"status": "error", "message": "Could not find any available slot on 2024-09-30."}
The defaults provided in terraform.tfvars.example will try and book next Monday's 8PM - 8.40PM Badminton 40min slot at Leytonstone Leisure Centre every Monday at 10PM UK time. If this is not what you want, adjust the following configuration variables accordingly:
| Variable | Description |
|---|---|
better_venue_slug |
The venue slug where you want to book an activity for. You can find it by visiting Better UK, selecting your venue, and looking at the URL bar. |
better_activity_slug |
The activity slug. You can find it by going to the booking page for the activity that you want and looking at the URL bar. |
better_activity_start_time |
The start time of the slot that you want to book in HHMM format (e.g. 2120 for 9.20PM). |
better_activity_end_time |
The end time of the slot that you want to book in HHMM format (e.g. 2120 for 9.20PM). |
eventbridge_scheduler_schedule_expression |
When the bot should book the desired activity slot. See Cron-based schedules for more information on the accepted syntax. |
git clonethis project.cdinto<path-to-project>/book-better.- Run
cp .env.example .envto create a copy of the environment variables configuration. Refer to Configuration for what each individual variables mean (hopefully they're self-explanatory enough!). - Run
poetry installto install thebook_betterproject along its dependencies in a virtual environment. - Run
poetry run mainto run the entrypoint (located atbook_better.main:main).