Skip to content

Now-AI-Foundry/Agent-Extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ServiceNow AI Agent Documentation Suite

A comprehensive toolkit for analyzing, exporting, and documenting ServiceNow AI Agents. Create beautiful presentations, migrate agents between instances, and maintain governance documentationβ€”all from code.

image image

🌟 Features

  • πŸ“Š Data Model Analysis - Discover and understand AI Agent table structures
  • πŸ“¦ Agent Export - Export complete agents with all dependencies as portable JSON
  • πŸ“– Documentation Generation - Create documentation in multiple formats:
    • Presentation Mode - Sleek, interactive cards perfect for presales demos
    • Documentation Mode - Comprehensive technical documentation for governance
    • Data Mode - Structured JSON for API integration and custom reporting

πŸš€ Quick Start

1. Install in ServiceNow

Navigate to System Definition > Script Includes and create three new Script Includes:

  1. AIAgentDataModelAnalyzer - Copy from src/AIAgentDataModelAnalyzer.js
  2. AIAgentExporter - Copy from src/AIAgentExporter.js
  3. AIAgentDocumentationGenerator - Copy from src/AIAgentDocumentationGenerator.js

2. Generate Presentation-Style Documentation

var docGen = new AIAgentDocumentationGenerator();
var html = docGen.documentUsecase('USECASE_SYS_ID', {
    presentationMode: true  // Sleek cards with drill-down
});

// Save as attachment
var user = new GlideRecord('sys_user');
user.get('user_name', gs.getUserName());
docGen.saveToAttachment(html, user, 'Workflow_Presentation.html');

3. Export an Agent

var exporter = new AIAgentExporter();
var pkg = exporter.exportAgent('AGENT_SYS_ID');
gs.print(JSON.stringify(pkg, null, 2));

4. Export as JSON Data

var docGen = new AIAgentDocumentationGenerator();
var jsonData = docGen.documentUsecase('USECASE_SYS_ID', {
    dataMode: true  // Returns structured JSON
});

// Parse and use the data
var data = JSON.parse(jsonData);
gs.info('Workflow: ' + data.name);
gs.info('Agents: ' + data.agents.length);

5. Analyze Data Model

var analyzer = new AIAgentDataModelAnalyzer();
var report = analyzer.exportAsText();
gs.print(report);

πŸ“‚ Project Structure

.
β”œβ”€β”€ src/                                    # Source code (Script Includes)
β”‚   β”œβ”€β”€ AIAgentDataModelAnalyzer.js        # Data model discovery
β”‚   β”œβ”€β”€ AIAgentExporter.js                 # Export agents as JSON
β”‚   └── AIAgentDocumentationGenerator.js   # Generate HTML docs
β”‚
β”œβ”€β”€ docs/                                   # Documentation
β”‚   β”œβ”€β”€ DataModelAnalysisResults.md        # Data model insights
β”‚   β”œβ”€β”€ ExporterREADME.md                  # Export guide
β”‚   β”œβ”€β”€ DocumentationGeneratorREADME.md    # Doc generator guide
β”‚   β”œβ”€β”€ PRESENTATION_MODE.md               # Presentation mode details
β”‚   β”œβ”€β”€ ULTRA_COMPACT_UPDATE.md            # UI optimization notes
β”‚   └── ...
β”‚
β”œβ”€β”€ examples/                               # Usage examples
β”‚   β”œβ”€β”€ UsageExamples.js                   # Analyzer examples
β”‚   β”œβ”€β”€ ExporterUsageExamples.js           # Export examples
β”‚   β”œβ”€β”€ DocumentationGeneratorExamples.js  # Doc generator examples
β”‚   β”œβ”€β”€ test.html                          # Sample output
β”‚   └── testworkflow.html                  # Sample workflow output
β”‚
└── README.md                               # This file

πŸ“– Documentation Modes

Presentation Mode

Perfect for presales demos and executive presentations:

  • βœ… Color-coded agent cards
  • βœ… Interactive drill-down (click to expand)
  • βœ… Tool descriptions and input schemas
  • βœ… Ultra-compact layout (50-60% more content on screen)
  • βœ… ServiceNow branding
var html = docGen.documentUsecase('SYS_ID', { presentationMode: true });

Documentation Mode

Comprehensive technical documentation for governance:

  • βœ… Complete agent configuration
  • βœ… Full prompts and instructions
  • βœ… Tool definitions with schemas
  • βœ… Export metadata
  • βœ… Scrollable sections for long content
