Working with Chatflows
Chatflows give you more control than Assistants. Instead of filling out a form, you visually connect building blocks to create exactly the workflow you want. Think of it as going from using a microwave (Assistant) to cooking on a stove (Chatflow) β more control, more possibilities.
When to Use Chatflows vs Assistantsβ
| Feature | Assistant | Chatflow |
|---|---|---|
| Ease of use | βββββ | ββββ |
| Flexibility | βββ | ββββ |
| Custom RAG setup | Basic | Advanced |
| Multiple vector stores | No | Yes |
| Custom chains | No | Yes |
| Best for | Quick prototypes | Production chatbots |
Step 1: Create a New Chatflowβ
- In the left sidebar, click "Chatflows"
- Click the "+ Add New" button
- You'll see a blank canvas β this is your workspace!
Step 2: Understanding Nodesβ
On the left side of the canvas, you'll see a panel with categories of nodes. Let's understand the main ones:
Chat Models π§ β
These are the AI brains. You'll almost always need one of these:
- ChatOpenAI: OpenAI's models (GPT-4o, GPT-4o-mini)
- ChatAnthropic: Anthropic's Claude models
- ChatGoogleGenerativeAI: Google's Gemini models
- ChatOllama: Run open-source AI models
Chains πβ
Chains connect your AI model to other components:
- Conversation Chain: The simplest β just chat back and forth
- Conversational Retrieval QA Chain: Chat + search through documents
Memory πβ
Memory lets your chatbot remember previous messages:
- Buffer Memory: Remembers everything (uses more tokens)
- Buffer Window Memory: Remembers the last N messages
- Conversation Summary Memory: Summarizes old messages to save space
Vector Stores π¦β
Where your documents are stored for searching:
- In-Memory Vector Store: Quick and easy, but data disappears when you restart
- Pinecone: Cloud-based, production-ready
- Qdrant: High-performance vector database
Document Loaders πβ
How you get documents into the system:
- PDF File: Upload PDF documents
- Web Scraper: Pull content from websites
- Text File: Upload plain text files
Text Splitters βοΈβ
Break large documents into smaller, searchable pieces:
- Recursive Character Text Splitter: The most commonly used β smart about where it splits
Embeddings π’β
Convert text into numbers so the AI can search through it:
- OpenAI Embeddings: Most popular choice
- Google Embeddings: Good alternative
Step 3: Build a Simple Chatbotβ
Let's build a basic chatbot step by step:
3a. Add a Chat Modelβ
- In the left panel, expand "Chat Models"
- Drag "ChatOpenAI" onto the canvas
- Click on the node to configure it:
- Credential: Select your OpenAI API key
- Model Name: Choose
gpt-4o-mini - Temperature: Leave at
0.9(higher = more creative, lower = more focused)
3b. Add Memoryβ
- Expand "Memory" in the left panel
- Drag "Buffer Memory" onto the canvas
- No configuration needed β it works out of the box
3c. Add a Conversation Chainβ
- Expand "Chains" in the left panel
- Drag "Conversation Chain" onto the canvas
- Now connect the pieces:
- Draw a line from ChatOpenAI β Conversation Chain (connect to the "Chat Model" input)
- Draw a line from Buffer Memory β Conversation Chain (connect to the "Memory" input)
3d. Test It!β
- Click "Save" in the top right
- Click the chat bubble icon in the bottom right
- Type a message and see your chatbot respond!
Your canvas should look something like this:
ββββββββββββββββ βββββββββββββββββββββββ
β ChatOpenAI ββββββΆβ Conversation Chain β
ββββββββββββββββ βββββββββββββββββββββββ
β²
ββββββββββββββββ β
β Buffer Memoryββββββββββββββββ
ββββββββββββββββ
Step 4: Add Document Search (RAG)β
Let's upgrade your chatbot so it can answer questions about a specific document:
4a. Replace the Chainβ
- Delete the Conversation Chain node (click it, press Delete)
- Drag a "Conversational Retrieval QA Chain" onto the canvas
4b. Add Document Loadingβ
- Drag a "PDF File" loader onto the canvas
- Click on it and upload a PDF document
4c. Add Text Splittingβ
- Drag a "Recursive Character Text Splitter" onto the canvas
- Connect it to the PDF File loader
- Configure it:
- Chunk Size:
1500(how big each piece of text is) - Chunk Overlap:
200(how much pieces overlap β helps maintain context)
- Chunk Size:
4d. Add Embeddingsβ
- Drag "OpenAI Embeddings" onto the canvas
- Select your OpenAI credential
4e. Add a Vector Storeβ
- Drag "In-Memory Vector Store" onto the canvas
- Connect everything:
- Text Splitter β PDF File (Document input)
- PDF File β In-Memory Vector Store (Document input)
- OpenAI Embeddings β In-Memory Vector Store (Embeddings input)
4f. Connect It Allβ
- ChatOpenAI β Conversational Retrieval QA Chain (Chat Model input)
- In-Memory Vector Store β Conversational Retrieval QA Chain (Vector Store input)
- Buffer Memory β Conversational Retrieval QA Chain (Memory input)
4g. Test It!β
Save and test by asking questions about your uploaded document. The AI will search through the document and give you answers based on what it finds!
Understanding How RAG Worksβ
Here's what happens when you ask a question:
You: "What is the return policy?"
β
βΌ
βββββββββββββββββββββββ
β 1. Your question is β
β converted to β
β numbers (embedded)β
βββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β 2. Those numbers are β
β compared to your β
β document chunks β
βββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β 3. The most relevant β
β chunks are found β
βββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β 4. The AI reads thoseβ
β chunks + your β
β question and β
β writes an answer β
βββββββββββββββββββββββ
Tips for Better Chatflowsβ
- Start simple: Begin with a basic chain, then add complexity
- Chunk size matters: Smaller chunks = more precise answers but might miss context. Larger chunks = more context but less precise
- Use the right memory: Buffer Window Memory (last 5-10 messages) is usually the best balance
- Test with real questions: Use the kinds of questions your actual users would ask
- Check source documents: Enable "Return Source Documents" to see which chunks the AI used β this helps you debug
What's Next?β
Chatflows are great for single-agent systems, but what if you need multiple AI agents working together, conditional logic, or human approval steps? That's where Agentflow comes in!
π Mastering Agentflow