> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fetchhive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Write to Knowledge Base

> Configure a workflow step that writes content to an existing knowledge base — from custom text, a document, or a scraped website

Use **Write to Knowledge Base** when you want a workflow step to add new content to one of your knowledge bases. Each run creates a new knowledge base item so that the full history of writes is preserved.

## Configuration

| Option                 | Required            | Description                                                                                                                                                                     |
| ---------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                   | No                  | Label for the step in the workflow canvas.                                                                                                                                      |
| Knowledge Base         | Yes                 | The target knowledge base selected in **Knowledge Base**.                                                                                                                       |
| Write Mode             | Yes                 | One of **Text**, **Document**, or **Scrape**.                                                                                                                                   |
| Content                | Yes (Text mode)     | The text to embed. This field supports workflow variables through **Insert Variable**.                                                                                          |
| Document URL           | Yes (Document mode) | The URL of the document to extract and embed. Supports workflow variables through **Insert Variable**.                                                                          |
| Website URL            | Yes (Scrape mode)   | The URL to scrape.                                                                                                                                                              |
| Chunking Strategy      | No                  | **Default** uses deterministic paragraph- and sentence-aware chunking. **Advanced** uses the same chunker and lets you set **Max Chunk Length** and **Chunk Overlap** manually. |
| Remove Email Addresses | No                  | When enabled, strips email addresses from the content before embedding.                                                                                                         |
| Remove Phone Numbers   | No                  | When enabled, strips phone numbers from the content before embedding.                                                                                                           |
| When the step fails    | No                  | Controls whether the workflow should **Terminate Workflow** or **Continue** if this step fails.                                                                                 |

### Write Mode

**Text** — Enter raw text directly in **Content** or pipe in a prior step's output using `{{step_n.output}}`.

**Document** — Enter a document URL in **Document URL**, or use **Insert Variable** to pass a URL from a prior step (for example, a media library asset URL). The content is extracted automatically and embedded into the knowledge base.

**Scrape** — Enter a URL in **Website URL**. Fetch Hive scrapes the page and embeds the extracted text.

### Chunking Strategy

Leave **Chunking Strategy** set to **Default** for most use cases. Fetch Hive preserves paragraph and sentence boundaries where possible, and only falls back to hard splitting when a single unit is too large. Switch to **Advanced** to control exactly how the content is split:

* **Max Chunk Length** — Maximum number of characters per chunk (default 500).
* **Chunk Overlap** — Number of characters shared between adjacent chunks (default 50). Overlap helps preserve context at chunk boundaries.

### PII Removal

Enable **Remove Email Addresses** and/or **Remove Phone Numbers** to redact those values from the content before it is embedded and stored.

## Output

This step returns a summary of the write operation:

```json theme={null}
{
  "knowledge_base_item_id": "...",
  "knowledge_base_id": "...",
  "chunk_count": 12,
  "status": "completed",
  "write_mode": "custom_text"
}
```

Reference the output in a later step:

```text theme={null}
{{step_2.output}}
{{step_2.output.chunk_count}}
```

## Cost

Each run of this step costs **1 task**.

## Example

Add **Write to Knowledge Base** from the **Knowledge Base** group in **Search steps...**.

Set **Knowledge Base** to the target knowledge base.

Choose **Write Mode**. For a pipeline that summarises web articles, select **Scrape** and set **Website URL** to `{{step_1.output.url}}`.

Leave **Chunking Strategy** as **Default** unless you need precise control over chunk size.

Enable **Remove Email Addresses** if the scraped content may contain personal data.

Click **Run** in the step header to test the write, then check **Output** to confirm the chunk count and item ID.

{/* Add screenshot: Write to Knowledge Base settings with Scrape mode and Advanced chunking */}

## Notes

* Each run creates a **new** knowledge base item. Prior items written by earlier runs are not overwritten, so the full write history is preserved in the knowledge base.
* The step validates that a knowledge base is selected and that the required input for the chosen mode is present before running.
* Chunking and PII removal are applied before the content is embedded.

See also: [Search Knowledge Base](./search-knowledge-base), [Creating and Editing](../../creating-and-editing), [Testing and Iteration](../../testing-and-iteration), and [Error Handling](../../error-handling)
