This guide covers deploying the Telegram Expense Tracker bot to Railway.app.
- GitHub account
- Railway account (sign up at railway.app)
- Your bot token and Google credentials ready
- Initialize git (if not already done):
git init
git add .
git commit -m "Initial commit"- 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- Go to railway.app and sign in
- Click "New Project"
- Select "Deploy from GitHub repo"
- Choose your expense-tracker repository
- Railway will automatically detect it's a Python project
In the Railway dashboard, go to your project → Variables tab and add:
TELEGRAM_BOT_TOKEN=your_bot_token_here
AUTHORIZED_USER_ID=your_telegram_user_id
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).
DATA_FILE_PATH=data.json
- Railway will automatically deploy after you add the variables
- Check the deployment logs to ensure it starts successfully
- Look for: "🤖 Starting Telegram Expense Tracker Bot..."
- Open Telegram and find your bot
- Send
/startto see if it responds - Try creating an expense:
/e 10 test Food
- Check Railway logs for errors
- Verify
TELEGRAM_BOT_TOKENis correct - Ensure the bot is running (check Railway dashboard)
- Verify
GOOGLE_CREDENTIALSis 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
- Verify
AUTHORIZED_USER_IDmatches your Telegram user ID - Get your ID by messaging @userinfobot on Telegram
To deploy updates:
git add .
git commit -m "Your update message"
git pushRailway will automatically redeploy.
- View logs in Railway dashboard → Deployments → View Logs
- Check bot status in Railway dashboard
- Monitor your Google Sheet for synced expenses
Railway offers:
- $5 free credit per month
- This bot typically uses ~$2-3/month
- Upgrade to Hobby plan ($5/month) if needed
Similar process:
- Sign up at render.com
- Create new "Background Worker"
- Connect GitHub repository
- Add environment variables
- Deploy
If you encounter issues:
- Check Railway logs for error messages
- Verify all environment variables are set correctly
- Test locally first with
python main.py