> For the complete documentation index, see [llms.txt](https://docs.aisera.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aisera.com/aisera-platform/ai-automation-optimize-flow/ai-workflow-studio/building-workflows/using-workflow-actions/knowledge-base-actions.md).

# Knowledge Base Actions

Each of the following Actions is discussed in this topic:

* [Get Field Mappings of KB Document](#get-field-mappings-of-kb-document)
* [Fetch File Content By File IDs](#fetch-file-content-by-file-ids)
* [Get Document Section Entities Action](#get-document-section-entities-action)
* [Create Tenant Generated KBs Published History](#create-tenant-generated-kbs-published-history)

***

### Get Field Mappings of KB Document

**Description:** Retrieves the resolved external-system field mappings for a specific generated KB document. Given a generated KB document key and a target external system type, the action finds the latest KB-generation cluster/job for the document, reads the custom field values captured for it, and returns them keyed by the external system's field paths (validated against that external system type's field mappings and supported values). Use this action when publishing generated KB content to an external System of Record (SOR) — it tells you which target fields to set, and to what values.

This action connects to an internal Aisera service (tenant server) and does not require an external system integration.

**Configuration Parameters:** This action has no configuration parameters.

**Input:**

* **documentKey (String, Required):** The generated KB document key identifying the document whose external-system field mappings should be retrieved.
* **extSysTypeId (Number, Required):** The external system type ID identifying the target external system (e.g. the System of Record the KB is published to, such as ServiceNow). If the value does not correspond to a known external system type, the request is rejected.

**Output:**

* **success (Boolean):** Indicates whether the operation was successful. Returns `false` when the external system type is invalid or an error occurs.
* **response (String):** The raw response body serialized as a string.
* **mapResponse (Map):** The field mappings as a map keyed by the external system's field path, where each value is the resolved custom field value for that path. Empty when the document has no captured field values, or when there are no matching field mappings for the given external system type.

{% hint style="info" %}
&#x20;Pair this with the KB publish flow: read the mappings here, then use them to build the payload you send to the external system.
{% endhint %}

***

### Fetch File Content By File IDs

**Description:** Fetches the ingested KB content for one or more uploaded files (uploaded through Copilot Upload), given their file IDs. For each file, the action resolves the file's document key and ingestion status, and — when the file has been successfully ingested — retrieves the document title and its rendered section content. Files are processed in parallel with a bounded thread pool and a maximum wait time, so files that are still being ingested or whose format is unsupported are reported individually rather than failing the whole action. Use this action to pull the text content of uploaded documents into a workflow (for example, to summarize or answer questions over uploaded files).

This action connects to internal Aisera services and does not require an external system integration.

**Configuration Parameters:** This action has no configuration parameters.

**Input:**

* **fileIds (List, Required):** The list of file IDs of the uploaded files whose content should be fetched. Blank entries are ignored.

**Output:**

* **status (String):** Overall execution status. Possible values: `Success` (content fetched for all requested files), `Partial` (content fetched for some files only), `Failed` (no file content could be fetched).
* **fileContents (Map):** A map keyed by file ID, where each value is a map holding the fetched document's `title`, `fileId`, `documentKey`, and concatenated section `content`. Only files with successfully retrieved content are included.
* **statusDetail (Map):** A map keyed by file ID indicating the per-file outcome. Possible values per file: `Success` (content ready), `NotAvailable` (ingestion not finished yet, no document key), `NotSupported` (file format not supported). – example: `{"file-abc123": "Success", "file-def456": "NotAvailable"}`

***

### Get Document Section Entities Action

**Description:** Retrieves an external KB document together with its section entities for a given document key and data source, and returns them as a single JSON payload. The payload includes the document's metadata (such as title, subject, external ID, URL, rating, author, status, page views, type, language, category, and meta) and an ordered list of its sections — each with its rendered content, paragraph index, and subject — sorted by paragraph index. Use this action when you need the full structured content of a KB document, section by section.

This action connects to internal Aisera services and does not require an external system integration.

**Configuration Parameters:** This action has no configuration parameters.

**Input:**

* **documentKey (String, Required):** The unique document key identifying the external document whose sections should be retrieved.
* **dataSourceId (Number, Required):** The ID of the data source that the document was ingested from.
* **isCommitted (Boolean, Optional):** Whether to fetch committed (`true`) or uncommitted (`false`) versions of the document and its sections. Defaults to `false`.

**Output:**

* **externalDocumentPayload (String):** The external document and its sections serialized as a JSON object string. Returns an empty string if the operation fails. – example:

  ```json
  {  "Title": "How to reset your VPN",  "Subject": "VPN",  "ExternalId": "kb0012345",  "URL": "https://example.service-now.com/kb_view.do?sysparm_article=KB0012345",  "Status": "Published",  "DocumentSections": [    {"Subject": "Overview", "ParagraphIndex": 0, "RenderContent": "This article explains..."},    {"Subject": "Steps", "ParagraphIndex": 1, "RenderContent": "1. Open the client..."}  ]}
  ```
* **success (Boolean):** Indicates whether the document and its sections were retrieved and serialized successfully.

{% hint style="info" %}
Pair this with the KB publish flow to construct the correct payload for publishing the document to an external system.
{% endhint %}

***

### Create Tenant Generated KBs Published History

**Description:** Records an audit/history entry for generated KBs that have been published (or attempted to be published) to an external System of Record (SOR). The request body lists one or more published-KB entries, each capturing the source generated KB document, its data source, the publish status, and — for successful publishes — who published it and the resulting external record. Use this action at the end of a KB publish operation to keep a traceable history of each publish event.

This action connects to an internal Aisera service (tenant server) and does not require an external system integration.

**Configuration Parameters:** This action has no configuration parameters.

**Input:**

* **payload (String, Required):** The publish-history request body as a JSON string. Each entry in `publishedKbDtos` supports: `sourceDocumentKey`, `dataSourceId`, `status` (`SUCCESS`, `IN_PROGRESS`, or `FAILED`), `externalSystemId`, `publishedBy`, `source`, `externalId`, and `displayId`. – example:

  ```json
  {  "publishedKbDtos": [    {      "sourceDocumentKey": "7931627452869191866",      "dataSourceId": "107556",      "status": "SUCCESS",      "externalSystemId": "201335",      "publishedBy": "system",      "source": "https://example.service-now.com/kb_view.do?sysparm_article=KB0012345",      "externalId": "c7dcff903b564390113523dc73e45af6",      "displayId": "KB0012345"    }  ]}
  ```
* **botId (Number, Optional):** The ID of the bot associated with the publish event.

**Output:**

* **success (Boolean):** Indicates whether the publish-history record was persisted successfully.
* **response (String):** The raw response body returned, serialized as a string. Empty on success.
* **mapResponse (Map):** The response parsed into a map of key/value pairs. Populated only when the operation returns a JSON body (e.g. an error response).

{% hint style="info" %}
Pair this with the KB publish flow to construct the correct payload for publishing the document to an external system.&#x20;
{% endhint %}
