{
  "name": "Snapchat Discover Publisher Show Extractor (long runs)",
  "nodes": [
    {
      "id": "2ffa0f1e-2f52-4c4f-a37b-24222168035b",
      "name": "Run by hand",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "a54f407e-cec5-43f5-a58d-c9cc1a4d8be3",
      "name": "Every day",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        200
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "notes": "Activate the workflow to run on this schedule."
    },
    {
      "id": "c4315a8a-800a-4a04-a09b-97996c1b6813",
      "name": "Start Apify run",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        100
      ],
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/actors/nimbryxo-studio~snapchat-discover-publisher-show-extractor/runs?waitForFinish=60",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"mode\": \"discover\",\n  \"maxStories\": 20,\n  \"country\": \"US\",\n  \"locale\": \"en-US\",\n  \"storyTypes\": \"all\",\n  \"includeEpisodes\": false,\n  \"maxEpisodesPerPublisher\": 10,\n  \"includeEpisodeMedia\": false\n}",
        "options": {
          "timeout": 90000
        }
      },
      "notes": "Actor: nimbryxo-studio/snapchat-discover-publisher-show-extractor. Starts the run and waits up to 60 s for it. Header Auth credential: name Authorization, value Bearer + your Apify token."
    },
    {
      "id": "55f51856-4ba9-4ced-a50e-cbf81618b93b",
      "name": "Run finished?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        520,
        100
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f1bc86a6-d71e-4d8f-a1c3-01a67d34778b",
              "leftValue": "={{ ['SUCCEEDED', 'FAILED', 'ABORTED', 'TIMED-OUT'].includes($json.data.status) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "28a8b392-fc6b-49d8-a68f-e8a9020872d7",
      "name": "Check the run again",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        520,
        320
      ],
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/actor-runs/{{ $json.data.id }}?waitForFinish=60",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 90000
        }
      },
      "notes": "Waits up to 60 s per check, then loops back."
    },
    {
      "id": "90ced37e-673b-455b-a4e2-fe9201bb9d73",
      "name": "Run succeeded?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        780,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "15047f5e-55a0-4791-a939-e70ca445f303",
              "leftValue": "={{ $json.data.status === 'SUCCEEDED' }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "c59cee6a-2a23-412c-a3f8-36815f987b8f",
      "name": "Get the results",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1040,
        -100
      ],
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/datasets/{{ $json.data.defaultDatasetId }}/items?clean=true",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "timeout": 120000
        }
      },
      "notes": "Each record of the run's dataset becomes one n8n item. Connect your destination after this node."
    },
    {
      "id": "a7b16bee-c2ab-4951-a9cb-65d0dee128a3",
      "name": "Run did not succeed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1040,
        100
      ],
      "parameters": {
        "errorMessage": "={{ 'Apify run ' + $json.data.id + ' ended with status ' + $json.data.status }}"
      }
    },
    {
      "id": "7e8f51be-b2f9-4249-a8d6-eaccfe318ed3",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -400
      ],
      "parameters": {
        "content": "## Snapchat Discover Publisher Show Extractor: long runs\n\nSource: [nimbryxo-studio/snapchat-discover-publisher-show-extractor](https://apify.com/nimbryxo-studio/snapchat-discover-publisher-show-extractor) on Apify.\n\nFor runs that need more than 5 minutes (the synchronous endpoint answers HTTP 408 after 300 s).\n1. Select the same Header Auth credential (name `Authorization`, value `Bearer YOUR_APIFY_TOKEN`) in the three HTTP Request nodes.\n2. Edit the JSON body of **Start Apify run** to change the input.\n3. Connect your destination after **Get the results**.\n\nGenerated by recipeforagents.com. Validated, not executed: runs are billed to your Apify account.",
        "height": 360,
        "width": 500,
        "color": 6
      }
    }
  ],
  "connections": {
    "Run by hand": {
      "main": [
        [
          {
            "node": "Start Apify run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every day": {
      "main": [
        [
          {
            "node": "Start Apify run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Apify run": {
      "main": [
        [
          {
            "node": "Run finished?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run finished?": {
      "main": [
        [
          {
            "node": "Run succeeded?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check the run again",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check the run again": {
      "main": [
        [
          {
            "node": "Run finished?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run succeeded?": {
      "main": [
        [
          {
            "node": "Get the results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Run did not succeed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
