# Migrate Workflow to n8n - Workflow Instructions ```xml The workflow execution engine is governed by: {project_root}/{bmad_folder}/core/tasks/workflow.xml You MUST have already loaded and processed: {installed_path}/workflow.yaml This workflow migrates automation workflows from other platforms to n8n. Before asking any questions, analyze what the user has already told you Review the user's initial request and conversation history Extract any mentioned: source platform, workflow details, integrations, file paths Summarize your understanding Skip directly to Step 2 (Check Context7 MCP) Note what you already know Only ask about missing information in Step 1 Proceed with full elicitation in Step 1 Ask Question 1: "Which platform are you migrating from?" Present numbered options: 1. Zapier - Migrate Zapier Zaps to n8n 2. Make (Integromat) - Migrate Make scenarios to n8n 3. HubSpot Workflows - Migrate HubSpot workflows to n8n 4. Microsoft Power Automate - Migrate Power Automate flows to n8n 5. IFTTT - Migrate IFTTT applets to n8n 6. Other - Specify another automation platform WAIT for user selection (1-6) Store selection in {{source_platform}} Ask: "Please specify the platform you're migrating from" WAIT for user input Store in {{source_platform}} Ask Question 2: "How will you provide the workflow to migrate?" Present numbered options: 1. Describe it - Explain what the workflow does 2. Provide export file - Upload/paste workflow export file 3. Provide screenshots - Share workflow screenshots 4. Provide documentation - Share workflow documentation WAIT for user selection (1-4) Ask: "Please describe what the workflow does (trigger, actions, logic)" WAIT for user input Store in {{workflow_description}} Ask: "Please provide the workflow export file path or paste the content" WAIT for user input Store in {{workflow_file}} or {{workflow_content}} Ask: "Please share the workflow screenshots and describe the flow" WAIT for user input Store in {{workflow_description}} Ask: "Please provide the workflow documentation" WAIT for user input Store in {{workflow_description}} Ask Question 3: "What is the trigger for this workflow?" Present numbered options: 1. Webhook/HTTP Request - Triggered by incoming HTTP requests 2. Schedule/Cron - Runs on a schedule 3. Form Submission - Triggered by form submissions 4. Database Change - Triggered by database events 5. Email - Triggered by incoming emails 6. Service Event - Triggered by external service (Slack, Google Sheets, etc.) 7. Not sure - Will determine from workflow details WAIT for user selection (1-7) Store selection in {{trigger_type}} Ask Question 4: "What integrations/services does this workflow use?" Ask: "Please list all services (e.g., Slack, Google Sheets, HubSpot, etc.)" WAIT for user input Store in {{integrations_used}} Ask Question 5: "How complex is the workflow?" Present numbered options: 1. Simple - Linear flow with 3-5 steps 2. Medium - Some conditional logic, 6-10 steps 3. Complex - Multiple branches, loops, 11-20 steps 4. Very Complex - Advanced logic, 20+ steps WAIT for user selection (1-4) Store selection in {{complexity}} Ask Question 6: "What should the migrated workflow be named?" WAIT for user input Store in {{workflow_name}} Ask Question 7: "Where should the n8n workflow file be saved?" Present numbered options: 1. Default location - workflows/[workflow-name].json 2. Custom path - Specify your own file path 3. Project root - Save in main project directory WAIT for user selection (1-3) Ask for specific path WAIT for user input Store final path in {{save_location}} Check if Context7 MCP server is configured Try to list available MCP tools Store true in {{context7_available}} Proceed to Step 3 Store false in {{context7_available}} Inform user: "Context7 MCP not configured. Proceeding with built-in n8n knowledge." Proceed to Step 4 Resolve n8n library ID using Context7 Query Context7 for relevant n8n documentation based on: - Integrations used: {{integrations_used}} - Trigger type: {{trigger_type}} - Source platform: {{source_platform}} Store relevant documentation snippets for reference Load {{platform_mappings}} file Extract mappings for {{source_platform}} Identify equivalent n8n nodes for source platform components Parse source workflow file/content Extract workflow structure Analyze workflow based on description and details: 1. Identify trigger type and configuration 2. List all actions/steps in order 3. Identify conditional logic (if/then branches) 4. Identify loops or iterations 5. Identify data transformations 6. Identify error handling 7. Map integrations to n8n nodes Present analysis to user: - Source trigger: [platform-specific trigger] - n8n trigger: [mapped n8n node] - Source actions: [list with platform names] - n8n actions: [list with n8n node types] - Logic: [conditional branches, loops] - Transformations: [data mapping needs] Load {{helpers}} for node creation guidelines Load {{templates}} for reference Design n8n workflow structure: 1. Map source trigger to n8n trigger node 2. Map each source action to n8n node(s) 3. Convert conditional logic to IF/Switch nodes 4. Convert loops to Split In Batches nodes 5. Add Set/Code nodes for data transformations 6. Plan node connections 7. Add error handling where needed Present migration plan to user: - n8n Trigger: [node type and configuration] - n8n Nodes: [list with descriptions] - Connections: [flow diagram] - Data Mappings: [field mappings] - Credentials Needed: [list of integrations requiring auth] Ask: "Does this migration plan look correct?" Present numbered options: 1. Yes - Proceed with migration 2. No - Adjust the plan 3. Add more details - Provide additional information WAIT for user selection (1-3) Ask: "What changes or additions are needed?" WAIT for user input Adjust plan based on feedback Repeat this step Follow guidelines from {{helpers}} for proper node creation Initialize workflow structure: { "name": "{{workflow_name}}", "nodes": [], "connections": {}, "active": false, "settings": { "executionOrder": "v1" }, "tags": [ { "name": "migrated-from-{{source_platform}}" } ] } Build nodes ONE at a time: For Each Mapped Node: 1. Generate unique node ID 2. Set node name (descriptive, unique) 3. Set node type from platform mappings 4. Set typeVersion (usually 1) 5. Calculate position (220px spacing) 6. Configure parameters based on source workflow 7. Map data fields from source to n8n format 8. Add credentials placeholder if needed 9. Set error handling if required For Data Transformations: 1. Identify field mappings needed 2. Create Set nodes for simple mappings 3. Create Code nodes for complex transformations 4. Use n8n expressions: ={{ $json.fieldName }} 5. Handle data type conversions 6. Handle date/time format differences For Conditional Logic: 1. Create IF nodes for if/then branches 2. Create Switch nodes for multiple conditions 3. Map source conditions to n8n condition format 4. Set up true/false branches (index 0/1) For Connections: 1. Connect trigger to first action 2. Connect actions in sequence 3. Connect conditional branches 4. Connect merge points 5. Validate all connections Add migration notes as workflow tags Validate all node IDs are unique Validate all connections reference existing nodes Add comment nodes or documentation: - Source platform: {{source_platform}} - Migration date: {timestamp} - Credentials to configure: [list] - Testing notes: [important considerations] - Platform-specific differences: [notes] Save workflow to {{save_location}} NEVER delete the file if validation fails - always fix syntax errors Run: node -e "JSON.parse(require('fs').readFileSync('{{save_location}}', 'utf8')); console.log('✓ Valid JSON')" Read the error message carefully - it shows the syntax error and position Open the file and navigate to the error location Fix the syntax error (add missing comma, bracket, or quote as indicated) Save the file Re-run validation with the same command Repeat until validation passes Once validation passes, confirm with user: "Workflow migrated successfully to {{save_location}}" Provide post-migration instructions: 1. Import the JSON file into n8n 2. Configure credentials for these services: [list] 3. Review and update these data mappings: [list] 4. Test with sample data before activating 5. Compare outputs with original platform 6. Monitor initial executions closely Highlight platform-specific differences: - Authentication: [differences] - Data formats: [differences] - Scheduling: [differences] - Error handling: [differences] Ask: "Would you like help with any specific part of the migration?" Present numbered options: 1. No - I'm ready to test 2. Yes - Explain credential setup 3. Yes - Explain data mappings 4. Yes - Explain testing approach WAIT for user selection (1-4) Provide requested explanation Validate against checklist at {{validation}} using {{bmad_folder}}/core/tasks/validate-workflow.xml ```