-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Copilot based migration from N8N to SIM workflows #2747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Gaurav Chadha <[email protected]>
Signed-off-by: Gaurav Chadha <[email protected]>
|
@Chadha93 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR implements a cost-optimized, copilot-based migration feature from N8N to SIM workflows.
Key Changes
Backend (route.ts)
- Auto-detects migration requests by checking if message contains "convert this n8n workflow"
- Dynamically injects specialized migration system prompt into agent contexts
- Leverages existing copilot infrastructure without modifying core flow
Frontend Components
MigrationDialog: New modal for uploading/pasting N8N workflow JSON with validationWelcome: Added "Migrate From N8n" button in build modeCopilot: Integrated dialog state management and submission flow
Migration Utilities
formatMigrationRequest: Server action that extracts workflow metadata and creates structured promptgetMigrationSystemPrompt: Provides efficient conversion instructions (create all blocks in one call, then autolayout)
Implementation Approach
The feature uses a minimal prompt strategy that leverages Copilot's existing knowledge:
- User uploads N8N workflow JSON via dialog
- Format utility extracts metadata (node count, types, workflow name)
- Structured message is submitted to copilot chat
- Backend detects migration request and injects specialized instructions
- Copilot creates all blocks in one
edit_workflowcall, then autolayouts
Architecture Benefits
- Cost efficient: $0.03-$0.08 per migration via minimal prompt
- Clean separation: Migration logic isolated in
/lib/migration - Non-invasive: Uses existing copilot infrastructure
- Progressive enhancement: BETA feature that doesn't affect existing workflows
Confidence Score: 5/5
- Safe to merge. Implementation is clean, well-isolated, and follows existing patterns.
- The PR introduces a new BETA feature without modifying core functionality. All changes are additive and properly isolated. The auto-detection logic is simple and won't cause false positives (requires exact phrase "convert this n8n workflow"). Error handling is present throughout. UI components follow established patterns. The only finding is a minor style issue about detection flexibility, which doesn't affect correctness.
- No files require special attention - all implementations are straightforward and follow project conventions.
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/copilot/chat/route.ts | 4/5 | Adds migration detection logic that triggers when message contains "convert this n8n workflow". Injects specialized migration prompt into agentContexts. Minor issue: detection string is hardcoded and case-sensitive match could be more flexible. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/migration-dialog.tsx | 5/5 | New dialog component for N8N workflow migration. Handles JSON file upload/paste, validates workflow structure, formats request using migration utility, and submits to copilot chat. Clean implementation with proper error handling. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/welcome/welcome.tsx | 5/5 | Adds "Migrate From N8n" button to welcome screen (build mode only). Simple UI addition with proper BETA badge and callback handling. |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/copilot.tsx | 5/5 | Integrates MigrationDialog component with copilot. Adds state management for dialog visibility and passes formatted content to handleSubmit. Clean integration without breaking existing functionality. |
| apps/sim/lib/migration/format-request.ts | 5/5 | Server action that formats N8N workflow JSON into copilot message. Extracts metadata (node count, types, name) and creates structured prompt. Proper error handling and JSON validation. |
| apps/sim/lib/migration/prompts.ts | 5/5 | Provides migration system prompt with block mappings and efficient conversion process. Clear instructions for creating all blocks in one edit_workflow call then autolayouting. |
Sequence Diagram
sequenceDiagram
participant User
participant Welcome as Welcome Component
participant Dialog as MigrationDialog
participant Copilot as Copilot Component
participant Format as formatMigrationRequest
participant Route as /api/copilot/chat
participant Migration as getMigrationSystemPrompt
participant Agent as Sim Agent API
User->>Welcome: Click "Migrate From N8n" button
Welcome->>Copilot: onMigrateClick()
Copilot->>Dialog: Open dialog (setIsMigrationDialogOpen)
User->>Dialog: Upload/paste N8N workflow JSON
Dialog->>Dialog: Validate JSON structure
Dialog->>Format: formatMigrationRequest(workflowJson)
Format->>Format: Parse JSON, extract metadata
Format-->>Dialog: Formatted message with workflow info
Dialog->>Copilot: onSubmitToChat(message)
Copilot->>Route: POST /api/copilot/chat
Route->>Route: Detect "convert this n8n workflow"
Route->>Migration: getMigrationSystemPrompt()
Migration-->>Route: Migration system prompt
Route->>Route: agentContexts.unshift(migration_instructions)
Route->>Agent: Forward request with contexts
Agent-->>Route: Streaming response
Route-->>Copilot: SSE stream
Copilot-->>User: Display AI response
| } | ||
|
|
||
| // Detect migration requests and add specialized system prompt | ||
| const isMigrationRequest = message.toLowerCase().includes('convert this n8n workflow') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] Detection string is hardcoded and brittle. If the user message format varies (e.g., "Convert this N8N workflow", "convert the n8n workflow"), detection will fail. Consider a more flexible pattern match or regex.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/api/copilot/chat/route.ts
Line: 175:175
Comment:
[P3] Detection string is hardcoded and brittle. If the user message format varies (e.g., "Convert this N8N workflow", "convert the n8n workflow"), detection will fail. Consider a more flexible pattern match or regex.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
Summary
Copilot-based Migration
edit_workflowcall, then autolayouts - no incremental creationget_block_configtool only when needed to prevent validation errorsCost: $0.03-$0.08 per migration ✅
Fixes #(issue)
Adds a feature
Type of Change
Testing
How has this been tested? What should reviewers focus on?
Checklist
Screenshots/Videos
Screen.Recording.2026-01-08.at.3.04.31.PM.mov