Lý thuyết
40 phút
Bài 11/15

User Management

Multi-user setup trong n8n - invitations, user roles, onboarding và team organization

👥 User Management

Team Collaboration

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 HIERARCHY
2──────────────────
3
4OWNER
5├── First user to sign up
6├── Full admin access
7├── Can invite users
8├── Manage all settings
9└── Cannot be removed
10
11ADMIN (If configured)
12├── Manage users
13├── Access all workflows
14└── Manage credentials
15
16MEMBER
17├── Create own workflows
18├── Use shared credentials
19└── Limited settings access
20
21VIEWER (Enterprise)
22├── View workflows only
23├── Cannot edit
24└── Execution view only

Enabling User Management

Environment Configuration:

Bash
1# Enable user management
2N8N_USER_MANAGEMENT_DISABLED=false
3
4# SMTP for email invitations (required)
5N8N_EMAIL_MODE=smtp
6N8N_SMTP_HOST=smtp.gmail.com
7N8N_SMTP_PORT=587
8N8N_SMTP_USER=your@gmail.com
9N8N_SMTP_PASS=app_password # Use app password, not regular
10N8N_SMTP_SENDER=noreply@yourdomain.com
11N8N_SMTP_SSL=true
12
13# Optional: Custom domain for links
14N8N_EDITOR_BASE_URL=https://n8n.yourdomain.com

First User Setup:

Text
11. Access n8n URL
22. You'll see "Set up your account"
33. Enter:
4 - First name
5 - Last name
6 - Email
7 - Password (strong!)
84. This user becomes OWNER

Inviting Users

Via UI:

Text
11. Click on user menu (top right)
22. Settings → Users
33. Click "Invite"
44. Enter email address
55. (Optional) Set temporary role
66. Click "Send Invitation"

Invitation Email:

Text
1User receives email with:
2├── Link to set password
3├── 7-day expiration
4└── Instructions to complete setup

Bulk Invite Script:

Bash
1#!/bin/bash
2# bulk-invite.sh
3
4EMAILS=(
5 "user1@company.com"
6 "user2@company.com"
7 "user3@company.com"
8)
9
10for email in "${EMAILS[@]}"; do
11 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"
17done

User Onboarding

Onboarding Checklist Template:

markdown
1# n8n User Onboarding
2
3## Account Setup
4- [ ] Accept invitation email
5- [ ] Set strong password
6- [ ] Complete profile
7
8## Getting Started
9- [ ] Review n8n basics documentation
10- [ ] Watch intro video (link)
11- [ ] Join team Slack channel
12
13## Access Setup
14- [ ] Request necessary credentials
15- [ ] Join relevant workflow folders
16- [ ] Set notification preferences
17
18## First Workflow
19- [ ] Clone starter template
20- [ ] Build first simple workflow
21- [ ] Get review from team lead
22
23## Best Practices
24- [ ] Read naming conventions
25- [ ] Review error handling guidelines
26- [ ] Understand backup procedures

Welcome Message Template:

markdown
1# Welcome to Our n8n Instance! 👋
2
3## Quick Links
4- n8n URL: https://n8n.yourdomain.com
5- Documentation: [Internal Wiki Link]
6- Support: #n8n-help on Slack
7
8## Getting Started
91. Set up your account using the invitation link
102. Watch this 10-min intro: [Video Link]
113. Try the "Hello World" workflow template
12
13## Need Help?
14- Check our internal FAQ first
15- Post in #n8n-help channel
16- Tag @n8n-admins for urgent issues
17
18## Rules
19- Always test in staging first
20- Don't modify shared credentials
21- Document your workflows
22- Follow naming conventions
23
24Happy automating! 🚀

Managing Users

View All Users:

Text
1Settings → Users
2
3Shows:
4├── User name
5├── Email
6├── Status (Active/Invited/Disabled)
7├── Role
8└── Last active

Disable User:

Text
11. Settings → Users
22. Click on user
33. Click "Disable"
44. Confirm
5
6User cannot:
7├── Log in
8├── Execute workflows
9└── Access API
10
11Workflows remain (can transfer)

Delete User:

Text
11. Settings → Users
22. Click on user
33. Click "Delete"
44. Choose what to do with workflows:
5 - Transfer to another user
6 - Delete all workflows
75. Confirm
8
9⚠️ This action is irreversible!

Transfer Ownership:

Text
1When user leaves:
21. Go to their workflows
32. For each workflow:
4 - Open workflow
5 - Settings → Transfer ownership
6 - Select new owner
73. Transfer credentials if needed
84. Then disable/delete user

Team Organization

Workflow Organization:

Text
1FOLDER STRUCTURE
2────────────────
3
4📁 Marketing
5├── 📁 Email Campaigns
6│ ├── Welcome Sequence
7│ └── Newsletter Automation
8└── 📁 Social Media
9 ├── Post Scheduler
10 └── Analytics Collector
11
12📁 Sales
13├── 📁 Lead Processing
14│ ├── New Lead Handler
15│ └── Lead Scoring
16└── 📁 CRM Sync
17 └── Salesforce Sync
18
19📁 Operations
20├── 📁 Reporting
21│ ├── Daily Summary
22│ └── Weekly Metrics
23└── 📁 Integrations
24 └── Inventory Sync

