A simple telegram bot that allows you to auto-book barbers appointments using the Nearcut booking system. This application was primarily developed as a way of auto-booking cancellations when wait times are long for appointments.
The bot will look ahead a specified number of days for available appointments that meet a defined 'availability filter' and then automatically book the appointment. A scheduler can also be set up to continuously look for new/cancelled appointments until one is found that matches the criteria, at which point the scheduler will automatically stop.
Create a new bot by messaging @BotFather with /newbot on Telegram and follow the prompts. Save the TELEGRAM_TOKEN for later use.
You can also customise the bot with a profile picture with
/setuserpicSetting bot commands will also make interacting with the bot must easier:
/mybots- Select your bot
- Edit Bot > Edit Commmands
- Send this:
status - Get bot status showconfig - Displays running configuration editconfig - Edit running configuration run - Start scheduler stop - Stop scheduler book - Try and book an appointment
You will also need to get your TelegramID, this is so only you have access to the bot.
Message @userinfobot /start to get your 'TELEGRAM_ID'
The script can be run on any stand-alone system with node installed or as a Docker container
The script requires TELEGRAM_TOKEN and TELEGRAM_ID as environment variables for the bot to run. Other enviornment variables are set using the /editconfig Telegram bot command or can be added by running the set-store.ts script.
| Environment Variable | Description | Required to Run |
|---|---|---|
TELEGRAM_TOKEN | The Telegram token obtained from BotFather | ✅ |
TELEGRAM_ID | Your Telegram User ID obtained from UserInfoBot | ✅ |
BARBERS_SHOP | The barber shop subdomain (https://<BARBERS_SHOP>.nearcut.com) | ❌ |
BARBER | The name of the barber you want to book with (user * for any barber) | ❌ |
SELECTED_SERVICE | The name of the service you would like to book | ❌ |
NUMBER_OF_DAYS_AHEAD | How many days to look ahead for booking | ❌ |
DATE_FILTER | A JSON object describing what days and times you are free see | ❌ |
SCHEDULE_INTERVAL_MINUTES | How often in minutes the scheduler should check for appointments | ❌ |
EMAIL | Your Nearcut email | ❌ |
PASSWORD | Your Nearcut password | ❌ |
git clone https://github.com/joshlucpoll/nearcut-autobooknpm inpx playwright install if this is the first time using playwright on your systemnode index.tsdocker run --name=nearcut-autobooking -d \
--restart=always \
-e 'TELEGRAM_TOKEN=<telegram_token>' \
-e 'TELEGRAM_ID=<telegram_id>' \
joshlucpoll/nearcut-autobook
DATE_FILTER ObjectThe DATE_FILTER object defines what days and times you are avalible, here is an example configuration:
{
"Monday": true,
"Tuesday": [
["8:00", "8:30"],
["17:00", "19:00"]
],
"Wednesday": false,
"Thursday": [
["8:15", "10:30"],
["13:00", "15:45"],
["17:10", "18:00"]
],
"Friday": true,
"Saturday": true,
"Sunday": false
}
It must contain every day of the week as a key, the value can be either:
true - Free all dayfalse - Not avalible all dayFor the example above:
NOTE
- All times must be in 24h format
- An appointment will match any time period specified
- You can have an unlimited amount of time periods Test and validate your
DATE_FILTERhere
Content type
Image
Digest
sha256:d7f1700b3…
Size
925.8 MB
Last updated
over 1 year ago
docker pull joshlucpoll/nearcut-autobook