Skip to main content

Add a website to a knowledge base

What you'll do: read the pages of acruxcore.com into a knowledge base from its sitemap, keep them up to date, and send the text of a page the crawler cannot read. An agent attached to the base then answers from the site and links the page it used.

You need a documents knowledge base. Run an agent with a knowledge base shows how to create one.

1. Add the sitemap​

Open Knowledge, open the base, and find the Website section.

  • Sitemap URL: usually https://your-site.com/sitemap.xml. A sitemap index works too; the crawler reads the sitemaps it lists.
  • Page limit: the crawler reads the first pages in sitemap order, up to 1000. Pages on another host are left out. www.example.com and example.com count as the same host.
  • Refresh: Daily, Weekly, or Only when I click.

Click Save and crawl. The pages appear in Documents as they are read, each named after its page title with its URL under it.

The Website section of a knowledge base named AcruxCore website: the sitemap https://acruxcore.com/sitemap.xml, a page limit of 50, a daily refresh, the Re-crawl whole site and Remove website buttons, the line 19 pages listed: 18 unchanged, 1 needs text, and below it the documents list with each page's title and URL

The crawler keeps each page's main text as Markdown, with its headings, lists, tables and code blocks. Menus, footers and images are left out. It reads two pages at a time and follows the site's robots.txt, where it is called AcruxCoreBot. Each address has its own robots.txt: www.example.com and example.com are read separately. While a robots.txt answers with a server error, the crawler reads no page from that address.

2. Keep the pages up to date​

The scheduled refresh trusts the sitemap's last-modified date, the <lastmod> of each page:

  • it reads pages that are new to the sitemap;
  • it reads pages whose <lastmod> is newer than the date it had at the last crawl, and pages whose last fetch failed;
  • it deletes pages that are no longer in the sitemap.

A page with no <lastmod> is never refreshed automatically. The Website section says how many of the listed pages have no date. To update them, click Re-crawl whole site, which reads every listed page again.

A page whose text has not changed is not embedded again, so a re-crawl costs page fetches, not embedding calls. Files you uploaded and pages you sent through the API are never touched by a crawl.

3. Send the pages the crawler cannot read​

A page with less than 50 words of main text is marked Needs text. Usually the page builds its text with JavaScript, which the crawler does not run. Scrape the text yourself and send it with the page's URL. Copy call under the documents list gives the request for your base.

The documents list with the API Reference page marked Needs text and the note Send this page's text through the API; see below, and under the list the section Pages that need their text with a Copy call button and a curl request that sends sourceUrl and text

curl -X POST https://api.acruxcore.com/api/v1/knowledge-bases/$KB_ID/documents \
-H "Authorization: Bearer $ACRUXCORE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sourceUrl": "https://docs.acruxcore.com/api-reference", "text": "# API reference\n\nThe AcruxCore REST API lives under /api/v1."}'

The page becomes a document marked Sent through the API. Sending the same URL again replaces the page's text, and sending the same text again changes nothing. A crawl never reads or overwrites a page you sent. You can also send a page the sitemap does not list. Add "filename" to give that page a name.

4. Let an agent answer from the site​

Attach the base to an agent, as for any other base. Each passage the agent finds carries its page's URL, so the prompt can tell the agent to link the page it used:

When a passage you use has a url, end your answer with a Markdown link to that page.

The chat page of an agent named Website assistant: its steps show two searches of the AcruxCore website base whose results include the url of the contact and security pages, and the answer links the support address and ends with a link to the security page

Embed an agent on your website puts the agent on the same site as a chat widget.

Limits​

  • One sitemap per knowledge base, up to 1000 pages. A sitemap index is read one level deep, up to 50 sitemaps.
  • Each page can be up to 10 MB and must answer within 15 seconds. A sitemap can be up to 20 MB.
  • The crawler does not run JavaScript and does not log in to a site.
  • It refuses private, loopback and link-local addresses, also when a page redirects to one.
  • If the sitemap cannot be read, the crawl stops and keeps every page. The Website section shows why it stopped.
  • A crawl runs for at most one hour. It keeps the pages it read, and the Website section says how many listed pages it did not reach. The next crawl adds the new ones.
  • Remove website deletes the sitemap and the pages the crawler added. Pages you sent through the API stay.

Next steps​