Skip to content

Latest commit

 

History

History
133 lines (96 loc) · 3.35 KB

File metadata and controls

133 lines (96 loc) · 3.35 KB

Deployment Guide

This guide covers deploying the Telegram Expense Tracker bot to Railway.app.

Prerequisites

  1. GitHub account
  2. Railway account (sign up at railway.app)
  3. Your bot token and Google credentials ready

Step 1: Prepare Your Repository

  1. Initialize git (if not already done):
git init
git add .
git commit -m "Initial commit"
  1. Create a GitHub repository and push:
git remote add origin https://github.com/yourusername/expense-tracker.git
git branch -M main
git push -u origin main

Step 2: Deploy to Railway

  1. Go to railway.app and sign in
  2. Click "New Project"
  3. Select "Deploy from GitHub repo"
  4. Choose your expense-tracker repository
  5. Railway will automatically detect it's a Python project

Step 3: Configure Environment Variables

In the Railway dashboard, go to your project → Variables tab and add:

Required Variables:

TELEGRAM_BOT_TOKEN=your_bot_token_here
AUTHORIZED_USER_ID=your_telegram_user_id

Google Credentials (choose ONE method):

Method 1: Environment Variable (Recommended for Railway)

GOOGLE_CREDENTIALS={"type":"service_account","project_id":"...","private_key_id":"..."}

Copy the ENTIRE contents of your credentials.json file and paste it as one line.

Method 2: Credentials File

GOOGLE_CREDENTIALS_PATH=credentials.json

Then upload credentials.json to Railway (less secure, not recommended).

Optional Variables:

DATA_FILE_PATH=data.json

Step 4: Deploy

  1. Railway will automatically deploy after you add the variables
  2. Check the deployment logs to ensure it starts successfully
  3. Look for: "🤖 Starting Telegram Expense Tracker Bot..."

Step 5: Test Your Bot

  1. Open Telegram and find your bot
  2. Send /start to see if it responds
  3. Try creating an expense: /e 10 test Food

Troubleshooting

Bot not responding

  • Check Railway logs for errors
  • Verify TELEGRAM_BOT_TOKEN is correct
  • Ensure the bot is running (check Railway dashboard)

Google Sheets sync not working

  • Verify GOOGLE_CREDENTIALS is set correctly (entire JSON on one line)
  • Check that you've shared your Google Sheet with the service account email
  • Use /config <sheet_link> to configure your sheet

"User not authorized" error

  • Verify AUTHORIZED_USER_ID matches your Telegram user ID
  • Get your ID by messaging @userinfobot on Telegram

Updating Your Bot

To deploy updates:

git add .
git commit -m "Your update message"
git push

Railway will automatically redeploy.

Monitoring

  • View logs in Railway dashboard → Deployments → View Logs
  • Check bot status in Railway dashboard
  • Monitor your Google Sheet for synced expenses

Cost

Railway offers:

  • $5 free credit per month
  • This bot typically uses ~$2-3/month
  • Upgrade to Hobby plan ($5/month) if needed

Alternative: Render.com

Similar process:

  1. Sign up at render.com
  2. Create new "Background Worker"
  3. Connect GitHub repository
  4. Add environment variables
  5. Deploy

Support

If you encounter issues:

  1. Check Railway logs for error messages
  2. Verify all environment variables are set correctly
  3. Test locally first with python main.py