Load ServiceNow Knowledge Base Articles
LlamaIndex loader that reads ServiceNow Knowledge Base articles via pysnc, with custom parsers and event-driven progress tracking.
Why it matters
Ingest and process your ServiceNow Knowledge Base articles to make them accessible for AI-powered retrieval and analysis. This asset connects to your ServiceNow instance to extract valuable knowledge base content.
Outcomes
What it gets done
Connect to your ServiceNow instance using provided credentials.
Retrieve knowledge base articles, optionally filtering by workflow state.
Download and process associated attachments using custom parsers.
Prepare extracted data for use in AI applications via LlamaIndex.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-reader-readers-service-now | bash Overview
ServiceNow Knowledge Base Loader
A LlamaIndex loader for ServiceNow Knowledge Base articles, built on the pysnc library. It requires at least one custom HTML parser to process article bodies and supports basic or OAuth2 authentication. Reach for it when you need ServiceNow's knowledge base content searchable outside ServiceNow, and are prepared to supply your own parser classes for articles and attachments.
What it does
The ServiceNow Knowledge Base Loader (SnowKBReader) reads Knowledge Base articles from a ServiceNow instance into LlamaIndex documents. Install with pip install llama-index-readers-service-now. Under the hood it uses the pysnc library to connect to ServiceNow and retrieve knowledge base articles, downloading and processing attachments automatically alongside the article bodies.
When to use - and when NOT to
Use it when you need ServiceNow's internal knowledge base content indexed for retrieval or search outside ServiceNow itself. It is not a drop-in loader: the reader ships with no built-in content parsers, so it cannot process a single article on its own. At minimum an HTML parser must be supplied to handle article bodies, and any attachment file types (the source shows a DOCX example built on the MarkItDown library) need their own custom parser classes inheriting from BaseReader and implementing load_data. If you cannot commit to writing at least an HTML parser, this reader will not function. The source's own example is a DocxParser class: it wraps the MarkItDown library, and its load_data method calls self.markitdown.convert(source=file_path) and returns a single-element list of Document(text=result.markdown, metadata={"file_path": str(file_path)}) - a useful template for writing parsers for other attachment types.
Inputs and outputs
Required inputs to initialize SnowKBReader are the ServiceNow instance name (e.g. "dev12345", without the .service-now.com suffix), username, password, and a custom_parsers dictionary mapping FileType enum values to BaseReader instances. Optional client_id/client_secret switch authentication to OAuth2 client-credentials password grant; without them the reader falls back to basic username/password auth. Other configurable options include the knowledge base table (defaults to kb_knowledge), the workflow state filter (defaults to "Published"), and a temporary folder for file processing. The reader can load articles by sys_id or KB number, returning LlamaIndex documents built from the parsed article and attachment content.
Integrations
The reader is instrumented with LlamaIndex's standard event dispatch system, firing events such as SNOWKBTotalPagesEvent, SNOWKBPageFetchStartEvent, SNOWKBPageFetchCompletedEvent, SNOWKBPageSkippedEvent, SNOWKBPageFailedEvent, and matching attachment-processing events (SNOWKBAttachmentProcessingStartEvent, SNOWKBAttachmentProcessedEvent, SNOWKBAttachmentSkippedEvent, SNOWKBAttachmentFailedEvent). All of these inherit from LlamaIndex's BaseEvent and can be monitored through the standard instrumentation dispatcher, giving visibility into page and attachment progress during a load.
Who it's for
Teams building internal search, chatbots, or RAG pipelines over enterprise ServiceNow knowledge bases who are comfortable writing their own parser classes for HTML (mandatory) and any attachment formats they need, and who want fine-grained event visibility into a potentially long-running knowledge base sync rather than a black-box bulk export.
pip install llama-index-readers-service-now
Source README
ServiceNow Knowledge Base Loader
pip install llama-index-readers-service-now
This loader reads Knowledge Base articles from a ServiceNow instance. The user needs to specify the ServiceNow instance URL and authentication credentials to initialize the SnowKBReader.
The loader uses the pysnc library to connect to ServiceNow and retrieve knowledge base articles. It supports authentication via username/password (basic auth) or with OAuth2 client credentials (password grant flow).
Important: This reader requires custom parsers for processing different file types. At minimum, an HTML parser must be provided for processing article bodies.
Authentication
The reader requires the following authentication parameters:
Required:
instance: Your ServiceNow instance name (e.g., "dev12345" - without .service-now.com)username: ServiceNow usernamepassword: ServiceNow passwordcustom_parsers: Dictionary mapping FileType enum values to BaseReader instances (REQUIRED)
Optional (for OAuth2 password grant flow):
client_id: OAuth2 client ID (if provided, client_secret is also required)client_secret: OAuth2 client secret (if provided, client_id is also required)
If OAuth2 parameters are not provided, the reader will use basic authentication with username/password.
Event System
The ServiceNow Knowledge Base reader uses LlamaIndex's standard instrumentation event system to provide detailed tracking of the loading process. Events are fired at various stages during knowledge base article retrieval and attachment processing.
Available Events
SNOWKBTotalPagesEvent: Fired when the total number of pages to process is determinedSNOWKBPageFetchStartEvent: Fired when page data fetch startsSNOWKBPageFetchCompletedEvent: Fired when page data fetch completes successfullySNOWKBPageSkippedEvent: Fired when a page is skippedSNOWKBPageFailedEvent: Fired when page processing failsSNOWKBAttachmentProcessingStartEvent: Fired when attachment processing startsSNOWKBAttachmentProcessedEvent: Fired when attachment processing completes successfullySNOWKBAttachmentSkippedEvent: Fired when an attachment is skippedSNOWKBAttachmentFailedEvent: Fired when attachment processing fails
All events inherit from LlamaIndex's BaseEvent class and can be monitored using the standard LlamaIndex instrumentation dispatcher.
Features
- Load knowledge base articles by sys_id or KB numbers
- Automatically download and process attachments
- Requires custom parsers for different file types (HTML parser is mandatory)
- LlamaIndex event-driven architecture for monitoring processing
- Configurable knowledge base table (defaults to
kb_knowledge) - Support for filtering by workflow state (defaults to "Published")
- Configurable temporary folder for file processing
Required Custom Parsers
The reader requires custom parsers to process different file types. At minimum, an HTML parser must be provided for processing article bodies.
Important: The ServiceNow reader does not include built-in parsers. You must define your own custom parser classes that inherit from BaseReader and implement the load_data method.
Example Custom Parser Implementation
from llama_index.core.readers.base import BaseReader
from llama_index.core.schema import Document
from markitdown import MarkItDown
from typing import List, Union
import pathlib
class DocxParser(BaseReader):
"""DOCX parser using MarkItDown for text extraction."""
def __init__(self):
self.markitdown = MarkItDown()
def load_data(
self, file_path: Union[str, pathlib.Path], **kwargs
) -> List[Document]:
"""Load and parse a DOCX file."""
result = self.markitdown.convert(source=file_path)
return [
Document(
text=result.markdown, metadata={"file_path": str(file_path)}
)
]
class HTMLParser(BaseReade
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.