Skip to content

DavidEricson00/LocalFAQ-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocalFAQ AI

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.

🚀 Technologies

  • n8n (workflow automation)
  • Ollama (local LLM runtime)
  • phi3:mini (3.8B parameter language model)
  • Docker & Docker Compose
  • ngrok (webhook tunneling)
  • Telegram Bot API

📐 How It Works

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

🧠 How the AI Works

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

🏢 Default Company (CodeStack)

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

⚠️ Known Inconsistencies

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:

Hallucination on Edge Cases

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.

Instruction Following is Inconsistent

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.

Context Window Sensitivity

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.

Temperature & Repetition Trade-offs

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.

🤖 n8n Workflow Screenshot

🚀 Getting Started

Prerequisites

1. Clone the Repository

git clone https://github.com/DavidEricson00/localfaq-ai.git
cd localfaq-ai

2. Configure Environment Variables

cp .env.example .env

Edit .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.app

3. Pull the AI Model

ollama pull phi3:mini

4. Start n8n

docker compose up -d

n8n will be available at http://localhost:5678

5. Expose Your Local Server with ngrok

ngrok http 5678

Copy the https:// forwarding URL and update WEBHOOK_URL in your .env, then restart the container:

docker compose down && docker compose up -d

6. Import the Workflow

  1. Open n8n at http://localhost:5678
  2. Go to Workflows → Import
  3. Import the .json workflow file from this repo
  4. Add your Telegram Bot credentials in n8n
  5. Activate the workflow

About

A complete AI-powered FAQ chatbot for Telegram

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors