See llms.txt for all machine-readable content.

Back to Templates

Chat with PDFs on Telegram using Google Gemini and Pinecone

Created by

Created by: Intuz  || intuz
Intuz

Last update

Last update 15 hours ago

Categories

Share


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

  1. Triggers when a new Telegram message is received by your bot.
  2. Checks whether the message includes a document; if it does, it downloads the file from Telegram and forces the binary metadata to application/pdf.
  3. Splits the PDF text into overlapping chunks, generates embeddings with Google Gemini, and inserts the vectors into a Pinecone index.
  4. Sends a Telegram confirmation message indicating how many PDF pages were saved to Pinecone.
  5. 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.
  6. Sends the generated answer back to Telegram using HTML parse mode formatting.

Setup

  1. Create a Telegram bot with BotFather and add Telegram credentials in n8n for the Telegram Trigger and Telegram nodes.
  2. Add a Google Gemini (PaLM) API credential for both the embeddings and chat model nodes.
  3. Set up a Pinecone account, create (or select) an index named telegram, and add your Pinecone credentials in n8n.
  4. 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