# ServiceNow: Retrieve Runbook or Knowledge Base Article

Retrieve runbook or knowledge article content from your ServiceNow instance


> **Availability:** See the [Incident Workflow Actions Overview table](/workflow-actions) for the plans this workflow is available on.

## Description

The action obtains a **Bearer token** using the same OAuth password grant as the Workflow Integration, then reads Knowledge article data from ServiceNow. You can identify an article by **URL,** **sys_id**, or **KB number**; if you leave the identifier blank, the action returns the first 10 articles from the primary Knowledge table query (up to the API limit configured in the integration).

> **Include Attachments **defaults to **false**. When set to true, the action adds JSON metadata about attachments linked to the article (not the attachment file binaries).

### Prerequisites

- A ServiceNow instance with OAuth password grant configured and a Workflow Integration connection using ServiceNow OAuth Connection fields as described in [Creating a Workflow Integration](/ai-automation/automation/incident-workflows/workflow-integrations#create-a-workflow-integration). 
- The integration user and OAuth client must allow successful token exchange and **read **access to the Knowledge tables and attachment API used by the action. 
- Managed Knowledge / `sn_km_mr_st_kb_knowledge` available on the instance if you rely on this action’s default code paths.

## Instructions

1. If you have not done so, follow the instructions to [Create an Incident Workflow](/ai-automation/automation/incident-workflows#create-an-incident-workflow).
2. When the instructions prompt you to [add actions](/ai-automation/automation/incident-workflows#add-actions), select **this action**.
3. Enter the following **Inputs** and click **Save**.
4. Continue following instructions to **Publish** the Workflow.
5. When the action runs, you will see the **Outputs** listed below.

## Inputs

> **Field References:** Fields with the **\{+\}** icon accept [Field References](/ai-automation/automation/incident-workflows#field-references), which can be useful for referencing incident data or outputs created in prior workflow steps. To add Field References, click **\{+\}**, or enter `{{`, and select relevant fields. Refer to the [Field References](/ai-automation/automation/incident-workflows#field-references) article for more information.

| Name                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| :------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **ServiceNow OAuth Connection**        | The ServiceNow OAuth Workflow Integration connection (URL, OAuth client, and user credentials configured in PagerDuty). If you have not yet configured a ServiceNow OAuth integration, please see the [ServiceNow Integration](/ai-automation/automation/incident-workflows/workflow-integrations#servicenow-oauth) instructions. |
| **Knowledge Article URL or KB Number** | A full article URL (including `sys_id` or `sysparm_article` as used by your instance), a 32-character **sys_id,** a **KB number** (for example `KB0012345`), or leave **blank** to retrieve the first **10** articles returned by the default table query.                                                                                                                                                             |
| **Include Attachments**                | When **true**, retrieves **metadata** about attachments associated with the article as JSON. Default: **false**.                                                                                                                                                                                                                                                                                                       |

> **How the action resolves articles**
>
> - **Article URL** — If the value looks like a URL and contains `kb_knowledge`, `sys_id`, or `sysparm_article`, the action extracts a **32-character sys_id** from `sys_id=` or `sysparm_article=` query parameters. If no sys_id can be parsed, the action fails with an error asking for a valid URL.
> - **sys_id only** — If you paste a 32-character hexadecimal string, it is treated as **sys_id** directly.
> - **KB number **— Otherwise, non-empty text is treated as a KB number (for example `KB0012345`). The action queries the Knowledge table and selects the matching article from the result set.
> - **Blank input **— If the field is empty (or only placeholder-like quotes), the action requests the first 10 articles (`sysparm_limit=10`) without a KB number filter. Downstream steps should handle multiple results only if your workflow expects list behavior.

## Outputs

| Name                  | Description                                                                                                                                              |
| :-------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **KB Number**         | Article identifier (for example `KB0012345`).                                                                                                            |
| **Short Description** | Article title.                                                                                                                                           |
| **Article Content**   | Full article body in **plain text **as returned by ServiceNow.                                                                                           |
| **Author**            | Article author (display value when provided by the API).                                                                                                 |
| **Knowledge Base**    | Name of the knowledge base containing the article (from supplemental fields when available).                                                             |
| **Workflow State**    | Current workflow state of the article when returned by ServiceNow.                                                                                       |
| **Last Updated**      | Timestamp of the last update.                                                                                                                            |
| **Last Updated By**   | User who last updated the article (display value when available).                                                                                        |
| **Attachments**       | JSON attachment metadata when Include Attachments is **true** and the attachment API succeeds; omitted when attachment retrieval is off or not returned. |
| **Result**            | `Success` or `Failed`.                                                                                                                                   |
| **Result Summary**    | Short description of the outcome.                                                                                                                        |
| **Error**             | Populated when the action fails (for example missing connection, OAuth failure, article not found, or API errors).                                       |