var html = docGen.documentUsecase('SYS_ID', { presentationMode: false });

Data Mode

Structured JSON for programmatic analysis and integration:

  • βœ… Clean, parseable JSON structure
  • βœ… Normalized schema format
  • βœ… All agent and tool data
  • βœ… API-friendly format
  • βœ… Perfect for custom reports
var jsonData = docGen.documentUsecase('SYS_ID', { dataMode: true });
var data = JSON.parse(jsonData);

🎯 Use Cases

1. Presales Demonstrations

Generate sleek presentations showing AI agent workflows:

  • Visual, interactive cards
  • Quick drill-down into details
  • Professional ServiceNow branding

2. Agent Migration

Export agents between instances:

  • Complete dependency capture
  • Portable JSON format
  • Preserves all relationships

3. Governance & Compliance

Maintain audit trails of agent configurations:

  • Version-controlled documentation
  • Change tracking via git
  • Stakeholder communication

4. Onboarding & Training

Help teams understand complex agentic workflows:

  • Visual hierarchy
  • Plain-language descriptions
  • Interactive exploration

5. Custom Reporting & Analysis

Build custom reports and analyze agent configurations:

  • Programmatic access to agent data
  • Compare multiple agents
  • Generate tool usage reports
  • API integration for external systems

πŸ“‹ Core Components

1. AIAgentDataModelAnalyzer

Discovers and analyzes the AI Agent data model structure.

Key Methods:

  • analyzeDataModel() - Complete data model analysis
  • exportAsText() - Human-readable report
  • getExportHierarchy() - Dependency graph

Use When:

  • Learning the AI Agent data model
  • Planning export strategies
  • Understanding table relationships

2. AIAgentExporter

Exports agents, tools, and workflows as portable JSON packages.

Key Methods:

  • exportAgent(sysId, options) - Export agent with dependencies
  • exportUsecase(sysId, options) - Export workflow
  • exportTool(sysId, options) - Export standalone tool
  • saveToAttachment() - Save as file

Options:

  • includeTeam: true/false - Include team membership
  • excludeSystemFields: true/false - Exclude audit fields
  • includeInactiveTools: true/false - Include inactive tools

3. AIAgentDocumentationGenerator

Generates beautiful documentation in multiple formats (HTML and JSON).

Key Methods:

  • documentUsecase(sysId, options) - Document workflow
  • documentAgent(sysId, options) - Document single agent
  • documentFromExport(exportPackage) - Document from export

Options:

  • presentationMode: true/false - Presentation vs documentation style (HTML)
  • dataMode: true/false - Generate structured JSON instead of HTML
  • includeToolScripts: true/false - Include complete tool scripts
  • includeTeam: true/false - Include team information
  • standalone: true/false - Generate complete HTML page (HTML only)

🎨 Presentation Mode Features

Visual Design

  • Color-coded agents - Each agent gets a unique color
  • Hero card - Workflow overview at the top
  • Compact layout - 50-60% more content visible
  • Interactive cards - Click to expand/collapse

Information Hierarchy

  1. Workflow - High-level description and purpose
  2. Agents - Individual agent cards with roles
  3. Tools - Tool descriptions and input schemas (expandable)
  4. Details - Instructions and handbooks (behind click)

Alignment & Layout

  • All tool cards align to grid
  • Input schema buttons align horizontally
  • Responsive design for different screen sizes

πŸ“š Documentation

Comprehensive documentation is available in the docs/ folder:

πŸ’‘ Examples

Check the examples/ folder for practical usage examples:

  • UsageExamples.js - Analyzer examples
  • ExporterUsageExamples.js - 12 export scenarios
  • DocumentationGeneratorExamples.js - 16 documentation scenarios
  • test.html - Sample documentation output
  • testworkflow.html - Sample workflow presentation

πŸ”§ Installation

  1. Copy the three JavaScript files from src/ to ServiceNow Script Includes
  2. Set them as server-side (not client-callable)
  3. Mark them as Active
  4. Use the examples to get started

🀝 Contributing

Contributions welcome! Areas for enhancement:

  • Additional export formats
  • Custom styling options
  • Import functionality
  • Automated testing

πŸ“„ License

MIT License - See LICENSE file for details

πŸ› Issues & Support

Found a bug or have a feature request? Open an issue on GitHub.

πŸŽ“ Learning Resources


Built for ServiceNow administrators and developers working with AI Agents

About

Autogenerate AIA Documentation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published