This tool extracts knowledge base articles from a ServiceNow instance and converts them to markdown format for easy reading and processing.
- Extracts articles from specified knowledge bases
- Maintains folder structure (knowledge base > category > articles)
- Converts HTML content to clean markdown
- Preserves article metadata (author, dates, etc.)
- Handles authentication securely
- Supports filtering specific knowledge bases
- Python 3.8 or higher
- Access to a ServiceNow instance
- API credentials with access to knowledge bases
- Clone this repository:
git clone <repository-url>
cd servicenow-kb-extractor
- Create and activate a virtual environment (recommended):
# Windows
python -m venv venv
venv\Scripts\activate
# Linux/Mac
python -m venv venv
source venv/bin/activate
- Install required packages:
pip install -r requirements.txt
- Copy the example environment file:
cp .env.example .env
- Edit
.env
file with your ServiceNow instance details:
SERVICENOW_INSTANCE=your-instance.service-now.com
SERVICENOW_USERNAME=your-username
SERVICENOW_PASSWORD=your-password
# Optional: Specify knowledge bases to extract (comma-separated)
SERVICENOW_KNOWLEDGE_BASES=IT,HR and Benefits
Run the script:
python extract-articles.py
The script will:
- Connect to your ServiceNow instance
- Extract specified knowledge bases (or all if none specified)
- Create an 'articles' folder in the script directory
- Save all articles as markdown files with metadata
The output structure will be:
articles/
├── IT/
│ ├── Security/
│ │ └── What-is-Spam.md
│ └── General/
│ └── About-Windows-10.md
└── HR/
└── Benefits/
└── Employee-Benefits.md