{
  "id": "q1yAKyD2NfnwIDsO",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Brand Search Intelligence from AI SERPs (SE Ranking + OpenAI GPT 4.1-mini)",
  "tags": [
    {
      "id": "Kujft2FOjmOVQAmJ",
      "name": "Engineering",
      "createdAt": "2025-04-09T01:31:00.558Z",
      "updatedAt": "2025-04-09T01:31:00.558Z"
    },
    {
      "id": "ZOwtAMLepQaGW76t",
      "name": "Building Blocks",
      "createdAt": "2025-04-13T15:23:40.462Z",
      "updatedAt": "2025-04-13T15:23:40.462Z"
    },
    {
      "id": "ddPkw7Hg5dZhQu2w",
      "name": "AI",
      "createdAt": "2025-04-13T05:38:08.053Z",
      "updatedAt": "2025-04-13T05:38:08.053Z"
    },
    {
      "id": "qpxJxOMCv2x7Op5c",
      "name": "SERP",
      "createdAt": "2025-04-03T15:37:19.686Z",
      "updatedAt": "2025-04-03T15:37:19.686Z"
    }
  ],
  "nodes": [
    {
      "id": "895358ea-48f0-427a-994f-3edc9dc1ea11",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -960,
        32
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "483ba8b7-e005-44f1-8518-7da182f445aa",
      "name": "Set the Input Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -736,
        32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "51fefe77-637c-456c-b037-e53b76e74fc5",
              "name": "brand",
              "type": "string",
              "value": "LinkedIn"
            },
            {
              "id": "24725cc6-edeb-4c8d-b8e7-31d58ae53822",
              "name": "engine",
              "type": "string",
              "value": "perplexity"
            },
            {
              "id": "cf825d67-60e7-4505-b6be-d67d0fb8f98f",
              "name": "source",
              "type": "string",
              "value": "us"
            },
            {
              "id": "893bdd5a-2cbe-4a1a-b320-38f7623bc219",
              "name": "sort",
              "type": "string",
              "value": "volume"
            },
            {
              "id": "dac73871-e90a-4794-b055-28fd702a8509",
              "name": "sort_order",
              "type": "string",
              "value": "desc"
            },
            {
              "id": "d8d073ca-de12-4e4b-bce5-e658c69b264a",
              "name": "offset",
              "type": "string",
              "value": "0"
            },
            {
              "id": "0453df05-8fb6-4685-94f1-8dd37a95f067",
              "name": "limit",
              "type": "string",
              "value": "10"
            },
            {
              "id": "cbfe1705-e817-414d-a4c3-73ea9edeb576",
              "name": "multi_keyword_included",
              "type": "string",
              "value": "[  [  {  \"type\": \"contains\",  \"value\": \"seo\"  }  ] ]"
            },
            {
              "id": "9ed54323-3bb2-4471-aab2-fb642a2a95ef",
              "name": "multi_keyword_excluded",
              "type": "string",
              "value": "[   [     { \"type\": \"contains\", \"value\": \"seo\"   },     { \"type\": \"contains\", \"value\": \"tools\" }   ],   [     { \"type\": \"contains\", \"value\": \"backlinks\" }   ] ]"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "719e0593-3724-40c8-be91-f41e1aa53e92",
      "name": "Write File to Disk",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        544,
        160
      ],
      "parameters": {
        "options": {},
        "fileName": "=C:\\\\SERanking_ByBrand.json",
        "operation": "write",
        "dataPropertyName": "=data"
      },
      "typeVersion": 1
    },
    {
      "id": "92f5e132-aef9-4ee6-8260-5b0e8ead3c09",
      "name": "Create a Binary Data",
      "type": "n8n-nodes-base.function",
      "position": [
        320,
        160
      ],
      "parameters": {
        "functionCode": "items[0].binary = {\n  data: {\n    data: new Buffer(JSON.stringify(items[0].json, null, 2)).toString('base64')\n  }\n};\nreturn items;"
      },
      "typeVersion": 1
    },
    {
      "id": "48e30203-969f-4e0a-9a65-a72da9eb7e7e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 736,
        "content": "## Custom Data Extraction\n\nExtracts brand prompts, answers, and supporting reference links. Normalizes raw API responses into structured, usable data. Combines extracted prompts, answers, and links into a unified dataset. Prepares the data for analysis, reporting, or downstream workflows."
      },
      "typeVersion": 1
    },
    {
      "id": "bf8550e8-7696-4452-abd7-ade4a3f3ba67",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 736,
        "content": "## Export Data Handling\n\nConverts the final dataset into structured JSON output. Stores results for brand research, content strategy, or automation."
      },
      "typeVersion": 1
    },
    {
      "id": "902893f3-c4bb-428e-b316-3684aaf04ace",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 736,
        "content": "## AI Search with SE Ranking by Brand\n\nRetrieves real AI search prompts and answers related to a specific brand. Provides authentic brand-level search intelligence from AI-driven SERPs."
      },
      "typeVersion": 1
    },
    {
      "id": "cd0848e1-9440-47d8-944b-33d67c67c2f8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -192
      ],
      "parameters": {
        "width": 496,
        "height": 752,
        "content": "## **How It Works**\n\nThis workflow analyzes real AI search prompts associated with a specific brand using SE Ranking. It starts with a manual trigger where brand name, AI search engine, region, sorting preferences, and limits are configured. These parameters are sent to the **SE Ranking Prompts by Brand API** to retrieve real-world AI-generated search prompts, answers, and supporting links related to the brand.\n\n## **Setup Instructions**\n\n1. Configure credentials:\n\n   * **SE Ranking API** via HTTP Header Authentication.\n2. Update the **Set the Input Fields** node with your target brand, AI engine, region, and result limits.\n3. Confirm the output file path in the **Write File to Disk** node matches your environment.\n4. Click **Execute Workflow** to generate brand-based AI search insights.\n\n## **Customize**\n\n* Change the brand name to analyze different companies or products.\n* Adjust sorting, limits, or AI engines to explore alternative search behaviors.\n* Add OpenAI summarization or classification steps for deeper insight enrichment.\n* Replace file export with database, dashboard, or webhook integrations for automation.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b29ace75-4b53-4edf-bcfb-664c41895fb7",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -448
      ],
      "parameters": {
        "color": 7,
        "width": 496,
        "height": 240,
        "content": "![Logo](https://media.licdn.com/dms/image/v2/D4D0BAQHBbVpuDD3toA/company-logo_200_200/company-logo_200_200/0/1725976307233/se_ranking_logo?e=1768435200&v=beta&t=_HSGZks62sL6rTXwuo0U21QCKBCNzVT_8OkeIPUr4N8)\n\nOpenAI GPT-4o-mini for the Structured Data Extraction and Data Mining Purposes"
      },
      "typeVersion": 1
    },
    {
      "id": "e533bd48-c24e-4467-993d-6112e5b6a82b",
      "name": "Extract All Links",
      "type": "n8n-nodes-base.code",
      "position": [
        -224,
        0
      ],
      "parameters": {
        "jsCode": "const prompts = $input.first().json.prompts || [];\n\nconst urls = prompts.flatMap(p => p.answer?.links || []);\n\nconst data = urls\n  .filter(Boolean)\n  .map(u => u.trim())\n  .filter(u => u.startsWith(\"http\"));\n\nreturn [{ links: data }];"
      },
      "typeVersion": 2
    },
    {
      "id": "cec3ee7c-16f2-4eae-a14f-e91e29dca4b9",
      "name": "Extract Prompts with Answers",
      "type": "n8n-nodes-base.code",
      "position": [
        -224,
        192
      ],
      "parameters": {
        "jsCode": "/**\n * Extract prompts with answers (excluding links)\n * Input: SE Ranking AI Search API response\n * Output: Array of { prompt, answer }\n */\n\nconst output = [];\nconst data = $input.first().json\nfor (const p of data.prompts) {\n  if (p.prompt && p.answer?.text) {\n    output.push({\n      json: {\n        prompt: p.prompt.trim(),\n        answer: p.answer.text.trim()\n      }\n    });\n  }\n}\n\nreturn { prompts: output}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "ceb38a90-52a3-46f1-8268-1feb0a9eb329",
      "name": "Extract JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        -224,
        400
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json.prompts\nreturn { prompts_with_links: data}"
      },
      "typeVersion": 2
    },
    {
      "id": "52e48cc2-dbd4-464a-a665-98acc660f4f8",
      "name": "SE Ranking AI Request by Brand",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -512,
        32
      ],
      "parameters": {
        "url": "https://api.seranking.com/v1/ai-search/prompts-by-brand",
        "options": {
          "redirect": {
            "redirect": {
              "followRedirects": false
            }
          }
        },
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "brand",
              "value": "={{ $json.brand }}"
            },
            {
              "name": "source",
              "value": "={{ $json.source }}"
            },
            {
              "name": "engine",
              "value": "={{ $json.engine }}"
            },
            {
              "name": "sort",
              "value": "={{ $json.sort }}"
            },
            {
              "name": "sort_order",
              "value": "={{ $json.sort_order }}"
            },
            {
              "name": "offset",
              "value": "={{ $json.offset }}"
            },
            {
              "name": "limit",
              "value": "={{ $json.limit }}"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 4.3
    },
    {
      "id": "20d98b5d-9228-40b9-a735-d2527b2fcf71",
      "name": "Merge Responses",
      "type": "n8n-nodes-base.merge",
      "position": [
        48,
        144
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6fa4959c-0be5-4425-87f5-298ba421fa09",
  "connections": {
    "Extract JSON": {
      "main": [
        [
          {
            "node": "Merge Responses",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Merge Responses": {
      "main": [
        [
          {
            "node": "Create a Binary Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract All Links": {
      "main": [
        [
          {
            "node": "Merge Responses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a Binary Data": {
      "main": [
        [
          {
            "node": "Write File to Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set the Input Fields": {
      "main": [
        [
          {
            "node": "SE Ranking AI Request by Brand",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Prompts with Answers": {
      "main": [
        [
          {
            "node": "Merge Responses",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "SE Ranking AI Request by Brand": {
      "main": [
        [
          {
            "node": "Extract All Links",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract Prompts with Answers",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set the Input Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}