Self-hosted
Customer-support agent with knowledge base and handoff
Dify self-hosted as the agent builder and knowledge base, a local model on vLLM behind it, pgvector or Qdrant for retrieval, and n8n for the handoff into your helpdesk. Scoped deliberately: a defined topic list, a refusal path, and a human queue.
- Source
- Editorial recipe — no step evidence has been fetched yet
- Verified
- Evidence not verified
- Confidence
- Low
01Objective
Answer common customer or employee questions from your own documented answers, and hand over to a person the moment the question is outside what the assistant can support.
- use caseAI customer-support agentAn assistant that answers customer questions from your help content and account systems, resolves what it can, and hands the rest to a person with context attached. Deflection rate matters less than what happens on the cases it cannot close.
- use caseEmployee helpdeskAn internal assistant that answers staff questions about IT, facilities, expenses and policy, and can perform routine service actions such as resets and access requests. Same shape as customer support, different audience and different data.
- use caseHR knowledge assistantAnswering questions about leave, benefits, pay policy and procedure from the HR document set, with jurisdiction-correct answers for multi-country teams. Answers must match the employee handbook, not approximate it.
Field notes about this recipe
02Recommended stack
| Role | Component |
|---|---|
| Inference | Qwen3-32B (or Qwen2.5-14B-Instruct for a narrower scope) |
| Inference | vLLM |
| Orchestration | Dify |
| Orchestration | n8n |
| Uioptional | Chat widget or helpdesk integration |
| Vector store | pgvector, or Qdrant for larger corpora |
Architecture and data flow
Components
- Customers and support agents — people
- Knowledge base articles — storage
- Reverse proxy / chat widget endpoint — network
- Dify agent — application
- Agent sign-in (OIDC) for staff — identity
- Retrieval + refusal policy — retrieval
- Helpdesk / ticketing system — external api
- pgvector / Qdrant — vector store
- PostgreSQL (conversations, logs) — database
- vLLM — inference server
- Qwen3-32B — model
- GPU server (48 GB) — hardware
Connections
- Customers and support agents to Reverse proxy / chat widget endpoint — HTTPS (confidential data)
- Reverse proxy / chat widget endpoint to Dify agent — reverse proxy (confidential data)
- Dify agent to Agent sign-in (OIDC) for staff — OIDC sign-in (personal data)
- Knowledge base articles to Retrieval + refusal policy — documents to index (confidential data)
- Dify agent to Retrieval + refusal policy — question + user groups (confidential data)
- Retrieval + refusal policy to pgvector / Qdrant — embedding search (confidential data)
- Retrieval + refusal policy to PostgreSQL (conversations, logs) — documents + permissions (confidential data)
- Dify agent to PostgreSQL (conversations, logs) — chats, users, settings (personal data)
- Retrieval + refusal policy to vLLM — prompt + retrieved passages (confidential data)
- vLLM to Qwen3-32B — loaded weights
- Qwen3-32B to GPU server (48 GB) — GPU memory
- vLLM to GPU server (48 GB) — GPU memory
- Dify agent to Helpdesk / ticketing system — escalated conversation and transcript (personal data)
External data transfer · SOME
- personal data leaves your premises for your own cloud tenancy ("Helpdesk / ticketing system"). You keep control of the account; the provider is a processor, so a DPA and a documented region apply.
- Model inference and retrieval stay on your machines; the only outbound flow is the escalated conversation into your own helpdesk tenancy.
- A customer-facing widget means the front door is public even though the model is not — the reverse proxy and rate limiting are part of the design, not an afterthought.
03Suitable for
- Organisation size
- 20–2000 employees
- Data classes
- personal, confidential
- Constraints
- documented answers already exist, or someone will write them; a helpdesk or ticketing system to hand over to; a support lead who owns what the assistant is allowed to answer; a 48 GB GPU for a 32B model, or a 24 GB card for a narrower scope
- Industries
- Retail, Ecommerce, Technology, Telecommunications, Professional services
- Jurisdictions
- any
04Hardware
Cloud GPU instance — 1 × NVIDIA L4 24 GB
- GPU
- NVIDIA L4 24 GB (AWS G6, Azure NVadsA10/NCads equivalents, GCP G2)
- VRAM
- 24 GB
- System RAM
- 64 GB
- Storage
- 1000 GB
- CPU
- 8–16 vCPU
- Form factor
- Cloud instance
Indicative costUS$1 – US$2
indicative on-demand rental, USD per hour, Aug 2026 — verify against the provider price list for your region
The private-cloud counterpart of `onprem-small-24gb`: same model sizes, no capital outlay, and a region you choose explicitly. Running it continuously for a year usually costs more than buying the equivalent box, so it suits pilots, bursts and firms without a server room. The cloud provider becomes a data processor — a DPA and a documented region are required.
On-premise single 48 GB GPU server
- GPU
- NVIDIA L40S 48 GB (rack) or NVIDIA RTX 6000 Ada 48 GB (office workstation)
- VRAM
- 48 GB
- System RAM
- 128 GB
- Storage
- 4000 GB
- CPU
- 24–32-core x86 server CPU (AMD EPYC or Intel Xeon Scalable)
- Form factor
- Rack server
Indicative costUS$12,000 – US$22,000
indicative build cost for the complete machine, USD, Aug 2026 — verify with a local supplier
The step up when answer quality matters more than price: a 32B model at 4-bit with generous KV cache, or a 14B model at fp16 with a long context. ECC memory and a standard 2U chassis mean it belongs in a rack or comms room rather than under a desk.
Indicative costUSD · one-off plus monthly
- Software licences
- All components are open source and self-installed. Check each licence for use limits.
- US$0
- Model usage
- Open weights served locally: no per-token charge. The GPU cost sits under infrastructure.
- US$0
- GPU server (48 GB class)
- Hardware profile onprem-medium-48gb — indicative build cost, Aug 2026, verify locally.
- US$12,000 – US$22,000
- Implementation (10–25 FDE-days)
- 10–25 FDE-days at US$760–1940 per day, converted from the HK$6,000–15,000 band at the HKMA Linked Exchange Rate band of HK$7.75–7.85 to one US dollar. One-off; excludes internal staff time.
- US$7,600 – US$48,500
- Ten documented topics, one language, one helpdesk integration.
- Excludes writing the knowledge-base articles, which is usually the largest single effort and belongs to the support team rather than to the deployment.
- Every figure is an assessment from the inputs listed, not a quotation.
05Difficulty
4 / 5
Multiple weeks and a team that has shipped infrastructure
06Skills
- API integrationapi-integration
- development
- Change managementchange-management
- operations
- Dockerdocker
- infrastructure
- Linuxlinux
- operations
- LLM evaluationllm-evaluation
- ml
- LLM inferencellm-inference
- ml
- Prompt engineeringprompt-engineering
- ml
- Retrieval-augmented generationrag
- ml
- Vector databasesvector-databases
- data
- Workflow automationworkflow-automation
- operations
07Deployment steps
Commands are copied from each project’s own documentation, and the page they came from is linked under the step. 0 of 7 steps currently open an evidence record. The rest are linked to their source; §10 says which of those documents were fetched and which were fetched without their anchor being found — two different states, named differently there.
- 01
Write the list of questions it is allowed to answer
AssessmentTake the last three months of tickets and rank the topics. Pick the top ten that have a documented, stable answer. Everything else is out of scope on day one and goes straight to a person. A narrow assistant that is right is worth more than a broad one that is plausible.
- 02
Deploy Dify with Docker Composeversion-sensitive
AssessmentClone the repository, copy the example environment file and start the stack. Change the default credentials before it is reachable by anyone else, and put it behind your reverse proxy rather than exposing the compose ports directly.
cd dify/dockercp .env.example .envdocker compose up -ddocker compose pscheck every service is healthy
- 03
Point Dify at a local modelversion-sensitive
AssessmentRun vLLM as an OpenAI-compatible endpoint and register it in Dify as a model provider. Keep the API key out of the compose file and in your secret store; support traffic often means the endpoint is the busiest service you run.
docker run --runtime nvidia --gpus all \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=$HF_TOKEN" \ -p 8000:8000 \ --ipc=host \ vllm/vllm-openai:latest \ --model Qwen/Qwen3-0.6Bfrom the vLLM docs — substitute the model you sized for
- 04
Load the knowledge base and make it citable
AssessmentLoad only the documented answers you chose, tagged by product and language. Configure the assistant to show which article an answer came from — support agents will not trust it otherwise, and neither should customers.
CREATE EXTENSION vector;if you are using pgvector rather than Qdrant
- 05
Design the refusal and the handoff first, not last
AssessmentThe assistant must say "I do not have a documented answer for that — connecting you to the team" whenever retrieval is weak, the topic is off-list, or the customer asks twice. The handoff carries the transcript so nobody repeats themselves. Test this path more than the happy path: it is the one that protects the brand.
docker volume create n8n_data docker run -it --rm \ --name n8n \ -p 5678:5678 \ -e GENERIC_TIMEZONE="<YOUR_TIMEZONE>" \ -e TZ="<YOUR_TIMEZONE>" \ -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \ -e N8N_RUNNERS_ENABLED=true \ -v n8n_data:/home/node/.n8n \ docker.n8n.io/n8nio/n8nfrom the n8n docs
- 06
Run it internally before any customer sees it
AssessmentPut it in front of the support team as a suggestion tool for a month. They will find the wrong answers faster than any evaluation set, and the corrections improve the knowledge base rather than the prompt.
- 07
Measure containment and escalation quality
AssessmentTrack the share of conversations resolved without a person, and — more importantly — the share of escalations that arrived with useful context. A high containment rate with angry escalations is a worse outcome than a lower one with clean handoffs.
08Compliance considerations
Structured issue-spotting to support your own review — not legal advice. Verify against the cited primary sources and your counsel.
Applies everywhere
Personal data · Retentionhigh
Support conversations contain customer personal data, sometimes special-category data when people explain why they need help. Set retention on transcripts and keep them out of the knowledge base.
Transparencyhigh
Tell customers they are talking to an automated assistant and how to reach a person. Several jurisdictions expect this explicitly; all of them expect it in practice.
Human oversight · Automated decision-makinghigh
Never let the assistant decide anything with a legal or financial effect — refunds, eligibility, account closure. It answers questions; a person decides outcomes.
Prompt leakage · Securityhigh
A customer-facing assistant is an untrusted input channel. Keep internal-only documents out of its knowledge base entirely rather than relying on instructions to withhold them.
Logging · Auditabilitymedium
Keep conversation logs with the answer, the retrieved articles and the model version, so a complaint about "what your bot told me" can be answered from the record.
09Alternatives
A support-desk vendor with a built-in AI agent
If your helpdesk already offers one, it arrives integrated with tickets, routing and reporting, which is most of the work in this recipe.
- — Integrated on day one
- — Customer conversations go to a processor; check DPA, retention and region
- — Priced per resolution or per seat, so success costs more
Onyx or a RAG stack without the agent layer
For an internal helpdesk, plain retrieval over the policy documents is often enough and is far quicker to stand up.
- — Much simpler
- — No workflows, no handoff logic, no customer-facing channel
10Evidence
Not yet in the ledger
not yet fetched
not yet fetched
not yet fetched
not yet fetched
not yet fetched
not yet fetched
not yet fetched
11Community
Deployed this stack, or hit something this page does not cover? Corrections, sources and implementation reports are what keep a recipe worth reading.
Improve this page
Sign in to contribute
From the field
0 deployments · 0 questions
Nobody has reported deploying this here yet, and no question has been opened against this page. Both appear once a reviewer accepts them.
12Hire an FDE
If you would rather not build it, we can introduce a forward-deployed engineer who has deployed this stack before. The enquiry form starts from this recipe.