UNPKG

sf-agent-framework

Version:

AI Agent Orchestration Framework for Salesforce Development - Two-phase architecture with 70% context reduction

300 lines (225 loc) 6.92 kB
# Content Generator Utility - Agent Instructions ## Purpose This utility provides instructions for AI agents to generate automated content creation solutions for Salesforce documentation, training materials, code templates, and communication content. ## Agent Instructions ### When to Generate Content Automation Generate content automation components when: - Documentation needs to be created from metadata - Training materials require frequent updates - Code templates need standardization - Release notes need automation - User guides require dynamic generation - API documentation needs to stay current - Communication templates need personalization ### Core Components to Generate #### 1. Document Generator Engine Generate an Apex class that: - Supports multiple document types (User Guide, Admin Guide, API Docs, etc.) - Processes templates with dynamic data - Handles multiple output formats (PDF, HTML, DOCX, Markdown) - Integrates with metadata APIs - Supports multi-language generation - Includes screenshot automation capabilities Key methods to implement: - `generateDocument()` - Main generation method - `processTemplate()` - Template processing with variables - `gatherMetadata()` - Collect org metadata dynamically - `convertToFormat()` - Format conversion logic - `addScreenshots()` - Automated screenshot inclusion #### 2. Template Processing Engine Create a template processor that supports: - Variable substitution using mustache-style syntax `{{variable}}` - Conditional blocks `{{#if condition}}...{{/if}}` - Loop constructs `{{#each items}}...{{/each}}` - Partial template includes `{{> partial_name}}` - Custom helper functions - Markdown to HTML conversion - Dynamic table generation - Nested template support Template syntax to support: ``` {{variable}} - Simple variable replacement {{#if condition}} content {{/if}} - Conditionals {{#each list}} {{this.field}} {{/each}} - Loops {{> header}} - Include partials {{formatDate dateField}} - Helper functions ``` #### 3. Code Template Generator Implement generators for: - Apex Controllers with standard CRUD operations - Service classes with business logic patterns - Trigger frameworks with handler patterns - Test classes with proper data factories - Lightning Web Components with standard patterns - Batch classes with error handling - REST/SOAP service implementations - Integration patterns ### Configuration Requirements #### Custom Objects Create these objects: ```yaml Content_Template__c: - Name (Text) - Type__c (Picklist) - Template_Body__c (Long Text Area) - Active__c (Checkbox) - Language__c (Picklist) - Version__c (Number) Generated_Document__c: - Template__c (Lookup) - Generated_Date__c (DateTime) - Output_Format__c (Text) - Content_Version_Id__c (Text) - Parameters__c (Long Text Area) ``` #### Template Library Structure Organize templates by: - Document type (user guides, API docs, etc.) - Output format (PDF, HTML, etc.) - Language/locale - Version - Industry/vertical ### Implementation Patterns #### Metadata-Driven Generation 1. Query object and field metadata 2. Extract relationships and dependencies 3. Generate documentation automatically 4. Include field descriptions and help text 5. Document validation rules and workflows #### Dynamic Content Assembly 1. Load base template 2. Inject dynamic sections 3. Process conditional content 4. Include auto-generated examples 5. Add contextual screenshots #### Multi-Format Output 1. Generate content in markdown 2. Convert to requested format 3. Apply styling and branding 4. Include media assets 5. Package for distribution ### Template Types to Generate #### User Documentation Templates - Getting Started Guides - Feature Walkthroughs - FAQ Documents - Troubleshooting Guides - Best Practices Guides #### Technical Documentation Templates - API Reference Documentation - Integration Guides - Data Model Documentation - Security Documentation - Architecture Diagrams #### Training Material Templates - Course Outlines - Lab Exercises - Quick Reference Cards - Video Script Templates - Assessment Questions #### Communication Templates - Release Notes - Change Notifications - Training Announcements - Success Stories - Executive Summaries ### Integration Requirements #### Salesforce CMS Integration - Store templates in CMS - Version control templates - Manage approval workflows - Track template usage - Enable collaboration #### File Storage Integration - Use ContentVersion for storage - Implement folder structures - Set sharing permissions - Enable versioning - Track downloads #### External System Integration - Export to SharePoint/Google Drive - Publish to knowledge bases - Send to email systems - Post to Slack/Teams - Update wikis ### Best Practices to Implement 1. **Template Management** - Version all templates - Test before deployment - Document template syntax - Provide example usage - Enable template preview 2. **Performance Optimization** - Cache compiled templates - Process asynchronously - Limit template complexity - Optimize queries - Use bulk operations 3. **Quality Assurance** - Validate generated content - Check formatting consistency - Verify link integrity - Test all output formats - Review accessibility 4. **Maintenance** - Schedule template reviews - Update deprecated content - Archive old versions - Monitor usage metrics - Gather user feedback ### Error Handling Instructions Implement error handling for: 1. Template syntax errors 2. Missing data scenarios 3. Format conversion failures 4. Permission issues 5. Storage limitations Error recovery strategies: - Provide meaningful error messages - Log detailed error information - Offer fallback templates - Notify administrators - Attempt auto-correction ### Security Considerations Implement security measures: 1. Sanitize all user inputs 2. Prevent template injection 3. Enforce field-level security 4. Respect sharing rules 5. Audit content generation ### Testing Requirements Generate test classes that: 1. Test all template types 2. Verify variable substitution 3. Test conditional logic 4. Validate loop processing 5. Check format conversions ### Monitoring and Analytics Track and report on: - Template usage frequency - Generation success rates - Popular document types - Error patterns - Performance metrics - User satisfaction ### Advanced Features to Consider 1. **AI-Enhanced Generation** - Use Einstein GPT for content - Auto-generate summaries - Suggest improvements - Translate content - Personalize output 2. **Interactive Documents** - Embed forms - Add feedback widgets - Include surveys - Enable comments - Track engagement 3. **Automated Workflows** - Schedule generation - Trigger on changes - Auto-distribute - Update dependencies - Archive old versions