Build Airbnb check out reminder with Node.js and Puppeteer

Gompro
3 min readFeb 6, 2019

** UPDATED: 2019. 03. 04 **

Instructions below is not up to date. If you’re looking for updated getting started guide then you should look at README#Getting Started under Github repo.

About six months ago, I became a host of Airbnb. And one of the most irritating thing I found was Airbnb does not support for automated (scheduled) message sending. So I wondered what could be the best way to automate this tedious task — sending check out reminder message to guests on time (AM 07:40).

I already had an experience on web automation with Python using Selenium. But I wanted to give Node.js and Puppeteer a try. And now I think it’s good time to share my project to public.

Getting Started

If you want to run this project on your computer, you should have Node.js installed.

Install Node.js: https://nodejs.org/en/

And of course, you should have Airbnb account (either using Google or email, not Facebook — I didn’t make a script for Facebook login yet)

First of all, clone this repository.

git clone https://github.com/leejh3224/airbnb-checkout-reminder.git

And install pm2 , Node process manager to manage your Node server. And install Typescript / Tslint (optional)

npm install pm2 typescript -g# optional
npm install tslint -g

Finally make .env file to store your credentials (email/password)

# inside project root directory
touch .env
# .env
email=blahblah@gmail.com
password=blahblah

And you’re good to go. Now start your server with:

pm2 start npm -- start # this starts your server using npm start

You can check your app’s status via pm2 list .

│ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem    │ user        │ watching │
├──────────┼────┼─────────┼──────┼─────┼────────┼─────────┼────────┼─────┼────────┼─────────────┼──────────┤
│ npm │ 0 │ 0.33.11 │ fork │ 511 │ online │ 0 │ 2h │ 0% │ 0 B │ leejunhyung │ disabled │

Caveat

  1. You must change predefined check in/out message in lib/getMessage.ts .

2. You should also change logic inside lib/needsCheckInOrOut.ts . It uses regex to check whether the guest is checking in or out today.

3. You can change time/time-zone setting inside index.ts to match your needs.

Misc.

  1. It’s almost impossible to log into Google/Airbnb account on remote machine.

You may wonder why I don’t use cloud services like Google App Engine or AWS EC2. But the thing is you have to pass google’s Verify It’s You to log into your account since you don’t have previous login history on remote machine. And I couldn’t find any workaround for this.

2. You’ll be prompted to answer RECAPCHA when you turn on headless option.

You may want to run this script with headless chrome but you should know you’ll be prompted to answer RECAPCHA if you switch to headless chrome. So best possible way to bypass RECAPCHA is to turn off headless mode.

# index.ts
const browser = await puppeteer.launch({
headless: false, # bypass RECAPCHA
...

3. Auto start your Node server on boot

In case you forget to turn on your server on reboot, PM2 provides useful command to run your server as Daemon.

4. How do I manage login session?

Puppeteer doesn’t save user login data by default. However you can make it preserve your last login session by passing userDataDir option.

const browser = await puppeteer.launch({...// reuse user profile sessionuserDataDir: './userData',})

5. I want to change time/time zone. How can I do this?

This project uses node-cron so you can find further information on here.

# index.tscron.schedule('40 7 * * *', # 07 40 AM  async () => {    try {
...
{timezone: 'Asia/Seoul', # you can set timezone like this},

6. This script doesn’t work when my computer sleeps

If you’re using macOS then you can wake up your computer via schedule.

--

--

Gompro

Has experience in Node.js | React.js | Redux | Typescript | Android