LocalFAQ AI is a complete AI-powered FAQ chatbot for Telegram built to deeply explore local LLM integration and no-code workflow automation.
This repository contains the full workflow and infrastructure of the project, responsible for receiving user messages, injecting company context, querying a local AI model, and returning intelligent responses, all without any cloud inference costs.
The bot is built using n8n + Ollama + phi3:mini + Docker + ngrok, with structured fallback handling and a fully customizable company knowledge base.
- n8n (workflow automation)
- Ollama (local LLM runtime)
- phi3:mini (3.8B parameter language model)
- Docker & Docker Compose
- ngrok (webhook tunneling)
- Telegram Bot API
User sends message on Telegram
│
▼
[n8n Webhook Trigger]
│
▼
[Check: is it a text message?]
├── No → Send "text-only" error message back to user
└── Yes ▼
[Inject Company Context]
│
▼
[POST to Ollama — phi3:mini runs locally]
│
▼
[Check: did the model return a valid response?]
├── No / Error → Send fallback message with contact info
└── Yes → Send AI response back to the user on Telegram
The intelligence of this bot lives in a single n8n Set node called Company Context. It injects structured facts about the company directly into the prompt before every request to the model. This technique is known as prompt-stuffing RAG, instead of a vector database, all knowledge is embedded directly into the system prompt at inference time.
The model is instructed to:
- Answer only using the provided company data
- Reply with a fallback message if the information is not available
- Be direct and concise, maximum 4 sentences per response
- Never fabricate information
The bot ships pre-configured for CodeStack, a fictional Brazilian web development startup. It knows:
| Category | Details |
|---|---|
| Services offered | Landing pages, institutional sites, e-commerce, web systems, custom web platforms |
| Services NOT offered | Monthly maintenance, ongoing support, mobile app development |
| Tech stack | Next.js, React, TypeScript, TailwindCSS, Node.js, NestJS, PostgreSQL, Docker, AWS, Vercel |
| Contract model | Fixed-scope projects with predefined deadline and price |
| Delivery times | Landing page: 3–7 days · Institutional: 1–3 weeks · E-commerce: 3–6 weeks · Web system: 1–3 months |
| Contact | 📞 (88) 99123-4567 · 📧 codestack00@empresa.com.br · 🌐 www.codestack.com.br |
| Hours | Mon–Fri 8am–5pm · Sat 8am–11am |
This project uses phi3:mini, a very small (3.8B parameter) model chosen for its low hardware requirements and fast local inference. This comes with real trade-offs:
Even with explicit instructions like "only use the data provided", phi3:mini can occasionally fabricate plausible-sounding answers when the question is ambiguous. Small models have a strong tendency to "complete" answers from their training data rather than strictly following instructions.
Large models (GPT-4, Claude, etc.) reliably follow complex system instructions. phi3:mini sometimes ignores constraints like response length limits or the "only use provided data" directive, especially under unusual phrasing or multi-part questions.
With num_ctx: 4096, the model handles typical FAQ scenarios well. If you significantly expand the company context (long pricing tables, policies, etc.), the model may truncate or forget earlier instructions, leading to degraded behavior.
The current settings (temperature: 0.5, repeat_penalty: 1.1, top_k: 20) are tuned for consistency. Increasing temperature produces more natural responses but raises hallucination risk. Lowering it too far makes responses robotic.
- Docker installed
- Ollama installed on the host machine
- ngrok account and CLI
- A Telegram Bot token (from @BotFather)
git clone https://github.com/DavidEricson00/localfaq-ai.git
cd localfaq-aicp .env.example .envEdit .env with your values:
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=yourpassword
N8N_HOST=localhost
N8N_PORT=5678
N8N_PROTOCOL=http
WEBHOOK_URL=https://your-ngrok-url.ngrok-free.appollama pull phi3:minidocker compose up -dn8n will be available at http://localhost:5678
ngrok http 5678Copy the https:// forwarding URL and update WEBHOOK_URL in your .env, then restart the container:
docker compose down && docker compose up -d- Open n8n at
http://localhost:5678 - Go to Workflows → Import
- Import the
.jsonworkflow file from this repo - Add your Telegram Bot credentials in n8n
- Activate the workflow
