{
  "name": "02 \u2014 Approval inbox \u2192 Slack",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 30
            }
          ]
        }
      },
      "id": "trigger-30m",
      "name": "Every 30 min",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=http://host.docker.internal:4000/api/approvals",
        "options": {}
      },
      "id": "http-approvals",
      "name": "GET /api/approvals",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "items",
        "options": {}
      },
      "id": "split-items",
      "name": "Split per item",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        720,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const r = $input.first().json;\nconst item = r.item;\nconst dashboard = ($env.DASHBOARD_URL || 'http://localhost:3000') + '/approvals';\nconst text = `*New script awaiting approval* \u2014 ${r.campaignName || 'campaign'}\\n*${item.topic}*\\n_${item.type} \u00b7 ${r.industryName || '\u2014'} \u00b7 ${item.language.toUpperCase()}_\\n\\n${item.hook}\\n\\nReview: ${dashboard}`;\nreturn [{ json: { text, itemId: item.id } }];"
      },
      "id": "format",
      "name": "Format Slack message",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.SLACK_WEBHOOK_URL }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={ \"text\": $json.text }",
        "options": {}
      },
      "id": "slack-post",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1200,
        300
      ]
    }
  ],
  "connections": {
    "Every 30 min": {
      "main": [
        [
          {
            "node": "GET /api/approvals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET /api/approvals": {
      "main": [
        [
          {
            "node": "Split per item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split per item": {
      "main": [
        [
          {
            "node": "Format Slack message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Slack message": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "versionId": "1",
  "tags": [
    "social-agent",
    "approvals"
  ]
}