Telegram AI Chatbot with Google & Gemini Integration
Simple overview
- This workflow connects a Telegram bot to Google Gemini (PaLM API) so the bot can reply to users with AI-generated answers.
- Useful for FAQs, assistants, classroom helpers, or bots that fetch document content to answer questions.
Who is this for
- Educators, creators, developers, and support teams who want a low-code Telegram chatbot powered by Gemini.
What it does (quick)
- Listens for messages sent to your Telegram bot.
- Sends incoming text to Google Gemini and receives a generated reply.
- Optionally fetches content from Google Docs or an external API to enrich replies.
- Sends the reply back to the original Telegram user.
- Processes messages in batches and adds short delays to avoid spamming.
Quick setup (5 steps)
- Create a Telegram bot with @BotFather and copy the bot token.
- Add Telegram credentials to n8n (Telegram node).
- Get a Google Gemini (PaLM) API key and add it to n8n.
- (Optional) Connect Google Docs OAuth2 if you want the bot to read documents.
- Activate the workflow and test by messaging the bot.
Required items
- Telegram bot token
- Google Gemini (PaLM) API key
- n8n instance with Telegram and HTTP nodes enabled
- (Optional) Google Docs OAuth2 credential
How it works (step-by-step)
- Telegram message arrives → Trigger node.
- Workflow extracts message and user info.
- (Optional) Pull supporting content from Google Docs or an API.
- Send prompt + context to Gemini → receive reply.
- Send reply back to the Telegram user.
- Add small delays and batch processing to handle volume safely.
How to customize
- Edit the Gemini prompt to change response style and behavior.
- Switch Gemini model (Flash vs Pro) for speed vs. quality.
- Add conditions (If / Switch) to route different inputs to different behaviors.
- Append more data sources (Sheets, external APIs) to enrich replies.
- Add error handling to retry or log failed requests.
Testing checklist
- Send a test message to the bot and confirm a reply.
- If using Google Docs, confirm the bot can read the target document.
- Check logs and node outputs in n8n for any errors.
Tips and best practices
- Keep prompts concise and include only needed context to reduce costs.
- Use rate limiting (Wait node) and batching to avoid API throttling.
- Store API keys securely in n8n credentials.
- Start with small tests before enabling automated production runs.
Support & links