Skip to content

benincasantonio/gemini-ai-telegram-bot

Repository files navigation

Gemini Telegram BOT

Description

This project is a chatbot application that uses Google's Generative AI (Gemini) to generate responses. It is built with Python and uses Flask for the web server. The chatbot can be interacted with via a Telegram bot.

Installation

  1. Set up the Telegram bot using the BotFather on Telegram
  2. Deploy on vercel with just a click Deploy with Vercel

Environment Variables

The following environment variables are required for the application to run:

Variable Description Default Value
GEMINI_API_KEY Your Gemini API key None
GEMINI_MODEL_NAME The Gemini model name gemini-2.5-flash
TELEGRAM_BOT_TOKEN Your Telegram Bot token None
OWM_API_KEY Your Open Weather Map API Key None
ENABLE_SECURE_WEBHOOK_TOKEN Enable validation of a secure token passed to the Telegram API webhook to prevent unauthorized access. Allowed values are 'True' or 'False'. True
TELEGRAM_WEBHOOK_SECRET A secure token used to validate incoming requests to the Telegram API webhook. None
MAX_HISTORY_MESSAGES Maximum number of chat messages to include in context when sending to Gemini. Limits history to prevent context overflow. 50

Database Migrations

This project uses Alembic for database migrations. Commands:

# Check current migration status
alembic current

# Apply all pending migrations
alembic upgrade head

# Create a new migration (after changing models)
alembic revision --autogenerate -m "description of changes"

# Rollback one migration
alembic downgrade -1

Note: Set SQLALCHEMY_DATABASE_URI environment variable before running migrations.

Project Progress

This section tracks the progress of the project. The following features are planned or have been implemented:

  • Implement Gemini model
  • Implement a basic plugin
  • Implement DateTimePlugin
  • Implement gemini multimodal api, to recognize images and text
  • Chat history mode
  • Implement other plugins (e.g. weather, stock, etc.)
  • Setup Continuous Delivery
  • Implement Secure Token Validation for Telegram Webhook Requests | Issue #2
  • Make it work in telegram groups | Issue #1

Contributing

Contributions are welcome! Feel free to open issues or submit PRs to help improve the project.

About

This project is a Python-based Telegram chatbot that uses Google's Generative AI (Gemini) for responses. It utilizes Flask for the web server and Vercel Functions for serverless computing. The bot can be interacted with via Telegram and includes a plugin system for extending its functionality.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors