# Website to RAG Knowledge Base (AI Chatbot Chunks) (`serkan1907/website-to-rag-knowledge-base`) Actor

Turn any website into clean, heading-aware text chunks for AI chatbots and vector databases (Pinecone, Qdrant, pgvector, n8n). Respects robots.txt, uses the sitemap, skips menus and cookie banners, removes duplicate boilerplate, and can return only pages that changed since the last run.

- **URL**: https://apify.com/serkan1907/website-to-rag-knowledge-base.md
- **Developed by:** [Serkan Bal](https://apify.com/serkan1907) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 chunks

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Website to RAG Knowledge Base

Turn any website into **clean, heading-aware text chunks** ready for an AI chatbot or a vector database. Paste a URL, get rows like this:

```json
{
  "url": "https://example.com/faq",
  "title": "FAQ",
  "headingPath": "FAQ > Do you rent e-bikes?",
  "text": "## Do you rent e-bikes?\nYes, e-bikes rent for $45 per day or $220 per week, helmet and lock included.\n- Pick up from 9am\n- Return by 6pm",
  "approxTokens": 34,
  "contentHash": "1f0c9a7e2b3d4c5a",
  "crawledAt": "2026-11-15T10:00:00.000Z"
}
```

Embed `text`, store `url` + `headingPath` as metadata, and your bot can **answer from the website and cite the exact section**.

### Why this one

| | This Actor | Generic page scraper |
| --- | --- | --- |
| Only the readable content (no menus, footers, cookie banners, scripts) | Yes | Usually raw HTML or full page text |
| Chunks split at headings, with the heading path on every chunk | Yes | No, you split it yourself |
| Tables kept as rows (prices, opening hours, plans) | Yes | Often flattened into noise |
| Duplicate boilerplate removed across pages | Yes | No |
| **Only pages that changed since last run** (cheap scheduled refresh) | Yes | No |
| Respects robots.txt, uses the sitemap, polite by default | Yes | Varies |

### Who it is for

- **Teams building a support or sales chatbot**: load your help center, pricing and policy pages into Pinecone, Qdrant, Supabase pgvector, or n8n's vector store.
- **Agencies**: build a client's knowledge base in minutes, then schedule a weekly refresh with *Only pages that changed*.
- **AI agents (MCP)**: give an agent a site's content as tidy chunks instead of raw HTML.

### Input

| Option | What it does |
| --- | --- |
| Start URLs | Home page or a section like `/help` |
| Max pages / Max link depth | How far to go |
| Output | Chunks (one row per chunk) or whole pages as markdown |
| Chunk size / overlap | Defaults 1,500 / 200 characters (about 375 / 50 tokens) |
| Only follow / Skip URLs containing | Focus on `/docs/` or skip `/blog/` |
| Only pages that changed since last run | Return just new or edited pages on scheduled runs |

### Use with n8n

Run this Actor from n8n's Apify node (or an HTTP Request node), then feed the rows into a vector store insert node with `text` as the document and `url`, `title`, `headingPath` as metadata. A ready-made RAG support chatbot workflow that uses the same idea is in our templates repo: https://github.com/steadyflow-labs/n8n-ai-templates

### What it does not do

- Public pages only: no logins, no paywalls, no CAPTCHA solving. Pages disallowed by robots.txt are skipped.
- No JavaScript rendering: content must be in the page HTML (true for most marketing sites, docs and help centers). PDF files are not read in this version.
- It does not create embeddings; you choose the model.

### Run report

Each run saves `RUN_REPORT` in the key-value store: pages fetched, pages with content, chunks returned, duplicates skipped, unchanged pages skipped, pages blocked by robots.txt, and errors.

Need this wired into your own chatbot or help desk? Reach out through the profile links.

# Actor input Schema

## `startUrls` (type: `array`):

Home page or section to start from, e.g. https://example.com or https://example.com/help. Links on the same site are followed.

## `maxPages` (type: `integer`):

Stop after this many pages are fetched.

## `maxDepth` (type: `integer`):

How many clicks away from the start URL to follow links. Sitemap pages count as depth 1.

## `outputMode` (type: `string`):

Chunks carry the page URL, title and heading path, so your chatbot can cite the source.

## `chunkSize` (type: `integer`):

About 4 characters per token. 1,500 suits most embedding models and RAG prompts.

## `chunkOverlap` (type: `integer`):

Text repeated at the start of the next chunk so answers that span two chunks are not lost.

## `includeUrlPatterns` (type: `array`):

Optional. Keep links that contain one of these (or match a pattern with *), e.g. /help/ or https://example.com/docs/*.

## `excludeUrlPatterns` (type: `array`):

Optional. Login, cart, checkout, account, search, tag and author pages are always skipped.

## `useSitemap` (type: `boolean`):

Also add pages listed in the site's sitemap (found via robots.txt or /sitemap.xml).

## `sameDomainOnly` (type: `boolean`):

Only crawl the start URLs' domains (www and non-www count as the same).

## `skipDuplicateChunks` (type: `boolean`):

Skip chunks whose text already appeared on another page (repeated banners, footers inside main content).

## `onlyChangedPages` (type: `boolean`):

For scheduled refreshes: return only new or edited pages, so you re-embed (and pay for) just what changed.

## `stateStoreName` (type: `string`):

Optional. Use a different name per website when 'only changed pages' is on.

## `maxConcurrency` (type: `integer`):

Kept low by default to be polite to the website.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.apify.com/academy"
    }
  ],
  "maxPages": 20,
  "maxDepth": 3,
  "outputMode": "chunks",
  "chunkSize": 1500,
  "chunkOverlap": 200,
  "useSitemap": true,
  "sameDomainOnly": true,
  "skipDuplicateChunks": true,
  "onlyChangedPages": false,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `chunks` (type: `string`):

No description

## `report` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://docs.apify.com/academy"
        }
    ],
    "maxPages": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("serkan1907/website-to-rag-knowledge-base").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": [{ "url": "https://docs.apify.com/academy" }],
    "maxPages": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("serkan1907/website-to-rag-knowledge-base").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://docs.apify.com/academy"
    }
  ],
  "maxPages": 20
}' |
apify call serkan1907/website-to-rag-knowledge-base --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,serkan1907/website-to-rag-knowledge-base"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/lcLvnzt6Ol6hUkr1O/builds/Qw7zUqQbqzDFxBZlo/openapi.json
