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.
- π 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
Navigate to System Definition > Script Includes and create three new Script Includes:
- AIAgentDataModelAnalyzer - Copy from
src/AIAgentDataModelAnalyzer.js - AIAgentExporter - Copy from
src/AIAgentExporter.js - AIAgentDocumentationGenerator - Copy from
src/AIAgentDocumentationGenerator.js
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');var exporter = new AIAgentExporter();
var pkg = exporter.exportAgent('AGENT_SYS_ID');
gs.print(JSON.stringify(pkg, null, 2));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);var analyzer = new AIAgentDataModelAnalyzer();
var report = analyzer.exportAsText();
gs.print(report);.
βββ 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
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 });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 });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);Generate sleek presentations showing AI agent workflows:
- Visual, interactive cards
- Quick drill-down into details
- Professional ServiceNow branding
Export agents between instances:
- Complete dependency capture
- Portable JSON format
- Preserves all relationships
Maintain audit trails of agent configurations:
- Version-controlled documentation
- Change tracking via git
- Stakeholder communication
Help teams understand complex agentic workflows:
- Visual hierarchy
- Plain-language descriptions
- Interactive exploration
Build custom reports and analyze agent configurations:
- Programmatic access to agent data
- Compare multiple agents
- Generate tool usage reports
- API integration for external systems
Discovers and analyzes the AI Agent data model structure.
Key Methods:
analyzeDataModel()- Complete data model analysisexportAsText()- Human-readable reportgetExportHierarchy()- Dependency graph
Use When:
- Learning the AI Agent data model
- Planning export strategies
- Understanding table relationships
Exports agents, tools, and workflows as portable JSON packages.
Key Methods:
exportAgent(sysId, options)- Export agent with dependenciesexportUsecase(sysId, options)- Export workflowexportTool(sysId, options)- Export standalone toolsaveToAttachment()- Save as file
Options:
includeTeam: true/false- Include team membershipexcludeSystemFields: true/false- Exclude audit fieldsincludeInactiveTools: true/false- Include inactive tools
Generates beautiful documentation in multiple formats (HTML and JSON).
Key Methods:
documentUsecase(sysId, options)- Document workflowdocumentAgent(sysId, options)- Document single agentdocumentFromExport(exportPackage)- Document from export
Options:
presentationMode: true/false- Presentation vs documentation style (HTML)dataMode: true/false- Generate structured JSON instead of HTMLincludeToolScripts: true/false- Include complete tool scriptsincludeTeam: true/false- Include team informationstandalone: true/false- Generate complete HTML page (HTML only)
- 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
- Workflow - High-level description and purpose
- Agents - Individual agent cards with roles
- Tools - Tool descriptions and input schemas (expandable)
- Details - Instructions and handbooks (behind click)
- All tool cards align to grid
- Input schema buttons align horizontally
- Responsive design for different screen sizes
Comprehensive documentation is available in the docs/ folder:
- ExporterREADME.md - Complete export guide
- DocumentationGeneratorREADME.md - Doc generator guide
- PRESENTATION_MODE.md - Presentation mode details
- DataModelAnalysisResults.md - Data model insights
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
- Copy the three JavaScript files from
src/to ServiceNow Script Includes - Set them as server-side (not client-callable)
- Mark them as Active
- Use the examples to get started
Contributions welcome! Areas for enhancement:
- Additional export formats
- Custom styling options
- Import functionality
- Automated testing
MIT License - See LICENSE file for details
Found a bug or have a feature request? Open an issue on GitHub.
Built for ServiceNow administrators and developers working with AI Agents