Horoscope Bot

In mid 2023, I had the bright idea to create a telegram bot. The not-so-bright part of the idea was that I had no idea what bot I wanted to create. While scouring through the internet, I stumbled upon an article on medium describing how to create a horoscope bot. I decided to follow this as a starting point.

After playing with the bot for a while, I found some issues / pain points:

  1. The bot would randomly return readings for other horoscopes
  2. I would have to manually type in the horoscope and date that I would like to obtain the reading for, which is highly unfriendly for the user
A quick look of the bot features

Wrong Readings Returned

I looked into the code to see where the readings were obtained. I quickly found that it was connected to a backend API for horoscope readings. As I did not intend to build a backend, I decided to try using a webscraper to obtain the readings directly from existing horoscope websites. I did a quick google search for websites displaying horoscope readings, and came across horoscope.com. Bingo.


Unfriendly inputs

The Telegram bot API provides several methods to register user input. Integrating these into the bot would provide a more user-friendly experience, as the user would not have to type down their horoscope and date every time. This also prevents errors due to typos. I went with the InlineKeyboardButton.


Current Features

I deployed the updated and improved version of the app in November 2023. The user starts the app with a '/start' menu button. The user will be prompted to select their horoscope, and the message will be reflected with the chosen horoscope. A new message will appear to prompt the user to select a date, and the message will also be updated with this information. Then, the reading for the chosen horoscope and date will be sent for the user to view.


Improvements

Since deploying the bot, I have had numerous friends come up to me with suggestions. These include:

  1. The ability to check compatibility between different horoscopes
  2. Readings on certain topics (health, wealth etc.), rather than a generalized one.

Other than that, my bot only supports readings for the day before, the current day, and the next day. An improvement would be to allow the user to pick a 'Custom Date' option, and then to manually key in the date they are interested in. Additionally, the date for this bot follows the american timing (I believe), thus selecting the 'Today' option would only return readings for the current day if it is past 3-4pm (since Singapore is in GMT+8). An additional feature would be to employ a try-except block in the event the reading cannot be fetched from horoscope.com, to let the user know that they should try again (currently nothing is returned if the web scraper fails).


Tech Stack

Python, python-telegram-bot, Beautiful Soup. Deployed with Fly.io