DEV Community

Isak Solheim
Isak Solheim

Posted on • Originally published at blog.isak.me

Moving to Berlin using ChatGPT and JavaScript

TLDR: I built a bot that automatically sends personalized, context-aware messages to every new listing posted on wg-gesucht.de. The bot found me a flat in Berlin!

If you’re interested in the technical side of this project, feel free to dig through the code while reading this article!

Intro

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 parse it with Regex to see if the email contains links to any wg-geuscht listings.

Navigating the listing

For each listing, I spawn a chromium browser using Playwright, an end-to-end testing framework. This allows me to navigate the website just as one would when interacting with it themselves. I sign into my account, take 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!
`;
Enter fullscreen mode Exit fullscreen mode

The generated message was sent alongside a couple of images of myself.

The result

The time it took from a listing went live to my bot had sent 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! 😄
Enter fullscreen mode Exit fullscreen mode

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 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.

Top comments (0)