UNPKG

sf-agent-framework

Version:

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

396 lines (279 loc) 9.84 kB
# Flow Documentation Template This template provides a comprehensive structure for documenting Salesforce Flows with clarity, completeness, and maintenance considerations. ## LLM Instructions {{#system}} You are a Salesforce Flow documentation expert. Create clear, comprehensive documentation that helps both administrators and developers understand the flow's purpose, logic, and maintenance requirements. Include visual representations, test scenarios, and troubleshooting guides. Focus on business context and technical implementation equally. {{/system}} ## Documentation Structure ```markdown # Flow: {{flowName}} ## Overview **Flow Type**: {{flowType}} **API Version**: {{apiVersion}} **Status**: {{status}} **Last Modified**: {{lastModified}} **Modified By**: {{modifiedBy}} ### Purpose {{businessPurpose}} ### Business Context - **Problem Statement**: {{problemStatement}} - **Solution Approach**: {{solutionApproach}} - **Expected Outcome**: {{expectedOutcome}} ### Key Features - {{feature1}} - {{feature2}} - {{feature3}} ## Flow Trigger {{#recordTriggered}} **Object**: {{object}} **Trigger Type**: {{triggerType}} **Entry Conditions**: ``` {{entryConditions}} ``` {{/recordTriggered}} {{#scheduled}} **Schedule**: {{scheduleFrequency}} **Start Date**: {{startDate}} **Time**: {{scheduledTime}} {{/scheduled}} {{#autolaunched}} **Launch Method**: {{launchMethod}} **Called By**: {{calledBy}} {{/autolaunched}} ## Input/Output Variables ### Input Variables | Variable Name | Data Type | Description | Required | Default Value | |--------------|-----------|-------------|----------|---------------| | {{varName}} | {{dataType}} | {{description}} | {{required}} | {{defaultValue}} | ### Output Variables | Variable Name | Data Type | Description | Example | |--------------|-----------|-------------|---------| | {{varName}} | {{dataType}} | {{description}} | {{example}} | ## Flow Architecture ### High-Level Diagram ``` [Start] [{{element1}}] [{{element2}}] [Decision: {{decision}}] Yes [{{element3}}] [End] No [{{element4}}] [End] ```` ### Detailed Logic #### Section 1: {{sectionName}} **Purpose**: {{sectionPurpose}} **Elements**: 1. **{{elementName}}** ({{elementType}}) - Purpose: {{elementPurpose}} - Configuration: ```yaml {{elementConfig}} ``` - Error Handling: {{errorHandling}} 2. **{{elementName}}** ({{elementType}}) - Purpose: {{elementPurpose}} - Logic: ``` IF {{condition}} THEN {{action}} ELSE {{alternativeAction}} ``` #### Section 2: {{sectionName}} {{sectionDetails}} ## Data Operations ### Get Records Elements | Element Name | Object | Filter Criteria | Fields Retrieved | Order By | |-------------|---------|-----------------|------------------|----------| | {{getName}} | {{object}} | {{filterCriteria}} | {{fields}} | {{orderBy}} | ### Create/Update Records | Element Name | Object | Operation | Field Assignments | |-------------|---------|-----------|-------------------| | {{elementName}} | {{object}} | {{operation}} | {{fieldAssignments}} | ### Delete Records | Element Name | Object | Filter Criteria | Error Handling | |-------------|---------|-----------------|----------------| | {{elementName}} | {{object}} | {{filterCriteria}} | {{errorHandling}} | ## Decision Elements ### {{decisionName}} **Purpose**: {{decisionPurpose}} | Outcome | Label | Condition | Next Element | |---------|-------|-----------|--------------| | {{outcome1}} | {{label}} | {{condition}} | {{nextElement}} | | {{outcome2}} | {{label}} | {{condition}} | {{nextElement}} | | Default | {{label}} | All other cases | {{nextElement}} | ## Loop Elements ### {{loopName}} - **Collection Variable**: {{collectionVar}} - **Item Variable**: {{itemVar}} - **Direction**: {{direction}} - **Purpose**: {{loopPurpose}} - **Elements in Loop**: - {{loopElement1}} - {{loopElement2}} ## Subflow Elements ### {{subflowName}} - **Flow Called**: {{flowCalled}} - **Input Mapping**: | Subflow Variable | Value Passed | |-----------------|--------------| | {{subflowVar}} | {{valuePassed}} | - **Output Mapping**: | Subflow Variable | Stored In | |-----------------|-----------| | {{subflowVar}} | {{storedIn}} | ## Actions ### Apex Actions | Action Name | Apex Class | Method | Parameters | Output | |------------|------------|---------|------------|---------| | {{actionName}} | {{apexClass}} | {{method}} | {{parameters}} | {{output}} | ### Email Alerts | Alert Name | Template | Recipients | Additional Emails | |-----------|----------|------------|-------------------| | {{alertName}} | {{template}} | {{recipients}} | {{additionalEmails}} | ## Error Handling ### Fault Paths | Element | Fault Type | Handling Strategy | User Message | |---------|------------|-------------------|--------------| | {{element}} | {{faultType}} | {{strategy}} | {{userMessage}} | ### Common Errors 1. **{{errorScenario}}** - **Cause**: {{errorCause}} - **Solution**: {{errorSolution}} - **Prevention**: {{errorPrevention}} ## Testing Scenarios ### Test Case 1: {{testCaseName}} **Scenario**: {{scenario}} **Test Data**: ```yaml {{testData}} ```` **Expected Result**: {{expectedResult}} **Actual Result**: {{actualResult}} **Status**: {{passOrFail}} ### Test Case 2: {{testCaseName}} {{testCaseDetails}} ### Edge Cases - {{edgeCase1}} - {{edgeCase2}} - {{edgeCase3}} ## Performance Considerations ### Query Optimization - **Get Records Limits**: {{getRecordsCount}} queries - **DML Operations**: {{dmlCount}} operations - **Loop Iterations**: Maximum {{loopMax}} expected ### Best Practices Applied - {{bestPractice1}} - {{bestPractice2}} - {{bestPractice3}} ### Performance Metrics | Metric | Target | Actual | Status | | ---------------- | ------------------- | ----------------- | ---------- | | Execution Time | < {{targetTime}} | {{actualTime}} | {{status}} | | Database Queries | < {{targetQueries}} | {{actualQueries}} | {{status}} | | DML Statements | < {{targetDML}} | {{actualDML}} | {{status}} | ## Dependencies ### Object Dependencies - **{{object}}**: {{fields}} fields required - **{{object}}**: {{relationship}} relationship ### Permission Dependencies - **Object Permissions**: {{objectPermissions}} - **Field Permissions**: {{fieldPermissions}} - **Apex Class Access**: {{apexAccess}} ### Configuration Dependencies - **Custom Metadata**: {{customMetadata}} - **Custom Settings**: {{customSettings}} - **Platform Events**: {{platformEvents}} ## Deployment Considerations ### Pre-Deployment Checklist - [ ] All test cases pass - [ ] Performance within limits - [ ] Error handling tested - [ ] Documentation reviewed - [ ] Permissions configured - [ ] Training completed ### Deployment Steps 1. {{deploymentStep1}} 2. {{deploymentStep2}} 3. {{deploymentStep3}} ### Post-Deployment Verification - [ ] Flow activated successfully - [ ] Monitor error emails - [ ] Verify data updates - [ ] User acceptance confirmed ## Maintenance ### Regular Reviews - **Frequency**: {{reviewFrequency}} - **Review Points**: - Performance metrics - Error logs - Business requirement changes - Platform updates impact ### Version History | Version | Date | Author | Changes | | ----------- | -------- | ---------- | ----------- | | {{version}} | {{date}} | {{author}} | {{changes}} | ### Known Limitations 1. {{limitation1}} 2. {{limitation2}} ### Future Enhancements - {{enhancement1}} - {{enhancement2}} ## Troubleshooting Guide ### Debug Steps 1. **Enable Debug Logs** ``` Setup Debug Logs New Select Flow User ``` 2. **Check Flow Interview** - Navigate to Setup Flow Interview Debug - Find failed interview - Review variable values 3. **Common Issues** **Issue**: {{issueDescription}} - **Symptoms**: {{symptoms}} - **Root Cause**: {{rootCause}} - **Resolution**: {{resolution}} ### Support Contacts - **Flow Owner**: {{ownerName}} ({{ownerEmail}}) - **Technical Lead**: {{techLead}} ({{techEmail}}) - **Business Contact**: {{businessContact}} ({{businessEmail}}) ## Related Documentation - [Flow Best Practices Guide]({{link}}) - [Object Schema Documentation]({{link}}) - [Integration Documentation]({{link}}) ``` ## Template Variables - `{{flowName}}`: Official flow name - `{{flowType}}`: Record-Triggered, Screen, Autolaunched, etc. - `{{businessPurpose}}`: Clear business objective - `{{element}}`: Flow element details - `{{testCase}}`: Test scenario details ## Visual Diagram Patterns ### Simple Linear Flow ``` [Start] [Get Records] [Update Records] [Send Email] [End] ``` ### Decision Branch Flow ``` [Decision] Yes No [Create Task] [Send Alert] [End] [End] ``` ### Loop Pattern ``` [Start] [Get Records] [Loop] [Process Record] [Update Record] [Next in Loop] ←┘ [End] ``` ## Documentation Best Practices 1. **Business Context First**: Always explain why before how 2. **Visual Aids**: Use diagrams for complex logic 3. **Test Coverage**: Document all test scenarios 4. **Maintenance Focus**: Include troubleshooting guides 5. **Version Control**: Track all changes 6. **Performance Metrics**: Include actual measurements ## Example Usage "Document a record-triggered flow on Opportunity that creates follow-up tasks and sends notifications based on stage changes" "Create documentation for a screen flow that guides users through a complex case creation process with conditional logic" "Generate documentation for a scheduled flow that processes overdue accounts and escalates them to management" ```