Horoscope Bot

While scouring through the internet in late-2023, I stumbled upon an article on medium describing how to create a horoscope bot. After recreating and 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

Sounds like an improvement is due!

A quick look of the improved bot features

Wrong Readings Returned

I found that the bot was connected to a free backend API for horoscope readings. I decided to try using a webscraper to obtain the readings directly from existing horoscope websites for greater accuracy in results. I did a quick google search for websites displaying horoscope readings, and came across horoscope.com.


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