Naming Conventions:

Text
1WORKFLOW NAMING
2───────────────
3
4Pattern: [Team]-[Category]-[Name]
5
6Examples:
7• Marketing-Email-WelcomeSequence
8• Sales-CRM-SalesforceLead Sync
9• Ops-Report-DailyMetrics
10• DevOps-Monitor-UptimeCheck
11
12CREDENTIAL NAMING
13─────────────────
14
15Pattern: [Service]-[Environment]-[Team]
16
17Examples:
18• Slack-Prod-Marketing
19• Salesforce-Prod-Sales
20• PostgreSQL-Prod-ReadOnly

Access Control Strategies

Strategy 1: Shared Workspace

Text
1All users in one workspace:
2├── ✅ Simple setup
3├── ✅ Easy collaboration
4├── ⚠️ Everyone sees everything
5└── Best for: Small teams (< 10)

Strategy 2: Team Folders

Text
1Organized by team:
2├── Marketing team → Marketing folder
3├── Sales team → Sales folder
4├── Share cross-team as needed
5└── Best for: Medium teams (10-50)

Strategy 3: Separate Instances

Text
1Different n8n per team:
2├── marketing.n8n.company.com
3├── sales.n8n.company.com
4├── ops.n8n.company.com
5├── ✅ Full isolation
6├── ⚠️ More maintenance
7└── Best for: Large orgs with compliance needs

API Access

Generate API Key:

Text
11. Settings → API
22. Generate API key
33. Note: API keys are personal
44. Each user generates their own

API Key Best Practices:

Bash
1# Store securely
2export N8N_API_KEY="your_key_here"
3
4# Use in scripts
5curl -H "X-N8N-API-KEY: $N8N_API_KEY" \
6 https://n8n.yourdomain.com/api/v1/workflows

API Permissions:

Text
1API keys inherit user permissions:
2├── Owner API key → Full access
3├── Member API key → Own workflows only
4└── Cannot elevate permissions via API

Email Configuration

Gmail Setup:

Bash
1# Enable 2FA on Gmail first
2# Create App Password:
3# 1. Google Account → Security
4# 2. App passwords
5# 3. Generate for "Mail"
6
7N8N_SMTP_HOST=smtp.gmail.com
8N8N_SMTP_PORT=587
9N8N_SMTP_USER=your@gmail.com
10N8N_SMTP_PASS=generated_app_password
11N8N_SMTP_SENDER=your@gmail.com
12N8N_SMTP_SSL=true

SendGrid Setup:

Bash
1N8N_SMTP_HOST=smtp.sendgrid.net
2N8N_SMTP_PORT=587
3N8N_SMTP_USER=apikey
4N8N_SMTP_PASS=your_sendgrid_api_key
5N8N_SMTP_SENDER=noreply@yourdomain.com
6N8N_SMTP_SSL=true

Custom Mail Server:

Bash
1N8N_SMTP_HOST=mail.yourdomain.com
2N8N_SMTP_PORT=587
3N8N_SMTP_USER=n8n@yourdomain.com
4N8N_SMTP_PASS=your_password
5N8N_SMTP_SENDER=n8n@yourdomain.com
6N8N_SMTP_SSL=true

Troubleshooting

Invitation Email Not Received:

Text
11. Check spam folder
22. Verify SMTP settings
33. Test SMTP connection:
4
5 docker exec n8n sh -c "
6 echo 'Test' | mail -s 'Test' user@email.com
7 "
8
94. Check n8n logs:
10 docker logs n8n | grep -i smtp

User Cannot Login:

Text
1Possible causes:
21. Account disabled → Re-enable
32. Password forgotten → Reset via email
43. Email not verified → Resend verification
54. Browser cache → Clear cache

Permission Issues:

Text
1"Cannot access workflow"
21. Check workflow ownership
32. Verify sharing settings
43. Confirm credential access
5
6"Cannot use credential"
71. Check credential sharing
82. Verify credential not deleted
93. Re-share if needed

User Activity Monitoring

Activity Query:

SQL
1-- Check user activity
2SELECT
3 u.email,
4 COUNT(e.id) as executions,
5 MAX(e."startedAt") as last_active
6FROM "user" u
7LEFT JOIN execution_entity e ON e."userId" = u.id
8WHERE e."startedAt" > NOW() - INTERVAL '30 days'
9GROUP BY u.id
10ORDER BY executions DESC;

Active Users Report:

Bash
1#!/bin/bash
2# user-activity.sh
3
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 status
15FROM \"user\"
16ORDER BY \"createdAt\" DESC;
17"

Bài Tập Thực Hành

User Management Challenge

Set up team environment:

  1. Enable user management
  2. Configure SMTP for invitations
  3. Create folder structure
  4. Define naming conventions document
  5. Invite test user
  6. 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.