👥 User Management
Khi team grows, bạn cần proper user management. Bài này covers multi-user setup, invitations, và team organization trong n8n.
User Management Overview
n8n User System:
Text
1N8N USER HIERARCHY2──────────────────3 4OWNER5├── First user to sign up6├── Full admin access7├── Can invite users8├── Manage all settings9└── Cannot be removed10 11ADMIN (If configured)12├── Manage users13├── Access all workflows14└── Manage credentials15 16MEMBER17├── Create own workflows18├── Use shared credentials19└── Limited settings access20 21VIEWER (Enterprise)22├── View workflows only23├── Cannot edit24└── Execution view onlyEnabling User Management
Environment Configuration:
Bash
1# Enable user management2N8N_USER_MANAGEMENT_DISABLED=false3 4# SMTP for email invitations (required)5N8N_EMAIL_MODE=smtp6N8N_SMTP_HOST=smtp.gmail.com7N8N_SMTP_PORT=5878N8N_SMTP_USER=your@gmail.com9N8N_SMTP_PASS=app_password # Use app password, not regular10N8N_SMTP_SENDER=noreply@yourdomain.com11N8N_SMTP_SSL=true12 13# Optional: Custom domain for links14N8N_EDITOR_BASE_URL=https://n8n.yourdomain.comFirst User Setup:
Text
11. Access n8n URL22. You'll see "Set up your account"33. Enter:4 - First name5 - Last name6 - Email7 - Password (strong!)84. This user becomes OWNERInviting Users
Via UI:
Text
11. Click on user menu (top right)22. Settings → Users33. Click "Invite"44. Enter email address55. (Optional) Set temporary role66. Click "Send Invitation"Invitation Email:
Text
1User receives email with:2├── Link to set password3├── 7-day expiration4└── Instructions to complete setupBulk Invite Script:
Bash
1#!/bin/bash2# bulk-invite.sh3 4EMAILS=(5 "user1@company.com"6 "user2@company.com"7 "user3@company.com"8)9 10for email in "${EMAILS[@]}"; do11 curl -X POST "https://n8n.yourdomain.com/rest/invitations" \12 -H "Content-Type: application/json" \13 -H "Authorization: Bearer YOUR_API_KEY" \14 -d "{\"email\": \"$email\"}"15 16 echo "Invited: $email"17doneUser Onboarding
Onboarding Checklist Template:
markdown
1# n8n User Onboarding2 3## Account Setup4- [ ] Accept invitation email5- [ ] Set strong password6- [ ] Complete profile7 8## Getting Started9- [ ] Review n8n basics documentation10- [ ] Watch intro video (link)11- [ ] Join team Slack channel12 13## Access Setup14- [ ] Request necessary credentials15- [ ] Join relevant workflow folders16- [ ] Set notification preferences17 18## First Workflow19- [ ] Clone starter template20- [ ] Build first simple workflow21- [ ] Get review from team lead22 23## Best Practices24- [ ] Read naming conventions25- [ ] Review error handling guidelines26- [ ] Understand backup proceduresWelcome Message Template:
markdown
1# Welcome to Our n8n Instance! 👋2 3## Quick Links4- n8n URL: https://n8n.yourdomain.com5- Documentation: [Internal Wiki Link]6- Support: #n8n-help on Slack7 8## Getting Started91. Set up your account using the invitation link102. Watch this 10-min intro: [Video Link]113. Try the "Hello World" workflow template12 13## Need Help?14- Check our internal FAQ first15- Post in #n8n-help channel16- Tag @n8n-admins for urgent issues17 18## Rules19- Always test in staging first20- Don't modify shared credentials21- Document your workflows22- Follow naming conventions23 24Happy automating! 🚀Managing Users
View All Users:
Text
1Settings → Users2 3Shows:4├── User name5├── Email6├── Status (Active/Invited/Disabled)7├── Role8└── Last activeDisable User:
Text
11. Settings → Users22. Click on user33. Click "Disable"44. Confirm5 6User cannot:7├── Log in8├── Execute workflows9└── Access API10 11Workflows remain (can transfer)Delete User:
Text
11. Settings → Users22. Click on user33. Click "Delete"44. Choose what to do with workflows:5 - Transfer to another user6 - Delete all workflows75. Confirm8 9⚠️ This action is irreversible!Transfer Ownership:
Text
1When user leaves:21. Go to their workflows32. For each workflow:4 - Open workflow5 - Settings → Transfer ownership6 - Select new owner73. Transfer credentials if needed84. Then disable/delete userTeam Organization
Workflow Organization:
Text
1FOLDER STRUCTURE2────────────────3 4📁 Marketing5├── 📁 Email Campaigns6│ ├── Welcome Sequence7│ └── Newsletter Automation8└── 📁 Social Media9 ├── Post Scheduler10 └── Analytics Collector11 12📁 Sales13├── 📁 Lead Processing14│ ├── New Lead Handler15│ └── Lead Scoring16└── 📁 CRM Sync17 └── Salesforce Sync18 19📁 Operations20├── 📁 Reporting21│ ├── Daily Summary22│ └── Weekly Metrics23└── 📁 Integrations24 └── Inventory SyncNaming Conventions:
Text
1WORKFLOW NAMING2───────────────3 4Pattern: [Team]-[Category]-[Name]5 6Examples:7• Marketing-Email-WelcomeSequence8• Sales-CRM-SalesforceLead Sync9• Ops-Report-DailyMetrics10• DevOps-Monitor-UptimeCheck11 12CREDENTIAL NAMING13─────────────────14 15Pattern: [Service]-[Environment]-[Team]16 17Examples:18• Slack-Prod-Marketing19• Salesforce-Prod-Sales20• PostgreSQL-Prod-ReadOnlyAccess Control Strategies
Strategy 1: Shared Workspace
Text
1All users in one workspace:2├── ✅ Simple setup3├── ✅ Easy collaboration4├── ⚠️ Everyone sees everything5└── Best for: Small teams (< 10)Strategy 2: Team Folders
Text
1Organized by team:2├── Marketing team → Marketing folder3├── Sales team → Sales folder4├── Share cross-team as needed5└── Best for: Medium teams (10-50)Strategy 3: Separate Instances
Text
1Different n8n per team:2├── marketing.n8n.company.com3├── sales.n8n.company.com4├── ops.n8n.company.com5├── ✅ Full isolation6├── ⚠️ More maintenance7└── Best for: Large orgs with compliance needsAPI Access
Generate API Key:
Text
11. Settings → API22. Generate API key33. Note: API keys are personal44. Each user generates their ownAPI Key Best Practices:
Bash
1# Store securely2export N8N_API_KEY="your_key_here"3 4# Use in scripts5curl -H "X-N8N-API-KEY: $N8N_API_KEY" \6 https://n8n.yourdomain.com/api/v1/workflowsAPI Permissions:
Text
1API keys inherit user permissions:2├── Owner API key → Full access3├── Member API key → Own workflows only4└── Cannot elevate permissions via APIEmail Configuration
Gmail Setup:
Bash
1# Enable 2FA on Gmail first2# Create App Password:3# 1. Google Account → Security4# 2. App passwords5# 3. Generate for "Mail"6 7N8N_SMTP_HOST=smtp.gmail.com8N8N_SMTP_PORT=5879N8N_SMTP_USER=your@gmail.com10N8N_SMTP_PASS=generated_app_password11N8N_SMTP_SENDER=your@gmail.com12N8N_SMTP_SSL=trueSendGrid Setup:
Bash
1N8N_SMTP_HOST=smtp.sendgrid.net2N8N_SMTP_PORT=5873N8N_SMTP_USER=apikey4N8N_SMTP_PASS=your_sendgrid_api_key5N8N_SMTP_SENDER=noreply@yourdomain.com6N8N_SMTP_SSL=trueCustom Mail Server:
Bash
1N8N_SMTP_HOST=mail.yourdomain.com2N8N_SMTP_PORT=5873N8N_SMTP_USER=n8n@yourdomain.com4N8N_SMTP_PASS=your_password5N8N_SMTP_SENDER=n8n@yourdomain.com6N8N_SMTP_SSL=trueTroubleshooting
Invitation Email Not Received:
Text
11. Check spam folder22. Verify SMTP settings33. Test SMTP connection:4 5 docker exec n8n sh -c "6 echo 'Test' | mail -s 'Test' user@email.com7 "8 94. Check n8n logs:10 docker logs n8n | grep -i smtpUser Cannot Login:
Text
1Possible causes:21. Account disabled → Re-enable32. Password forgotten → Reset via email43. Email not verified → Resend verification54. Browser cache → Clear cachePermission Issues:
Text
1"Cannot access workflow"21. Check workflow ownership32. Verify sharing settings43. Confirm credential access5 6"Cannot use credential"71. Check credential sharing82. Verify credential not deleted93. Re-share if neededUser Activity Monitoring
Activity Query:
SQL
1-- Check user activity2SELECT 3 u.email,4 COUNT(e.id) as executions,5 MAX(e."startedAt") as last_active6FROM "user" u7LEFT JOIN execution_entity e ON e."userId" = u.id8WHERE e."startedAt" > NOW() - INTERVAL '30 days'9GROUP BY u.id10ORDER BY executions DESC;Active Users Report:
Bash
1#!/bin/bash2# user-activity.sh3 4echo "=== User Activity Report ==="5echo "Date: $(date)"6echo ""7 8docker exec n8n-postgres psql -U n8n -d n8n -c "9SELECT 10 email,11 \"firstName\",12 \"lastName\",13 \"createdAt\"::date as joined,14 CASE WHEN disabled THEN 'Disabled' ELSE 'Active' END as status15FROM \"user\"16ORDER BY \"createdAt\" DESC;17"Bài Tập Thực Hành
User Management Challenge
Set up team environment:
- Enable user management
- Configure SMTP for invitations
- Create folder structure
- Define naming conventions document
- Invite test user
- Create onboarding checklist
Build your collaborative workspace! 👥
Key Takeaways
Remember
- 👤 First user = Owner - Can't be removed
- 📧 SMTP required - For invitations
- 📁 Organize early - Folders and naming
- 📋 Document onboarding - Save time later
- 🔐 Principle of least privilege - Minimum access needed
Tiếp Theo
Bài tiếp theo: Permissions & Roles - Access control chi tiết, workflow sharing, và credential permissions.
