misc
Automation System

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

  1. 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)
  2. API Endpoints

    • GET /api/admin/automations - List all automations with filtering
    • GET /api/admin/automations/[id] - Get specific automation details
    • POST /api/admin/automations/[id]/trigger - Trigger an automation
  3. UI Components

    • app/(dashboard)/dashboard/admin/n8n/page.tsx - Full n8n automation panel
    • components/admin/automation-quick-trigger.tsx - Quick trigger dropdown for sidebar

Usage

For Admins

  1. Access Automation Panel

    • Navigate to /dashboard/admin/n8n
    • Or use "n8n Automation Panel" link in admin dashboard
  2. Quick Actions

    • Use the "Quick Actions" dropdown in admin sidebar
    • Select an automation to trigger
    • Confirm in the dialog
  3. 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:

  1. Create a workflow JSON file in the appropriate directory:

    • commands/ - Executable commands
    • agents/ - AI-powered agents
    • orchestrators/ - Workflow orchestrators
    • tools/ - Utility tools
  2. Ensure the workflow has:

    • A webhook node (for triggering)
    • A name field
    • Optional tags array for categorization
  3. 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 webhooks

API 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 path or webhookId
  • HTTP Method: From webhook node httpMethod (defaults to POST)
  • Tags: From workflow tags array
  • 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_TOKEN environment variable
  • Automations marked with requiresAuth: true will 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

Platform

Documentation

Community

Support

partnership@altsportsdata.comdev@altsportsleagues.ai

2025 Β© AltSportsLeagues.ai. Powered by AI-driven sports business intelligence.

πŸ€– AI-Enhancedβ€’πŸ“Š Data-Drivenβ€’βš‘ Real-Time