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
- A chatbot using Lamatic.ai Studio
- A chat widget powered by LLM
- RAG & Firecrawl for smart data retrieval
Understanding the Components
Before we begin, let's go over the key technologies:
-
Firecrawl (opens in a new tab) A web crawling service that systematically browses and collects data from websites. It extracts structured content, follows links, and processes various content types.
-
RAG (Retrieval-Augmented Generation): A technique that enhances Large Language Models (LLMs) by retrieving relevant knowledge from a database, improving response accuracy and relevance.
Architecture Overview
Our chatbot consists of three main flows:
1. Firecrawl Flow
This flow handles:
- Accepting website URLs via an API
- Setting crawling parameters (e.g., depth, filters)
- Extracting content from web pages
- Sending collected data to the Webhook Processing Flow
2. Webhook Processing Flow
This flow processes and stores the crawled data:
- Receiving data from Firecrawl
- Cleaning and structuring text content
- Creating vector embeddings for efficient search
- Storing processed data in a vector database
3. Chatbot Flow
This flow enables user interaction and intelligent responses:
- Managing user input through a chat interface
- Retrieving relevant context using RAG
- Generating responses using the LLM
- Handling errors and fallback scenarios
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.
2. Setting Up the Firecrawl Flow
- Click Create New Flow in Lamatic.ai Studio.
- Name your flow Website Crawler.
- Select API Request as the trigger type Node and define the schema:
{ "trigger": "bool" }
- Add a Crawler Node, then enter your Firecrawl API key.
- Provide a website URL for crawling.
- Configure the Webhook Notification (this will be set up in the next step).
- Save the Node and Test the node.
3. Creating the Webhook Processing Flow
-
Create a new flow named Crawler Data Processor.
-
Set Webhook as the trigger type and fetch data from Firecrawl.
-
Add a Conditional Node to check page data.
-
Use a Logic Node to parse data before vectorization.
Example
let vectorData = "title: " + {{ triggerNode_1.output.data }}[0].metadata.title + " \n description: " + {{ triggerNode_1.output.data }}[0].metadata.description + " \n url: " + {{ triggerNode_1.output.data }}[0].metadata.url + " \n sourceURL: " + {{ triggerNode_1.output.data }}[0].metadata.sourceURL + " \n markdown: " + {{ triggerNode_1.output.data }}[0].markdown let MetaData = { rawHtml: {{ triggerNode_1.output.data }}[0].rawHtml, markdown: {{ triggerNode_1.output.data }}[0].markdown, title: {{ triggerNode_1.output.data }} [0].metadata.title, description: {{ triggerNode_1.output.data }} [0].metadata.description, url: {{ triggerNode_1.output.data }}[0].metadata.url, sourceURL:{{ triggerNode_1.output.data }} [0].metadata.sourceURL, } output = {"vectorData":[vectorData],"MetaData":[MetaData]};
-
Add a Vectorize Node, selecting an embedding model for conversion.
-
Add an Indexing Node to store vectorized data in a vector database.
-
Save and publish the flow.
-
Link the Webhook to the Firecrawl Flow. Save and publish the Firecrawl Flow.
-
Check the Webhook Processing Flow to verify the data received from the Firecrawl Node.
4. Building the Chatbot Flow
- Create a new flow named RAG Chatbot or use the RAG Chatbot Template.
- Add a Chat Interface Node.
- Add a RAG Node, configure the database, and connect it to an LLM.
5. Testing Chatbot
- Run the Firecrawl Flow to collect website data.
- Test the Chatbot Flow to ensure accurate responses.
6. Deployment and Integration
- Click Deploy to make the chatbot live.
- To integrate the chatbot into your website:
- Click Setup to access the embed code.
- Paste the code into your website’s HTML.
- Ensure allowed domains are configured before deployment.
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!