App to monitor the nearest available appointment at migri every 10 minutes, and email the user with the available appointment details.
You create monitoring requests:
Every 10 minutes, the app will scrape the migri booking page in the background:
- How to run
- How to run tests and other dev tools
- Problem - Why do I need this?
- Solution
- App's basic flow
- Development methodologies
- Some thoughts
-
Install the Chrome Driver which the project uses. Save the absolute path to wherever you install it.
-
Clone this repository then go to the root directory
appointment-monitor/. -
Run
pipenv installto get all the project's requirements from Pipfile. To runpipenv, you need to have it installed on your machine. -
Run
pipenv shellto activate your virtual environment. -
Create a
.envfile in the root directory to store environment variables. -
Obtain a secret key from MiniWebTool. Save it so you can add it to the
.envfile (as shown below). -
Create an email account from which you want to receive notification emails. Better have a separate one from your personal email. This way, you can relax its security settings as you wish and let it be accessible by external apps.
-
Add other environment variables to your
.envfile, as shown below, so that it eventually looks like this:DRIVER_PATH="/absolute/path/to/chromedriver" BOOKING_SITE_URL="https://migri.vihta.com/public/migri/#/reservation" SECRET_KEY="secret_key_you_obtained_from_MiniWebTool" DEBUG=on FROM_EMAIL="address_of_email_from_which_you_want_to_receive_notification_emails" FROM_PASSWORD="password_of_that_account" -
At the root directory, run
python manage.py migrate.
From now on, all you need to do is go to the root directory of the project, then:
- Activate your virtual environment by running
pipenv shell. - Run the periodic task by running
python manage.py crontab add. - Start the application by running
python manage.py runserver. - Access the application on
http://127.0.0.1:8000/application/. - Enjoy! 🎉
To run the tests and use other dev-packages for various purposes like test coverage or flake8 reports, you need to run pipenv install --dev.
- Tests: run command
pytestin the project root. - Test coverage report: run
pytest --cov=application application/testsin the project root. - Flake8 reports: run
flake8in the project root. - Mypy for type checking: run
mypy applicationin the project root.
There was a time in my life in which I needed to keep on checking the appointment booking system in order to find a time slot for each of my residence permit and my citizenship applications. Both required different appointment types that I had to search for. It got time-consuming (and mentally taxing) when the appointments were scarce, and the calendar was showing no appointments, except for in far-away cities.
Build a bot to do the checking for me. The bot uses:
- Selenium: to do the scraping and checking for available appointments.
- Django: to run server that takes monitoring requests containing the search parameters and email of the recipient.
- Cron: to run the task of checking the available appointments periodically.
MonitoringRequest objects instantiated and stored in DB.
Every 10 mins, do appointment monitoring (main task):
- Get all monitoring_request objects.
- Search for available appointments based on the attributes of each monitor.
- Email with the availability.
For a more detailed technical walkthrough, click here.
- Agile: Kanban. Check out the project's kanban board.
- Documentation-driven development (DDD, for the love of acronyms).
- Test-driven Development (TDD).
Advantages
- In addition to the main advantage of not having to manually do the search: The app can set multiple monitoring requests of different types, such as residence permit and citizenship, and different emails to send to.
Limitations
- This app does not do the booking, and this is by design. Letting the bot do the actual booking is both out of scope and adds legal complexity.
- This is limited to the migri appointment page (vihta). Changes to rendered page might result in system not working. It would be better if there is an API to get all appointment data. The scraping depends on the structure of the output html on the appointment booking page.
Future improvements
- For the user experience:
- Stop the notifications. Right now, you pull the plug 🔌: i.e. stop the server, Later: delete monitoring requests or unsubscribe.
- Nice-to-haves:
- Show the past monitors or current monitors in progress.
- Show more than one available appointment at a time for options.
Legal
- This is under MIT License. It is intended for personal use, mostly for fun (and ease of mind) purposes. When you use it, do not book multiple appointments and try to sell them, because that is illegal.

