Build a Free Local AI Personal Assistant with Ollama
Overview & Architecture
This blueprint turns a Telegram bot into a personal assistant that runs on your own hardware. Send it a PDF, another document, or a photo of printed text with a question, and it answers from the file. Send no file and just ask about one (“Please summarize my terms of service document”), and it looks for that file in a Google Drive folder.
Every file goes through a self-hosted Apache Tika container, which extracts the text (with OCR for photos). An n8n AI Agent node then answers with a local Ollama model and remembers the last few messages in the chat, so follow-up questions work. The bot only responds to your own Telegram chat ID.
The model and the text extraction stay on your own machine. Telegram carries the messages and Google Drive stores the files.
The Pipeline
- Telegram Message: A Telegram Trigger receives messages from one bot and only accepts the owner’s chat ID.
- File Attached?: If the message has a document or a photo, it is downloaded from Telegram. The caption is the question; with no caption the assistant summarizes the file.
- Extract File Search Term: With no attachment, a small Ollama step pulls one to three keywords out of the message, so “Please summarize my terms of service document” becomes “terms service”.
- Search Drive Folder: n8n searches one Google Drive folder for a file whose name contains those keywords and downloads the first match. Google Docs and Slides are exported to PDF, Sheets to CSV.
- Extract Text With Tika: Every file is sent to Apache Tika (full image, with OCR) at
http://tika:9998, and the text is trimmed to about 12,000 characters. - Personal Assistant: An AI Agent node runs Ollama with
qwen2.5:14b-instruct-q5_K_Mand a window memory of the last 6 messages, keyed by Telegram chat ID. If no file was attached and nothing matched, it says so and answers from the message alone. - Reply in Telegram: The answer is escaped for Telegram’s HTML formatting and sent back to the same chat.
What You Need
- Docker with n8n, Ollama and Apache Tika (full image) on a shared network (built and tested on n8n 2.43.5)
- n8n reachable over HTTPS from the internet, so Telegram can deliver messages to the trigger
- A Telegram bot made with BotFather, your numeric chat ID, and a Telegram credential in n8n
- A Google Drive OAuth credential in n8n and the ID of the Drive folder to search
- The
qwen2.5:14b-instruct-q5_K_Mmodel pulled in Ollama, or another local model set in both Ollama nodes
Key Deployment Hurdles & Solutions
- Reading any file, including photos: Instead of a separate parser per file type, every file goes to one Apache Tika container. The full image includes OCR, so a photo of printed text works too; the slim image does not.
- Google files are not regular files: Docs and Slides are exported to PDF and Sheets to CSV during the Drive download, so Tika gets a file it can read.
- Finding a file from a sentence: A Drive search on the whole message would never match. A small Ollama step reduces the message to a few file-name keywords first, and the Drive search looks for names that contain them.
- Avoiding model reloads: The keyword step and the assistant use the same model and the same context size, so Ollama does not reload the model between the two steps.
- Telegram formatting errors: Model answers can contain characters Telegram’s HTML mode rejects. The reply step escapes
&,<and>before sending. - Keeping it private: The trigger only accepts the owner’s chat ID, so other Telegram users cannot use the bot.
- Limits to know: Telegram bot downloads cap at about 20 MB, the Drive search covers only files directly in the folder, the first match wins, and text is cut at about 12,000 characters.
Download the Workflow (.json)
Import-ready n8n workflow with all 16 nodes. In n8n choose Import from file, attach your own Telegram, Google Drive and Ollama credentials, then replace YOUR_TELEGRAM_CHAT_ID in the Telegram Message trigger and YOUR_GOOGLE_DRIVE_FOLDER_ID in Search Drive Folder, and publish the workflow.
Download the n8n workflow (.json)
Download the Companion System Prompt (.md)
Enter your first name to personalize the assistant prompt so your AI helper can walk you through the Telegram, Google Drive, Tika, Ollama and n8n setup step by step. Add your email optionally to get notified when new home lab blueprints drop.