AutomationFlowsE-commerce › Analyze Shopify Orders with Gemini AI and Send Weekly Slack Insights

Analyze Shopify Orders with Gemini AI and Send Weekly Slack Insights

ByOka Hironobu @okp29 on n8n.io

E-commerce store owners and sales managers who want AI-powered insights from their Shopify data without manually crunching numbers every week.

Cron / scheduled trigger★★★★☆ complexity15 nodesShopifyHTTP RequestSlackGmailGoogle Sheets
E-commerce Trigger: Cron / scheduled Nodes: 15 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #13872 — we link there as the canonical source.

This workflow follows the Gmail → Google Sheets recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "361be7b7-c6fa-44c1-bded-3a7bd938adeb",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        272
      ],
      "parameters": {
        "width": 380,
        "height": 730,
        "content": "## Weekly Shopify sales analysis with Gemini AI\n\nThis workflow analyzes your Shopify sales data weekly and provides AI-powered insights via Slack and email.\n\n### How it works\n1. **Data collection**: Pulls last 7 days of Shopify orders every Monday morning\n2. **Analysis**: Aggregates sales metrics (revenue, top products, order count)\n3. **AI insights**: Sends data to Gemini AI for trend analysis and recommendations\n4. **Reporting**: Delivers insights via Slack channel and email to stakeholders\n5. **Tracking**: Logs metrics to Google Sheets for historical analysis\n6. **Alerts**: Notifies team if revenue drops >20% from previous week\n\n### Setup steps\n1. Configure Shopify credentials with order read permissions\n2. Set up Gemini API key for AI analysis\n3. Connect Slack workspace and choose target channel\n4. Add Gmail credentials for email reports\n5. Create Google Sheets for data tracking\n6. Adjust revenue threshold in the filter node\n\n### Customization\n- Change schedule frequency in the trigger\n- Modify revenue drop threshold (default: 20%)\n- Customize Gemini prompts for different analysis types\n- Add more Slack channels for department-specific reports"
      },
      "typeVersion": 1
    },
    {
      "id": "1d828bd4-71c8-4d37-8d49-f7751605536b",
      "name": "Data Collection",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 214,
        "height": 588,
        "content": "## Data collection\nFetch orders from Shopify"
      },
      "typeVersion": 1
    },
    {
      "id": "499d660b-aa8f-4e4c-9132-f3383a14939b",
      "name": "Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 360,
        "height": 588,
        "content": "## Data processing\nAggregate sales metrics and prepare for AI analysis"
      },
      "typeVersion": 1
    },
    {
      "id": "7cfe7c29-8b39-442e-91bc-d71d9532d9c4",
      "name": "AI Analysis",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 588,
        "content": "## AI analysis\nGemini AI analyzes trends and provides insights"
      },
      "typeVersion": 1
    },
    {
      "id": "1efb9a8f-06ff-4244-aa0e-da884b40a0ed",
      "name": "Reporting",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        272
      ],
      "parameters": {
        "color": 7,
        "width": 760,
        "height": 588,
        "content": "## Reporting & alerts\nDistribute insights via Slack, email, and track in Google Sheets. Alert on revenue drops."
      },
      "typeVersion": 1
    },
    {
      "id": "b99f6cc0-c4fe-46ac-bb19-bff96a989ee4",
      "name": "Weekly Monday Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -400,
        464
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * MON"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ca1d803a-9e5f-46a9-bd0f-18df642f0031",
      "name": "Get Last 7 Days Orders",
      "type": "n8n-nodes-base.shopify",
      "position": [
        -176,
        464
      ],
      "parameters": {
        "limit": 500,
        "options": {},
        "operation": "getAll"
      },
      "typeVersion": 1
    },
    {
      "id": "7a13da50-3454-4a18-bc47-80b44596cac0",
      "name": "Aggregate Sales Data",
      "type": "n8n-nodes-base.code",
      "position": [
        0,
        464
      ],
      "parameters": {
        "jsCode": "// Aggregate order data for analysis\nconst orders = $input.all();\n\nlet totalRevenue = 0;\nlet orderCount = orders.length;\nlet productCounts = {};\nlet dailySales = {};\n\norders.forEach(order => {\n  const orderData = order.json;\n  \n  // Calculate revenue\n  totalRevenue += parseFloat(orderData.total_price || 0);\n  \n  // Track daily sales\n  const date = orderData.created_at.split('T')[0];\n  dailySales[date] = (dailySales[date] || 0) + parseFloat(orderData.total_price || 0);\n  \n  // Count products\n  orderData.line_items?.forEach(item => {\n    const productName = item.name;\n    productCounts[productName] = (productCounts[productName] || 0) + item.quantity;\n  });\n});\n\n// Get top 5 products\nconst topProducts = Object.entries(productCounts)\n  .sort(([,a], [,b]) => b - a)\n  .slice(0, 5)\n  .map(([name, count]) => ({ name, quantity: count }));\n\n// Calculate average order value\nconst avgOrderValue = orderCount > 0 ? (totalRevenue / orderCount).toFixed(2) : 0;\n\n// Previous week for comparison (mock data - would typically come from sheets)\nconst previousWeekRevenue = totalRevenue * 0.95; // Simulated previous week\n\nreturn {\n  totalRevenue: totalRevenue.toFixed(2),\n  orderCount,\n  avgOrderValue,\n  topProducts,\n  dailySales,\n  previousWeekRevenue: previousWeekRevenue.toFixed(2),\n  revenueChange: (((totalRevenue - previousWeekRevenue) / previousWeekRevenue) * 100).toFixed(1)\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "13d1eb98-12ce-4292-ab2b-9d249bf19c10",
      "name": "Gemini Sales Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        208,
        464
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "contents",
              "value": "=[{\"parts\":[{\"text\":\"Analyze this week's Shopify sales data and provide insights:\\n\\nTotal Revenue: ${{ $json.totalRevenue }}\\nOrder Count: {{ $json.orderCount }}\\nAverage Order Value: ${{ $json.avgOrderValue }}\\nRevenue Change from Last Week: {{ $json.revenueChange }}%\\n\\nTop Products:\\n{{ $json.topProducts.map(p => `${p.name}: ${p.quantity} sold`).join('\\n') }}\\n\\nDaily Sales:\\n{{ Object.entries($json.dailySales).map(([date, amount]) => `${date}: $${amount}`).join('\\n') }}\\n\\nPlease provide:\\n1. Key insights about sales performance\\n2. Trends you notice in the data\\n3. 2-3 actionable recommendations\\n4. Risk assessment if revenue declined\\n\\nFormat as JSON with keys: insights, trends, recommendations, risks\"}]}]"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1fc78f67-9545-498f-a358-b6e6f7ba5e4b",
      "name": "Parse AI Response",
      "type": "n8n-nodes-base.set",
      "position": [
        400,
        464
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "analysis",
              "name": "aiInsights",
              "type": "object",
              "value": "={{ JSON.parse($json.candidates[0].content.parts[0].text) }}"
            },
            {
              "id": "metrics",
              "name": "weeklyMetrics",
              "type": "object",
              "value": "={{ $('Aggregate Sales Data').item.json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "89cfab60-7ffc-4f5d-990e-ec3f467ec4c8",
      "name": "Post to Slack Channel",
      "type": "n8n-nodes-base.slack",
      "position": [
        560,
        464
      ],
      "parameters": {
        "text": "\ud83d\udcca **Weekly Sales Report** ({{ $now.minus({days: 7}).toFormat('MMM dd') }} - {{ $now.toFormat('MMM dd') }})\n\n**Metrics:**\n\u2022 Revenue: ${{ $json.weeklyMetrics.totalRevenue }} ({{ $json.weeklyMetrics.revenueChange }}%)\n\u2022 Orders: {{ $json.weeklyMetrics.orderCount }}\n\u2022 Avg Order Value: ${{ $json.weeklyMetrics.avgOrderValue }}\n\n**AI Insights:**\n{{ $json.aiInsights.insights }}\n\n**Trends:**\n{{ $json.aiInsights.trends }}\n\n**Recommendations:**\n{{ $json.aiInsights.recommendations }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#sales"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.2
    },
    {
      "id": "2e2d2d11-eab2-4c3a-a125-3851d339c15f",
      "name": "Email Report to Stakeholders",
      "type": "n8n-nodes-base.gmail",
      "position": [
        736,
        464
      ],
      "parameters": {
        "message": "<h2>Weekly Sales Analysis</h2>\n<p><strong>Period:</strong> {{ $now.minus({days: 7}).toFormat('MMM dd') }} - {{ $now.toFormat('MMM dd') }}</p>\n\n<h3>Key Metrics</h3>\n<ul>\n<li>Total Revenue: ${{ $json.weeklyMetrics.totalRevenue }} ({{ $json.weeklyMetrics.revenueChange > 0 ? '+' : '' }}{{ $json.weeklyMetrics.revenueChange }}%)</li>\n<li>Order Count: {{ $json.weeklyMetrics.orderCount }}</li>\n<li>Average Order Value: ${{ $json.weeklyMetrics.avgOrderValue }}</li>\n</ul>\n\n<h3>AI-Generated Insights</h3>\n<p>{{ $json.aiInsights.insights }}</p>\n\n<h3>Trends</h3>\n<p>{{ $json.aiInsights.trends }}</p>\n\n<h3>Recommendations</h3>\n<p>{{ $json.aiInsights.recommendations }}</p>\n\n<h3>Top Products This Week</h3>\n<ul>\n{{ $json.weeklyMetrics.topProducts.map(p => `<li>${p.name}: ${p.quantity} sold</li>`).join('') }}\n</ul>",
        "options": {},
        "subject": "Weekly Sales Report - {{ $now.toFormat('MMM dd, yyyy') }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "a9d7e01b-156f-4a53-bf79-7c1c48a17291",
      "name": "Log Metrics to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        560,
        672
      ],
      "parameters": {
        "operation": "appendRow",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "your-spreadsheet-id"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "5ab101bf-4c34-4a26-b186-55db6425c508",
      "name": "Check Revenue Drop >20%",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        672
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "revenue-drop-check",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ parseFloat($json.weeklyMetrics.revenueChange) }}",
              "rightValue": -20
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ef590b98-aba5-43f4-813b-e5c69958cce2",
      "name": "Send Revenue Drop Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        960,
        656
      ],
      "parameters": {
        "text": "\ud83d\udea8 **Revenue Alert** \ud83d\udea8\n\nSignificant revenue drop detected!\n\n\ud83d\udcc9 This week: ${{ $json.weeklyMetrics.totalRevenue }}\n\ud83d\udcca Change: {{ $json.weeklyMetrics.revenueChange }}%\n\n**Immediate attention required:**\n\u2022 Review marketing campaigns\n\u2022 Check inventory levels\n\u2022 Analyze customer feedback\n\u2022 Consider promotional strategies\n\n**AI Risk Assessment:**\n{{ $json.aiInsights.risks || 'Review recommended for declining performance' }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#alerts"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.2
    }
  ],
  "connections": {
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Post to Slack Channel",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email Report to Stakeholders",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log Metrics to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Sales Data": {
      "main": [
        [
          {
            "node": "Gemini Sales Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Sales Analysis": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Monday Trigger": {
      "main": [
        [
          {
            "node": "Get Last 7 Days Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Last 7 Days Orders": {
      "main": [
        [
          {
            "node": "Aggregate Sales Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Revenue Drop >20%": {
      "main": [
        [
          {
            "node": "Send Revenue Drop Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Metrics to Google Sheets": {
      "main": [
        [
          {
            "node": "Check Revenue Drop >20%",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

E-commerce store owners and sales managers who want AI-powered insights from their Shopify data without manually crunching numbers every week.

Source: https://n8n.io/workflows/13872/ — original creator credit. Request a take-down →

More E-commerce workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

E-commerce

This workflow automates inventory management and predictive reordering for Shopify stores. It integrates Shopify, Google Sheets, and Slack to monitor inventory levels, calculate dynamic reorder points

Shopify, Google Sheets, Gmail +2
E-commerce

E-commerce store management made easy. The workflow pulls your daily Shopify orders, calculates essential metrics like revenue and fulfillment rates, and categorizes them by status (shipped, returned,

Shopify, Google Sheets, Chain Llm +4
E-commerce

A webhook or timer triggers the workflow to automatically fetch inventory data from multiple platforms. Stock levels are compared across stores to identify discrepancies, and any inconsistencies are u

HTTP Request, Google Sheets, Gmail
E-commerce

Never miss a revenue-impacting failure. This n8n workflow monitors your Shopify store and triggers an alert if X minutes pass without a single new order. By automatically detecting unexpected drops in

Stop And Error, Slack, Gmail +1
E-commerce

This n8n automation identifies Magento 2 orders that have been stuck in the same status (like "processing") for the past 7 weekdays (excluding weekends), compiles them into a clean Google Sheet report

HTTP Request, Google Sheets, Gmail