Telegram Gemini Bot
A telegram bot which answers to messages with Gemini API.
- You can reply to messages for keeping the context of your conversation:
- You can also upload photos with a caption as a prompt:
- Generated text will be received part by part with streaming support:

Prerequisites
Configurations
Create a configuration file:
$ cp config.json.sample config.json
$ $EDITOR config.json
and set your values:
{
"google_generative_model": "gemini-3.1-pro-preview",
"google_generative_model_for_image_generation": "gemini-3-pro-image-preview",
"google_generative_model_for_video_generation": "veo-3.1-generate-preview",
"google_generative_model_for_speech_generation": "gemini-2.5-flash-preview-tts",
"allowed_telegram_users": ["user1", "user2"],
"db_filepath": null,
"answer_timeout_seconds": 180,
"verbose": false,
"telegram_bot_token": "123456:abcdefghijklmnop-QRSTUVWXYZ7890",
"google_ai_api_key": "ABCDEFGHIJK1234567890"
}
You can get appropriate model names from here.
If db_filepath is given, all prompts and their responses will be logged to the SQLite3 file.
Using Infisical
You can use Infisical for saving & retrieving your bot token and api key:
{
"google_generative_model": "gemini-3.1-pro-preview",
"google_generative_model_for_image_generation": "gemini-3-pro-image-preview",
"google_generative_model_for_video_generation": "veo-3.1-generate-preview",
"google_generative_model_for_speech_generation": "gemini-2.5-flash-preview-tts",
"allowed_telegram_users": ["user1", "user2"],
"db_filepath": null,
"answer_timeout_seconds": 180,
"verbose": false,
"infisical": {
"client_id": "012345-abcdefg-987654321",
"client_secret": "aAbBcCdDeEfFgG0123456789xyzwXYZW",
"project_id": "012345abcdefg",
"environment": "dev",
"secret_type": "shared",
"telegram_bot_token_key_path": "/path/to/your/KEY_TO_TELEGRAM_BOT_TOKEN",
"google_ai_api_key_key_path": "/path/to/your/KEY_TO_GOOGLE_AI_API_KEY"
}
}
Build
$ go build
Run
Run the built binary with the config file's path:
$ ./telegram-gemini-bot path-to/config.json
Run as a systemd service
Create a systemd service file:
[Unit]
Description=Telegram Gemini Bot
After=syslog.target
After=network.target
[Service]
Type=simple
User=ubuntu
Group=ubuntu
WorkingDirectory=/dir/to/telegram-gemini-bot
ExecStart=/dir/to/telegram-gemini-bot/telegram-gemini-bot /path/to/config.json
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
and systemctl enable|start|restart|stop the service.
Commands
/image <PROMPT> for image generation.
/video <PROMPT> for video generation.
/speech <PROMPT> for speech generation.
/google <PROMPT> for generation with grounding (Google Search).
/stats for various statistics of this bot.
/help for help message.
Todos / Known Issues
- Handle markdown texts gracefully.