AstroGPT is a learning-scale Telegram bot based LLM reasoning.
Behind the scenes the bot
- Parses free-form text with an LLM (via LangChain) to recognize intent and extract dates, zodiac signs, etc.
- Runs actions such as
get_daily_forecast
,update_user_data
, orunsubscribe
. - Generates replies with short forecasts, situational advice, or astrology jokes.
- Stores state in Postgres so users can pick up the conversation later.
- Python
- Telegram Bot API (webhook mode)
- LangChain + OpenAI GPT-4o (can swap to any chat-completion model)
- Postgres + SQLAlchemy + Alembic
- Docker / docker-compose for local dev
- Deployment to GCP Cloud Run
To use this code, you need to obtain a Telegram Bot Token. Follow these steps to get your token:
- Open Telegram and search for the BotFather.
- Start a chat with the BotFather and use the
/start
command. - Use the
/newbot
command to create a new bot. - Follow the prompts to name your bot and choose a username for it.
- Once the bot is created, the BotFather will provide you with a bot token. This token is required to authenticate your bot with the Telegram API.
Important: Keep your bot token secure and do not share it publicly.
Once you have your bot token, you can use it in the code to interact with the Telegram API.
- Ensure you have Python and Alembic installed.
- Add
DATABASE_URL
to your terminal session or export it as an environment variable:export DATABASE_URL=<your_postgres_connection_string>
- Verify the connection by running:
This should display the current migration state. If it fails, check your
alembic current
DATABASE_URL
and ensure the Postgres server is running. - Run the following command to apply migrations:
alembic upgrade head
-
Set up environment variables:
- Create a file named
dev.env
in the root directory. - Add the following variables to
dev.env
:DATABASE_URL=<your_postgres_connection_string> TG_BOT_TOKEN=<your_telegram_bot_token> OPEN_AI_KEY=<your_openai_api_key>
- Create a file named
-
Run database migrations
-
Start the bot locally:
- Use Docker Compose to start the services:
docker-compose up
- Use Docker Compose to start the services:
-
Set up environment variables:
- Create a file named
prod.cloudrun.env.yaml
. - Add the following variables to
prod.cloudrun.env.yaml
:DATABASE_URL: <your_postgres_connection_string> TG_BOT_TOKEN: <your_telegram_bot_token> OPEN_AI_KEY: <your_openai_api_key>
- Create a file named
-
Run database migrations
-
Deploy to Cloud Run:
- Use the provided deployment script:
./deploy.sh
- Use the provided deployment script:
- Human-like ChatBot conversation UI
- Use LLM-reasoning instead rigid
/commands
. - Minimal business logic - new skills are just new “actions” plus a prompt tweak.
Pull requests and feedback are welcome. Have fun, and may your planetary transits be favourable! 🪐