DOCS 路 N8N WORKFLOWS

n8n Automation Workflows

UPDATED 22 NOVEMBER 2025

Example: Daily At-Risk Customer Report

{
  "name": "Daily At-Risk Report",
  "nodes": [
    {
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [250, 300],
      "parameters": {
        "rule": {
          "interval": [{ "field": "hours", "value": 24 }]
        },
        "triggerTimes": {
          "item": [{ "hour": 9, "minute": 0 }]
        }
      }
    },
    {
      "name": "Get At-Risk Customers",
      "type": "n8n-nodes-base.httpRequest",
      "position": [450, 300],
      "parameters": {
        "url": "https://api.getaiva.ai/api/merchant/{{$env.AIVA_MERCHANT_ID}}/customers",
        "qs": {
          "segment": "At Risk",
          "pageSize": 100
        },
        "authentication": "headerAuth",
        "headerAuth": {
          "name": "X-API-Key",
          "value": "={{$env.AIVA_API_KEY}}"
        }
      }
    },
    {
      "name": "Calculate Metrics",
      "type": "n8n-nodes-base.function",
      "position": [650, 300],
      "parameters": {
        "functionCode": "const customers = items[0].json.customers;\nconst totalLTV = customers.reduce((sum, c) => sum + c.totalSpent, 0);\nreturn [{\n  json: {\n    count: customers.length,\n    totalLTV: totalLTV,\n    avgLTV: totalLTV / customers.length,\n    customers: customers\n  }\n}];"
      }
    },
    {
      "name": "Send Email Report",
      "type": "n8n-nodes-base.emailSend",
      "position": [850, 300],
      "parameters": {
        "toEmail": "marketing@yourstore.com",
        "subject": "馃毃 {{$json.count}} At-Risk Customers - ${{$json.totalLTV}} at Risk",
        "text": "You have {{$json.count}} at-risk customers.\n\nTotal LTV at risk: ${{$json.totalLTV}}\nAverage LTV: ${{$json.avgLTV}}\n\nTake action today to prevent churn!"
      }
    }
  ],
  "connections": {
    "Schedule Trigger": { "main": [[{ "node": "Get At-Risk Customers" }]] },
    "Get At-Risk Customers": { "main": [[{ "node": "Calculate Metrics" }]] },
    "Calculate Metrics": { "main": [[{ "node": "Send Email Report" }]] }
  }
}

Import This Workflow:

  • Copy the JSON above

  • In n8n, click Import from JSON

  • Paste and save

  • Set environment variables: AIVA_API_KEY, AIVA_MERCHANT_ID

  • Activate workflow

Building something with the AIVA API or MCP server? We read every developer message.
Talk to us