Inspired by mayrs/der-bergdoktorbot-a-doctolib-doctors-appointment-telegram-notifier
Get notifications about the most recent doctor's appointments on doctolib.de via mqtt payload. This script will notify you every minute as long as appointments exist within the next UPCOMING_DAYS
. The next appointment outside of that threshold is additionally notified on the hour.
If you, like me, want to be notified about new appointments via notifications in homeassistant, take a look at the automation provided in this fork.
ℹ️ 🔒 🔧 Remember that this static script does not know anything about your doctolib details behind your login so you have to monitor and adjust it on the go to reduce unwanted notifications.
On your server running the script:
pip install gmqtt
- Insert the bot
Token
into the constantTELEGRAM_BOT_TOKEN
- Insert the
chat_id
into the constantTELEGRAM_CHAT_ID
You do not have to be signed in to doctolib.de in order to do do the next steps that will get your search query.
- Navigate to doctolib.de
- Use the search mask to find a doctor you want to make an appointment at and hit
search
- Once your on the doctor's landing page open your browsers
dev tools
, select theNetwork
tab and leave it open for the next steps - Click on
TERMIN BUCHEN
- Answer the following questions in the appointment wizard until you reach the date overview that says
Wählen Sie das Datum für den Termin
- Copy the URL of the browser into the constant
BOOKING_URL
- Select the filter
Fetch/XHR
within theNetwork
tab in order to make it easier to find the correct request URL - Look for a request to
availabilities.json…
and click on it in the list of requests - Copy the value of the
Request URL
in the detail view and paste it into the constantAVAILABILITIES_URL
First of all the script has to be made executable.
chmod +x /path/to/notifyDoctolibDoctorsAppointment.py
Next, schedule the script execution via the cron.
crontab -e
E.g. this cron entry will run it every minute from 7:00 AM to 23:59 PM.
* 7-23 * * * python /path/to/notifyDoctolibDoctorsAppointment.py
Adjust those constants to get the most out of your notifications.
Paste your doctolib booking URL in this constant. The Telegram message will contain a link to this page in case of available appointments.
Type str
.
Default https://www.doctolib.de/
.
Paste the complete URL to the Doctolib availabilities.json
(including parameters) in this constant.
Type str
.
Default ''
.
If you have multiple instances of the script running and share the same Telegram channel it's a good idea to make notifications allocatable.
Type str|None
.
Default None
.
Provide a link to your Termin verschieben
page behind your login to navigate fastest to the booking page and move the appointment in one go. When set, an extra link will be sent in addition to the BOOKING_URL
link.
Type str|None
.
Default None
.
Paste the number of days from today, that you want to monitor appointments for, in this constant.
ℹ️ Doctolib has a limit of 15 days.
Type int
.
Default 15
.
If you already have an appointment within the next UPCOMING_DAYS
you can set this date in this constant so that the script only notifies for earlier dates.
E.g.
MAX_DATETIME_IN_FUTURE = datetime(2023, 6, 16, 12, 0, 0)
Type datetime
.
Default 15 days in the future
.
Whether to notify late appointments (outside of the UPCOMING_DAYS
range) hourly.
Type bool
.
Default False
.