Powerful Knowledge Chatbot with Firecrawl and RAG
In this tutorial, you'll learn how to build a custom knowledge chatbot using Lamatic.ai, Firecrawl, and RAG (Retrieval-Augmented Generation).
What you'll Build
- You'll utilize Lamatic.ai Studio.
- Build Chat Widget using LLM
- Implement RAG & Firecrawl
Understanding the Components
Before we dive in, let’s understand the key technologies we’ll be working with:
- Firecrawl (opens in a new tab) A web crawling service that systematically browses and collects website data. It can extract structured content, follow links, and handle various content types.
- RAG (Retrieval-Augmented Generation): A technique that enhances Large Language Models (LLMs) by providing relevant context retrieved from a knowledge base. This allows the model to generate more accurate and contextual responses.
Architecture Overview
Our implementation follows a three-flow architecture, each handling a specific aspect of the system:
1. Firecrawl Flow
This flow is responsible for:
- Accepting website URLs through an API endpoint
- Configuring crawling parameters and depth
- Extracting relevant content from web pages
- Forwarding collected data to the webhook flow
2. Webhook Processing Flow
This flow handles:
- Receiving crawled data from Firecrawl
- Cleaning and processing the text content
- Creating vector embeddings for efficient retrieval
- Storing processed data in a vector database
3. Chatbot Flow
This flow manages:
- User interaction through a chat interface
- Context retrieval using RAG
- Response generation using the LLM
- Handling edge cases and errors
Getting Started
1. Project Setup
- Sign up at Lamatic.ai (opens in a new tab) and log in.
- Navigate to the dashboard and click Create New Flow.
- You'll see different sections like Flows, Data, and Models
2. Setting Up the Firecrawl Flow
- From the Studio, click “Create New Flow”
- Name your flow “Website Crawler”
- Select “API Request” as the trigger type and define the schema such as
{ "trigger": "bool" }
- Add a Crawler node to your flow and Add Credentials (API key from Firecrawl)
- Add Website URL to crawl the website
- In the Notification Webhook, Here we’ll select the Webhook which we’ll create in the next section
- Save the Node and Test the node.
3. Creating the Webhook Processing Flow
- Create a new flow named “Crawler Data Processor”
- Select “Webhook” as the trigger type and Click on Fetch to collect the data from Crawler Flow.
- Add a Conditional Node to check the page data
- Parse the data before Vectorize the data by adding Logic Node
- Add Vectorize Node, here you can pass the data to vectorized by selecting Embedding Model Name
- Add New Node for Indexing vectorized data, here we’ll select the vector database, vectors, metadata, and primary key JSON.
- Save the flow and Publish
- Select the Webhook in the Firecrawl Flow and Save
4. Building the Chatbot Flow
- Create a new flow named “RAG Chatbot” or Select the Flow Template of RAG Chatbot
- Add a “Chat Interface” node
- Add RAG Node and Select the Database, Pass query, Select Respective LLM
5. Testing Chatbot
- Run the Firecrawl Flow, in which we’ll crawl the data from the given website
- Check with Chatbot Flow for testing
6. Deployment and Integration
Once you’ve tested the chat widget, click the Deploy button to make it live. Here you pass the deployment message.
7. Integration
To integrate the chat widget into your website, simply click the Setup button to access the code, then paste it into your website.
Ensure that the allowed domains are specified before integrating this chat widget.
Congratulations! You've completed the tutorial and created your custom knowledge chatbot using Lamatic.ai!