Skip to content

zegheim/book-better

Repository files navigation

book-better

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.

Pre-requisites

Installation

  1. git clone this project.

  2. cd into <path-to-project>/book-better/terraform.

  3. Run cp terraform.tfvars.example terraform.tfvars to create a copy of a variable definition file.

  4. Open terraform.tfvars using 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_slug
    • better_activity_slug
    • better_activity_start_time
    • better_activity_end_time
    • better_username
    • better_password
  5. Run terraform init to install all necessary Terraform providers.

  6. Run terraform apply -var-file='terraform.tfvars', and follow the prompts as instructed.

  7. Verify your installation by running aws lambda invoke --function-name=$(terraform output -raw lambda_name) response.json and inspect response.json using your favourite text editor. You should see something like

    {"status": "error", "message": "Could not find any available slot on 2024-09-30."}
    

Configuration

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.

Developing locally

  1. git clone this project.
  2. cd into <path-to-project>/book-better.
  3. Run cp .env.example .env to create a copy of the environment variables configuration. Refer to Configuration for what each individual variables mean (hopefully they're self-explanatory enough!).
  4. Run poetry install to install the book_better project along its dependencies in a virtual environment.
  5. Run poetry run main to run the entrypoint (located at book_better.main:main).

About

Book activities at Better UK

Resources

Stars

Watchers

Forks