Automation System Documentation
Overview
The automation system provides a way for admins to discover, view, and trigger n8n workflows directly from the frontend application. Automations are discovered by scanning workflow files in apps/workflows/n8n_workflows/workflows/ and exposed via API endpoints.
Architecture
Components
-
Workflow Discovery Service (
lib/workflows/discover-workflows.ts)- Scans n8n workflow JSON files
- Extracts webhook information, tags, and metadata
- Categorizes workflows (command, agent, orchestrator, tool)
-
API Endpoints
GET /api/admin/automations- List all automations with filteringGET /api/admin/automations/[id]- Get specific automation detailsPOST /api/admin/automations/[id]/trigger- Trigger an automation
-
UI Components
app/(dashboard)/dashboard/admin/n8n/page.tsx- Full n8n automation panelcomponents/admin/automation-quick-trigger.tsx- Quick trigger dropdown for sidebar
Usage
For Admins
-
Access Automation Panel
- Navigate to
/dashboard/admin/n8n - Or use "n8n Automation Panel" link in admin dashboard
- Navigate to
-
Quick Actions
- Use the "Quick Actions" dropdown in admin sidebar
- Select an automation to trigger
- Confirm in the dialog
-
Full Panel Features
- Search automations by name, description, or tags
- Filter by category (command, agent, orchestrator, tool)
- Filter by tags
- View automation details
- Trigger automations with confirmation
- Open automation in n8n editor
For Developers
Adding New Automations
Automations are automatically discovered from workflow files. To add a new automation:
-
Create a workflow JSON file in the appropriate directory:
commands/- Executable commandsagents/- AI-powered agentsorchestrators/- Workflow orchestratorstools/- Utility tools
-
Ensure the workflow has:
- A webhook node (for triggering)
- A
namefield - Optional
tagsarray for categorization
-
The workflow will be automatically discovered on next refresh
Environment Variables
NEXT_PUBLIC_N8N_URL=https://n8n.altsportsleagues.ai
N8N_WEBHOOK_TOKEN=your-webhook-token-here # Optional, for authenticated webhooksAPI Usage
List Automations
const response = await fetch('/api/admin/automations?category=command&tag=admin')
const { automations } = await response.json()Trigger Automation
const response = await fetch(`/api/admin/automations/${automationId}/trigger`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
data: { /* custom payload */ },
waitForResponse: false
})
})Workflow Discovery
The discovery service scans workflow files and extracts:
- Webhook Path: From webhook node
pathorwebhookId - HTTP Method: From webhook node
httpMethod(defaults to POST) - Tags: From workflow
tagsarray - Category: Determined from file path
- Description: Generated from workflow name and category
Security
- All automation triggers require admin authentication (handled by Next.js middleware)
- Webhook tokens can be configured via
N8N_WEBHOOK_TOKENenvironment variable - Automations marked with
requiresAuth: truewill include auth headers
Future Enhancements
- Real-time execution status updates
- Execution history and logs
- Custom parameter input forms
- Workflow scheduling
- Bulk operations
- Workflow testing interface