A Cypress bot to book restaurants on Tock and report attempts to Slack.
Ensure your computer has node
and npm
installed. You can use nodenv if you don't. Once installed,
use npm install
to pull down the dependencies for the project. Before you can run the bot, you'll also need to configure it. Read on to the next section for
how to do that.
If you don't already have an account on Tock, make one. Once you've created your account, take note of your credentials as you'll need them in a bit. Next, navigate to your account billing page and ensure you have a credit card on file. Take note of the CVV number for the card.
Next go find the restaurant you'd like to book, and grab the path for the booking page. In the example above, that would be:
/otiumgrillandgreens/experience/330688/reservation
Last but not least, create an incoming webhook for your Slack account. This will send notifications from the cypress run to the slack room of your choice.
With all this in-hand, you can create your configuration file. There's an example in the repo you can start with,
though you'll need to create a real one named cypress.env.json
in the project root. Using the example information we just took down, let's
create one:
echo '
{
"email": "{{ the email address used for Tock }}",
"password": "{{ the password used for Tock }}",
"cvv": {{ the CVV code for the card saved on Tock }},
"bookingPage": "/otiumgrillandgreens/experience/330688/reservation",
"partySize": 4,
"desiredTimeSlots": [ "11:00 AM" ],
"excludedDays": [ "2023-03-29" ],
"slackWebhookUrl": "https://hooks.slack.com/services/00000000000/00000000000/00000000000000000000000",
"slackUsername": "Otium Grill and Greens",
"slackIconEmoji": ":meat_on_bone:",
"dryRun": true
}
' > cypress.env.json
The fields are all pretty self explanatory, though you can use dryRun
to avoid actually booking if you just want to test the whole thing out.
A lot of restaurants set their next month's schedule on a particular day and time. You can use github actions to
schedule jobs on a cron and try to snag a spot as things
open up. The example in this repo attempts bookings every 15 minutes. You can fork the repo and try it out yourself.
Just be sure to set a secret CYPRESS_ENV
with the above JSON so that the action will run.