As my exchange semester at Technische Universität Berlin approached, I started looking for places to live. Without an existing network in Berlin, I used the website wg-geuscht.de to contact potential flatshares. This was a very repetitive process, and I decided to automate it.
Automate the Boring Stuff With JavaScript
I set up email alerts for all new potential flats in my price range on wg-gesucht.de and used Google Clouds Pub/Sub service with a push subscription to watch for any incoming email to my Gmail inbox.
Once a new email arrives, the service sends a webhook notification to my server.
Parsing the Email
On the server, written in JavaScript with Express, I read the latest email in my Gmail inbox and parsed it with Regex to see if the email contained links to any wg-geuscht listings.
Navigating the Listing
For each listing, I spawned a Chromium browser using Playwright, an end-to-end testing framework. This allowed me to navigate the website just as one would when interacting with it themselves. I signed into my account, took note of the listing description, and hit send message.
Generating a Message Using GPT-3.5 Turbo
The message is generated using GPT-3.5 Turbo with the following prompt:
const prompt = `
Can you spice up the following text: "${starterText}"
The updated text should explain why I would fit in the flatshare with the
following listing text: "${listingText}". Add some emojies as well.
Mention that my semester is from September to March, so a stay for that
perioud would be ideal (but Im always flexible)! And if the listing is
written in German, the answer should be in German as well. And if the listing
says I need to say a specific word, start the whole text with that word!
`;
The generated message was sent alongside a couple of images of myself.
The Result
The time it took from a listing that went live to my bot sending a response was around 10 seconds, making me confident in being the first responder. This was the response that secured me a flat:
Hallo zusammen! 🦄
Das scheint ja eine richtig coole WG zu sein, in die ich perfekt reinpassen würde! 😄
Ich bin Isak und ich glaube, dass ich perfekt in dein WG-Zimmer passen würde! Mein Semester in Berlin geht von September bis März, also wäre ein Aufenthalt für diesen Zeitraum ideal (aber ich bin auch immer flexibel!). Die Lage der Wohnung klingt super, besonders die Nähe zum RAW-Gelände und zum Boxhagener Platz. Und hey, eine Tram-Station direkt vor der Tür ist auch genial! 🚋
Die Wohnung hört sich toll an, mit Balkon, Badewanne und Waschmaschine. Da fühlt man sich doch gleich wie zuhause! Wenn du Interesse hast, würde ich mich freuen, von dir zu hören. 📞
Liebe Grüße und hoffentlich bis bald!
Isak
P.S. Wenn die Anzeige auf Deutsch ist, dann antworte ich auch gerne auf Deutsch. Aber sei gewarnt, mein Deutsch ist manchmal etwas holprig. Ich verstehe nur Bahnhof! 😄
Closing Thoughts
Looking back, I spent more time tinkering with the bot than I would have manually responding to email notifications. But with that being said, I am happy with how this project turned out. I got a lot of good laughs from the silly responses the bot would send, and the frequency of people getting back to me was noticeably increased (most likely because I was their first responder).
I recently tried spinning the bot up again, but since my search in June, captcha verification has been implemented on their site. This may be for the better. For all I know, many of the listings themselves were created using ChatGPT.
This article was originally published by blog.isak.me on Hackernoon.