{
  "name": "Daily Reddit mentions → Zendesk tickets + Linear issues (rich_minds/reddit-brand-monitoring-ai)",
  "nodes": [
    {
      "parameters": {
        "rule": {"interval": [{"field": "days", "triggerAtHour": 8}]}
      },
      "name": "Every day 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/rich_minds~reddit-brand-monitoring-ai/run-sync-get-dataset-items?timeout=290",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"sourceMode\": \"actor\",\n  \"brandTerms\": [\"acme crm\"],\n  \"brandBrief\": \"Acme CRM — the sales CRM for small agencies. Replace with your product in one sentence.\",\n  \"timeWindow\": \"day\",\n  \"mentionTypes\": [\"complaint\", \"pain_point\", \"feature_request\", \"question\"],\n  \"enableAi\": true,\n  \"maxItemsPerSearch\": 75,\n  \"maxDiscoveryChargeUsd\": 0.5,\n  \"dedupeAcrossRuns\": true\n}",
        "options": {"timeout": 300000}
      },
      "name": "Run Reddit Brand Monitoring (new mentions only)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [240, 0],
      "notes": "Credential: Header Auth, name 'Authorization', value 'Bearer <your Apify API token>'. dedupeAcrossRuns keeps each day to NEW mentions, so a mention never opens two tickets. suggestedAction route_to_support / route_to_product is set on every row (AI tier: from the text; basic tier: from the mention type)."
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "conditions": [
                  {"leftValue": "={{ $json.suggestedAction }}", "rightValue": "route_to_support", "operator": {"type": "string", "operation": "equals"}}
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "support"
            },
            {
              "conditions": {
                "conditions": [
                  {"leftValue": "={{ $json.suggestedAction }}", "rightValue": "route_to_product", "operator": {"type": "string", "operation": "equals"}}
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "product"
            }
          ]
        },
        "options": {}
      },
      "name": "Route by suggestedAction",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [480, 0]
    },
    {
      "parameters": {
        "resource": "ticket",
        "operation": "create",
        "description": "=Reddit {{ $json.kind }} in r/{{ $json.subreddit }} by {{ $json.author }} ({{ $json.authorUrl }})\n\n{{ $json.text }}\n\nWhy: {{ $json.actionReason }}\nEvidence: \"{{ $json.evidenceQuote }}\"\nLink: {{ $json.url }}",
        "additionalFields": {
          "subject": "=[Reddit · {{ $json.priority }}] {{ $json.name }}",
          "externalId": "={{ $json.dedupeKey }}",
          "tags": ["reddit", "brand-monitoring"]
        }
      },
      "name": "Zendesk: create a ticket",
      "type": "n8n-nodes-base.zendesk",
      "typeVersion": 1,
      "position": [720, -100],
      "notes": "Swap for HubSpot → Ticket → Create (same fields) if your support desk is HubSpot. externalId = dedupeKey, so a re-run never duplicates a ticket."
    },
    {
      "parameters": {
        "resource": "issue",
        "operation": "create",
        "teamId": "<your Linear team id>",
        "title": "=[Reddit] {{ $json.insight || $json.name }}",
        "additionalFields": {
          "description": "=**{{ $json.mentionType }}** · {{ $json.sentiment }} · r/{{ $json.subreddit }} · {{ $json.upvotes }} upvotes\n\n> {{ $json.evidenceQuote }}\n\n{{ $json.url }}\n\nKey: {{ $json.dedupeKey }}"
        }
      },
      "name": "Linear: create an issue",
      "type": "n8n-nodes-base.linear",
      "typeVersion": 1,
      "position": [720, 100]
    }
  ],
  "connections": {
    "Every day 08:00": {"main": [[{"node": "Run Reddit Brand Monitoring (new mentions only)", "type": "main", "index": 0}]]},
    "Run Reddit Brand Monitoring (new mentions only)": {"main": [[{"node": "Route by suggestedAction", "type": "main", "index": 0}]]},
    "Route by suggestedAction": {"main": [
      [{"node": "Zendesk: create a ticket", "type": "main", "index": 0}],
      [{"node": "Linear: create an issue", "type": "main", "index": 0}]
    ]}
  },
  "settings": {"executionOrder": "v1"}
}