A love story written
​in JavaScript

@soyguijarro

👨‍💻  Web engineer from Madrid

💼  Dev tools at Undefined Labs

🤩  JavaScript, React, Web APIs

🗣️  International tech speaker

🎓  Adalab bootcamp volunteer

💖  Community and inclusion

Ramón
Guijarro

@soyguijarro

Problems with
dating apps

The hard facts

Most popular dating apps
are driven by pictures

I estimate that photos drive 90% of the action in online dating

Christian Rudder, co-founder of OkCupid

We don't really know
what we want

The kind of partner people said they were looking for didn't match up with the kind of partner they were actually interested in

Amarnath Thombre, chief of algorithms for Match.com

Women are much more selective than men

Men are nearly three times as likely to swipe "like" (in 46% of cases) than women (14%)

Jessica Carbino, Tinder's in-house dating and relationship expert

Less good-looking people have much lower chances

A man of average attractiveness can only expect to be liked by slightly less than 1% of females
(1 like for every 115 females).

Tinder Experiments II

Usual consequences

The way apps work
promotes superficiality

The liking process
can feel arbitrary

You are pushed to
come back every day

Automation
to the rescue

The like everybody strategy

Waste of time

Waste of opportunity

How to automate it

Swipe based on preferences

Automatic and unattended

A bit more selective

How the
tool works

Origins and evolution

Browser automation
script with Puppeteer

Network requests
with developer tools

Unofficial online documentation

Command-line tool
with Node.js

Internal architecture

Config

Logging

Network

UI

User input

Config

Network

UI

Logging

User input

(async function() {
  title('Swipr');

  try {
    let config = readConfig();
    if (shouldRunSetup) {
      config = await runSetup(config);
    }
    
    await runMain(config);
  } catch (err) {
    error(`Error: ${err.message}`);
  }
})();
async function runMain(config) {
  try {
    // Do stuff
  } catch (err) {
    switch (err) {
      case apiErrors.NO_MATCH_RECOMMENDATIONS:
        throw Error('No match recommendations');
      case apiErrors.OUT_OF_LIKES:
        throw Error('You are out of likes');
      default:
        throw err;
    }
  }
}

Config

Network

UI

Logging

User input

const title = str => {
  console.info(chalk.bold.magenta('❤️'), str);
};

const success = str => {
  console.info(chalk.bold.green('✔️'), str);
};

const error = str => {
  console.error(chalk.bold.red('❌'), str);
};

Config

Logging

Network

UI

User input

const readConfig = key => (getConfig())[key];

const writeConfig = (key, value) => {
  setConfig({ ...getConfig(), [key]: value });
};

const isConfigValid = (key, value) => {
  switch (key) {
    case 'phoneNumber':
      return Number.isInteger(value);
    default:
      return false;
  }
};

Config

Logging

UI

User input

Network

async function createApi(refreshToken) {
  return Object.keys(methods).reduce((api, method) => {
    api[method] = async function(...args) {
      const callMethod = () => methods[method](apiToken, ...args);

      try {
        return callMethod();
      } catch (err) {
        if (err.statusCode === UNAUTHORIZED_CODE) {
          await refreshApiToken(refreshToken);
          return callMethod();
        }
        throw err;
      }
    };
    return api;
  }, {});
}
async function likeUser(apiToken, userId) {
  const response = await get('/like/' + userId, {
    apiToken
  });

  if (!response.likes_remaining) {
    throw errors.OUT_OF_LIKES;
  }
  return response;
}

Third-party ecosystem

chalk

apisauce

dotenv

inquirer

conf

oclif

gluegun

ncc

pkg

Ideas for
the future

Add more liking criteria

Support other dating apps

Turn into a website or app

Some final
thoughts

We had fun and learned stuff

But did we solve the problem?

53 matches, including 38 people he began talking [...] 9 agreed to a date, 3 stood him up, and 2 cancelled, leaving him with
4 actual dates.

Kari Paul, MarketWatch

@soyguijarro

Thank you!

Made with Slides.com