Video summary
Вебинар: Автоматизация бизнес-процессов с AI: n8n + Dify на практике
Main summary
Key takeaways
Topic
Practical webinar demonstrating how to automate business processes with AI by combining n8n (automation/workflow) and Dify (open-source platform for building AI apps, including vector knowledge bases and chat UIs). The live demo used a simple “door store” knowledge base and Telegram as an entry channel.
Key technological concepts explained
- Retrieval-Augmented Generation (RAG)
- Store business documents as embeddings in a vector DB.
- Split documents into chunks, retrieve the most-similar chunks for a user query, and include them in the LLM context to reduce hallucinations and token cost.
- Embeddings and chunking
- Chunk size / overlap strategy (example: ~3,000 characters per chunk as a starting point; use overlap to preserve semantics).
- Rule of thumb: one token ≈ 3 characters (rough guide).
- Search modes
- Vector, full-text, hybrid (vector + full-text / ranking).
- Hybrid mode was demonstrated for better relevance.
- Prompt engineering / system-prompt best practices
- Limit the LLM to facts, use local memory, set format rules for channels (e.g., Telegram), and include examples.
- Orchestration patterns
- On-demand RAG: model or agent decides when to call the KB (tool invoked only if needed).
- Forced-first retrieval: always call the KB first and feed results to the model (reduces hallucination but requires tighter KB structure).
- Deployments and local models
- n8n and Dify are open-source and can be deployed locally, on-prem, or in cloud (docker-compose, Docker, Kubernetes).
- Telegram webhooks require a domain + SSL (unless using proxies).
- Dify supports multiple LLM vendors and local models (e.g., via Ollama / localhost), enabling fully offline workflows.
Product / feature highlights — Dify
- Open-source platform for AI apps with:
- Visual no-code / low-code studio (recently added code editor and Python support for advanced blocks).
- Vector knowledge base with embedding selection, chunking settings, and per-chunk metadata editing in the UI.
- Support for multiple embedding/LLM providers (OpenAI, local models via Ollama, etc.).
- API endpoints (e.g., dataset retrieve) for integration with external workflow engines.
- Chat/app templates and the ability to publish a chat app and issue API keys.
- Ability to edit chunks inside the UI without full re-upload.
Product / feature highlights — n8n
- Open-source workflow automation platform with a visual workflow editor and many integrations (Telegram, email, etc.).
- Features used in the talk:
- Agent/LLM blocks.
- Memory (simple per-user memory; supports external DBs like Postgres/Mongo).
- Retry logic and conditional steps.
- Ability to call Dify via HTTP request node to retrieve relevant chunks (used as a “tool” inside the agent).
Demo / tutorial steps (practical guide)
- Prepare documents (PDF, Word, Excel, CSV, etc.). Prefer consistent structure and parsers for uniform chunking.
- Upload files to a Dify dataset and configure chunking:
- Set separator, max characters, overlap.
- Choose an embedding model (OpenAI or local).
- Trigger embedding calculation (background process).
- Note the dataset ID (in the dataset URL) for API calls.
- In n8n:
- Create a trigger (Telegram message).
- Create an agent block with a system prompt instructing language, factual-only answers, format rules, and examples.
- Add a tool: HTTP POST to Dify retrieve endpoint with a JSON body containing the query (user message) and retrieval parameters (method: hybrid/vector/full-text).
- Configure the model node (e.g., OpenAI GPT-4o Mini in demo), memory, and retries.
- Test end-to-end:
- User message -> n8n trigger -> HTTP retrieve to Dify -> top chunks returned -> LLM composes reply -> send to Telegram.
- Alternative flow:
- Always call Dify first as a separate HTTP tool step before the LLM if the KB is tightly curated.
- Optionally use Dify Studio to build and publish an internal chat app (chatflow / agent templates) and reuse the same API from n8n.
Best practices, tips and caveats
- KB structure and metadata matter
- Use consistent parsers and add metadata/keywords per chunk to improve relevance and filtering.
- Avoid duplicated or ambiguous sections (e.g., old vs. current product info).
- For hierarchical or large taxonomies
- Consider iterative retrieval (multi-step filtering by taxonomy levels).
- Editing KB content
- Edit chunks directly in the Dify interface to quickly fix content without full re-ingest.
- Embedding model selection
- Use cloud models (OpenAI) if data sensitivity allows; for sensitive data, use local models via Ollama or other localhost connectors.
- Image handling
- Some nodes prefer image URLs rather than raw base64. Workarounds include temporary storage (Google Drive) or using nodes that support image upload. Image editing workflows were not fully demonstrated.
- Production trade-offs
- Open-source + low-code: fast prototyping, low initial cost, rapid iteration, strong community support.
- Downsides: potential scaling constraints depending on choices, security/testing/auditing requirements, and the need to patch/monitor open-source components.
- Custom development: longer timelines (weeks–months) but offers more control and scalable solutions tailored to needs.
Issues encountered & debugging topics
- Agent reliance on message history instead of re-querying the KB — mitigations: tighten prompts or call KB explicitly each time.
- Persistent hallucinations — address via KB tuning, prompt rules, metadata filtering, or forced retrieval-first flow.
- Retry logic is valuable to handle transient OpenAI/Dify outages.
Resources mentioned
- Dify API: dataset retrieve endpoint and dataset ID usage.
- Embedding and LLM vendor options: OpenAI, Ollama/local.
- Deployment methods: Docker/docker-compose or Kubernetes.
- Integration examples: Telegram webhook, exporting Dify chat app via API keys.
Main speakers / sources
- Presenter: Ivan Chetverikov — Lead Architect at RAFT (demonstrator and primary speaker).
- Webinar/host: Dextau webinar series.
- Platforms referenced: Dify, n8n, OpenAI, Ollama, RAFT.
If you want, I can: - Extract the exact n8n workflow steps (nodes + JSON body example for the Dify retrieve request). - Provide a sample system prompt (the presenter offered to share the prompt and workflow). - Draft a short checklist for KB ingestion and chunking metadata to minimize hallucinations.