Chat with PDFs on Telegram using Google Gemini and Pinecone
Go to WorkflowDescription
Quick overview
This workflow lets users upload PDFs or ask questions in Telegram, indexes PDF content in Pinecone using Google Gemini embeddings, and answers follow-up questions with a Google Gemini chat model using retrieval-augmented generation formatted for Telegram HTML.
How it works
Triggers when a new Telegram message is received by your bot.
Checks whether the message includes a document; if it does, it downloads the file from Telegram and forces the binary metadata to application/pdf.
Splits the PDF text into overlapping chunks, generates embeddings with Google Gemini, and inserts the vectors into a Pinecone index.
Sends a Telegram confirmation message indicating how many PDF pages were saved to Pinecone.
If the message is a text question, retrieves relevant context from the Pinecone index and uses the Google Gemini chat model to generate an answer constrained to that context.
Sends the generated answer back to Telegram using HTML parse mode formatting.
Setup
Create a Telegram bot with BotFather and add Telegram credentials in n8n for the Telegram Trigger and Telegram nodes.
Add a Google Gemini (PaLM) API credential for both the embeddings and chat model nodes.
Set up a Pinecone account, create (or select) an index named telegram, and add your Pinecone credentials in n8n.
Activate the workflow and start a chat with your Telegram bot to upload a PDF for indexing and then send text questions to query it.
Requirements
n8n Instance & Required Nodes: An active n8n account (Cloud or self-hosted).
Telegram Account: A Telegram bot created via the BotFather, along with its API token.
Google Gemini AI Account: A Google Cloud account with the Vertex AI API enabled and an associated API Key.
Pinecone Account: A Pinecone account with an API key.
Additional info
Connect with us:
Website: https://www.intuz.com/n8n-workflow-automation-templates/
Email: [email protected]
LinkedIn: https://www.linkedin.com/company/intuz
For Custom Workflow Automation
Get Started: https://n8n.partnerlinks.io/intuz