Sales data analyst AI agent

Ask questions about your sales in plain words: best products, cities, months and margins, answered with real numbers.

AI agentMedium Saves ~8 hours/month AI AgentsBy Flowngn team

Works with n8n · Make · Zapier

How it works

Trigger: Chat — you ask a question
  1. You ask, e.g. "which city grew most this month?".
  2. The agent reads your Sales sheet and does the maths.
  3. It answers with the key numbers and one insight.
  4. It can post the summary to Slack.

What it can do

Unlike a fixed flow, an agent decides which of its tools to use, in what order — and remembers the conversation.

  • Totals, averages, growth and top-5 lists
  • Margins by product, city or channel
  • Short text tables for comparisons

System prompt

The instructions that shape the agent. It's already inside the n8n template — copy it into Make or Zapier, and adjust the YOUR_… parts.

System prompt
You are a data analyst for YOUR_BUSINESS. You answer questions about our sales data with numbers. Today is {{ $now.toFormat('d LLLL yyyy') }}. Currency: YOUR_CURRENCY.

Tools:
- "Read sales": every order (date, order_id, customer, city, channel, product, quantity, revenue, cost).
- "Post to Slack": posts a finished summary to the team channel. Use only when the user asks to share.

How to answer:
1. Always read the data first. State the period you used.
2. Do the arithmetic carefully: totals, averages, growth vs the previous period, top 5 lists.
3. Answer in 3–6 lines with the key numbers, then one practical insight or question to dig into.
4. Show a small text table when comparing more than 3 items.

Rules:
- Never guess numbers. If the data doesn't answer the question, say what's missing.
- Gross margin = (revenue − cost) / revenue.
- Don't share individual customers' personal details in Slack posts.

Safety rules

Built into the prompt and the tools:

  • Never guesses numbers; says what data is missing
  • Keeps customer details out of Slack posts

Uses your own AI key (Claude, OpenAI or another model). Cost depends on the model and conversation length — a small, fast model keeps most conversations to a fraction of a cent.

Diagram

Analyst chatChat TriggerAnalyst agentAI AgentClaude modelAnthropic Chat Mo…◷MemorySimple MemoryGRead salesGoogle Sheets ToolSPost to SlackSlack Tool
Trigger AI Agent tool

Build it

Pick your tool — same automation, step by step.

Copy and paste straight into an n8n canvas (Ctrl+V), or download and use Import from File. Then connect your own credentials and replace every YOUR_… placeholder. AI steps use a Claude model node — swap it for OpenAI, Gemini or Ollama if you prefer.

Workflow JSON
Show code (198 lines)
{
  "name": "Sales data analyst AI agent (Flowngn)",
  "nodes": [
    {
      "parameters": {
        "content": "## Sales data analyst AI agent\nAsk questions about your sales in plain words: best products, cities, months and margins, answered with real numbers.\n\n**Setup**\n1. Open each node and connect your own credentials.\n2. Replace every YOUR_… placeholder.\n3. Test once, then activate.\n\nFree template from Flowngn",
        "height": 260,
        "width": 340
      },
      "id": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -420,
        -60
      ]
    },
    {
      "parameters": {
        "public": true,
        "mode": "hostedChat",
        "initialMessages": "Ask me anything about your sales: best products, cities, months, margins…",
        "options": {
          "responseMode": "lastNode"
        }
      },
      "id": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e",
      "name": "Analyst chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "webhookId": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e"
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "=You are a data analyst for YOUR_BUSINESS. You answer questions about our sales data with numbers. Today is {{ $now.toFormat('d LLLL yyyy') }}. Currency: YOUR_CURRENCY.\n\nTools:\n- \"Read sales\": every order (date, order_id, customer, city, channel, product, quantity, revenue, cost).\n- \"Post to Slack\": posts a finished summary to the team channel. Use only when the user asks to share.\n\nHow to answer:\n1. Always read the data first. State the period you used.\n2. Do the arithmetic carefully: totals, averages, growth vs the previous period, top 5 lists.\n3. Answer in 3–6 lines with the key numbers, then one practical insight or question to dig into.\n4. Show a small text table when comparing more than 3 items.\n\nRules:\n- Never guess numbers. If the data doesn't answer the question, say what's missing.\n- Gross margin = (revenue − cost) / revenue.\n- Don't share individual customers' personal details in Slack posts."
        }
      },
      "id": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e",
      "name": "Analyst agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        300,
        0
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "claude-sonnet-5",
          "mode": "list"
        },
        "options": {}
      },
      "id": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e",
      "name": "Claude model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.3,
      "position": [
        45,
        220
      ]
    },
    {
      "parameters": {
        "contextWindowLength": 10
      },
      "id": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e",
      "name": "Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        215,
        220
      ]
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Returns every order: date, order_id, customer, city, channel, product, quantity, revenue, cost.",
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Sales",
          "mode": "name"
        },
        "options": {}
      },
      "id": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e",
      "name": "Read sales",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        385,
        220
      ]
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Posts a finished summary to the team channel.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "#numbers",
          "mode": "name"
        },
        "text": "={{ $fromAI('summary', \"The summary to share\", 'string') }}",
        "otherOptions": {}
      },
      "id": "2473c6c3-ceef-44d1-aca0-1bb2b8b2ff2e",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slackTool",
      "typeVersion": 2.2,
      "position": [
        555,
        220
      ]
    }
  ],
  "connections": {
    "Analyst chat": {
      "main": [
        [
          {
            "node": "Analyst agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyst agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Memory": {
      "ai_memory": [
        [
          {
            "node": "Analyst agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Read sales": {
      "ai_tool": [
        [
          {
            "node": "Analyst agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Post to Slack": {
      "ai_tool": [
        [
          {
            "node": "Analyst agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}

Open in the playground to edit →

Tips

  • Large sheets slow it down; keep the last 12 months in the Sales tab and archive the rest.

Related flows