# Using your knowledge base in drafts

> Read your help center into Lagotto, or write articles here, so AI drafts answer from your documentation and link to it, even pages behind a sign-in.

The knowledge base is your support documentation, read into Lagotto so AI drafts can answer from it and link customers to the right page. Lagotto does not host a help center: it reads the one you already have, and you can add answers that are not published anywhere. Administrators set it up under **Settings → Knowledge base**, once the **Knowledge base** capability is on under **Settings → Capabilities**.

There are two kinds of source, and you can have as many of each as you like:

- **A website**: your help center, read page by page and kept up to date every day.
- **Articles written here**: answers you write in Lagotto, for things that are not published.

## Adding a website

1. Go to **Settings → Knowledge base** and press **Add website**.
2. Give it a **Name**, such as Help center.
3. In **Address**, enter where to start. Either:
   - your sitemap, such as `https://help.acme.com/sitemap.xml`, or
   - any page, such as `https://help.acme.com/docs/`. Lagotto follows the links beneath it.
4. If the documentation is behind a sign-in, fill in **Request headers** (see below).
5. Press **Add**. Lagotto starts reading straight away.

The source's page shows its status: **Waiting**, **Reading**, **Up to date** or **Failed**, with how many articles it holds and when it was last read. Open any article to see **What the AI reads**: the page's title and text, with its headings, lists, code and link addresses kept. A website's articles cannot be edited in Lagotto. To change one, change the page on your site and press **Sync now**.

### What gets read

- **A sitemap** gives the list of pages. A sitemap index is followed one level down. Only pages on the same site as the address you entered are read.
- **Any other page** is the start of a crawl: Lagotto follows its links, staying on the same site and under the start page's folder. Starting at `https://help.acme.com/docs/` reads pages under `/docs/` and nothing else on the site.
- Up to 500 pages each time. Web pages only: images, PDFs and other files are skipped.
- Each page can be up to 2MB and must answer within 10 seconds. Pages with almost no text are skipped.
- Pages are read one at a time with a short pause, so your site is not put under load.
- The site has to be on the public internet, on the standard web ports. Addresses on private networks are refused.

## Documentation behind a sign-in

If your documentation needs a sign-in, give Lagotto a header that gets it past the sign-in, such as a session cookie or an access token. Enter one per line in **Request headers**:

```
Cookie: session=...
Authorization: Bearer ...
```

- Headers are stored encrypted and work like a password: the box is always empty when you come back. The source's page and the audit log show only the header names.
- To keep the saved headers when you edit the source, leave the box empty. To replace them, fill it in again. To delete them, tick **Remove the saved headers**. Then press **Save**.
- Headers are sent only to the site you entered. If a page redirects to another site, or from https to plain http, the headers are not sent there.

> **Note:** Cookies and tokens expire. If a sync fails saying the site refused us, showed us its sign-in page, redirected to a sign-in page, would have removed most of the articles, or found no pages with readable text, the headers probably need renewing. Your articles are kept until a sync gets past the sign-in again. See [When a sync is stopped](https://www.lagottolabs.ai/support/integrations/knowledge-base.md#when-a-sync-is-stopped).

## Writing articles

1. Go to **Settings → Knowledge base** and press **Write articles**.
2. Give the source a **Name**, such as Internal answers, and press **Add**.
3. Press **Add article**. Enter a **Title** and the **Article** in plain text or Markdown. Add a **Link** if customers can read it somewhere, so a reply can point to it.
4. Press **Add article**.

To change an article, open it and press **Edit**. To remove it, use **Delete article** on the edit page. Drafts stop using it straight away.

## Keeping it up to date

A website is read again:

- every day, automatically
- when you press **Sync now** on its page
- when you change its address or request headers

Pages that have not changed are left alone, changed pages are updated, and new pages are added. A page that has gone from your site is deleted from the knowledge base, but only when the sync read the whole site. A sync that stopped at 500 pages deletes nothing, and a page that failed to load this time (a server error, a timeout, a refusal, a sign-in page) keeps its last copy. A sign-in page is never kept as an article.

### When a sync is stopped

A sync is stopped and marked **Failed**, with the reason, when:

- the start address cannot be read, or no page has readable text
- Lagotto is shown a sign-in page instead of your documentation: most pages are a sign-in form, or most pages redirect to the same address
- the start page now redirects outside the folder the source reads, for example from `/docs/` to `/login`
- the sync would remove more than half of the source's articles, once it has more than five. A site rarely loses half its pages at once; an expired cookie makes it look as if it had

A stopped sync deletes nothing, and keeps none of the pages it found for the first time. The source's page and the list under **Settings → Knowledge base** show what went wrong.

Most often the request headers need renewing (see [Documentation behind a sign-in](https://www.lagottolabs.ai/support/integrations/knowledge-base.md#documentation-behind-a-sign-in)). If your documentation moved to another site or folder, change the source's address: articles from the old place are removed when the new one is read. If it stayed where it was and really did lose more than half its pages, delete the source and add it again.

If the **Knowledge base** capability is switched off while a sync is waiting to start, the sync is marked **Failed**. Press **Sync now** once the capability is back on.

To delete a source and all its articles, open it, press **Edit**, then press the delete button under **Delete source**.

## How drafts use it

When it writes a draft, the AI searches your knowledge base before answering a how-to question, reads the best matches, and links the article it relied on when the article has an address. Assistants your team connects over MCP can search it too. See [AI drafts](https://www.lagottolabs.ai/support/ai/ai-drafts.md) and [Connecting Claude and other AI assistants](https://www.lagottolabs.ai/support/integrations/connecting-claude.md).

After each sync, the total size of your articles is recorded as storage, which your contract may charge for. See [How usage is counted](https://www.lagottolabs.ai/support/billing/how-usage-is-counted.md).
