Get Telegram notifications about the most recent doctor's appointments on doctolib.de. 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.
ℹ️ 🔒 🔧 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.
The setup follows these instructions. For simplicity I tried to compress it even more in the following step by step list:
-
Create a Telegram bot using @botfather (FAQ).
- Username:
@<NAME>Bot
- Disable
Allow Groups?
- Turn on
Group Privacy
The bot
Token
will be available once the bot is created.
Write it down, you'll need it in a later step. - Username:
-
Create a private group. Overyone in the group will see the messages from your bot.
- Group name:
MyPrivateGroup
- Group Type:
private
Warning: Do not edit special permissions for users as this will convert the group into a supergroup which does not work with this code.
- Group name:
-
Temporarily enable
Allow Groups?
on the bot. -
Add the bot to the group.
-
Immediately deactivate
Allow Groups?
on the bot after adding it to the group. -
Post a test message into the group via the app or the browser (required to get the next step running). Start message with
/
in order for the bot to be able to read it (Group Privacy
is turned on by default). -
Retrieve group
chat_id
by visitinghttps://api.telegram.org/bot<BOT_TOKEN>/getUpdates
in the browser.
Write it down, you'll need it in a later step. -
Let the bot send a test message via visiting
https://api.telegram.org/bot<BOT_TOKEN>/sendMessage?chat_id=<GROUP_CHAT_ID>&text=Test
in the browser.
The message should appear in the group chat.
- 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 Telegram bot Token
in this constant.
Type str
.
Default ''
.
Paste your Telegram chat_id
in this constant.
Type str
.
Default ''
.
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
.