{
  "id": "GA1HTM4YyIidEJb3",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automated TikTok Influencer Discovery & Analysis via Bright Data and Anthropic AI and Send Email Notification",
  "tags": [],
  "nodes": [
    {
      "id": "cb75134b-4746-4715-87b4-c2bb596d4366",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        1460,
        300
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-20250514",
          "cachedResultName": "Claude 4 Sonnet"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "aef0b016-6017-4b2a-8bcc-56e78b9a5cc1",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        1680,
        0
      ],
      "parameters": {
        "jsCode": "// N8N Code Node to extract data from AI output\nconst items = $input.all();\n\nreturn items.map(item => {\n  try {\n    // Get the output string from the item\n    const outputString = item.json.output;\n    \n    // Extract JSON from the markdown code block\n    const jsonMatch = outputString.match(/```json\\n([\\s\\S]*?)\\n```/);\n    \n    if (jsonMatch && jsonMatch[1]) {\n      // Parse the extracted JSON\n      const parsedData = JSON.parse(jsonMatch[1]);\n      \n      // Return the extracted data as separate columns\n      return {\n        json: {\n          Collaboration: parsedData.Collaboration || '',\n          Analysis: parsedData.Analysis || '',\n          Profile_ID: parsedData['Profile ID'] || '',\n          // Keep original data as well if needed\n          original_output: outputString\n        }\n      };\n    } else {\n      // If no JSON found, return empty values\n      return {\n        json: {\n          Collaboration: '',\n          Analysis: '',\n          Profile_ID: '',\n          original_output: outputString,\n          error: 'No JSON found in output'\n        }\n      };\n    }\n  } catch (error) {\n    // Handle any parsing errors\n    return {\n      json: {\n        Collaboration: '',\n        Analysis: '',\n        Profile_ID: '',\n        original_output: item.json.output || '',\n        error: `Parsing error: ${error.message}`\n      }\n    };\n  }\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "51d9eee9-63c0-43a4-bb03-d94a1d9ceb2a",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1980,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "Analysis": "={{ $json.Analysis }}",
            "Profile ID": "={{ $json.Profile_ID }}",
            "Collaboration": "={{ $json.Collaboration }}"
          },
          "schema": [
            {
              "id": "Profile ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Profile ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Username",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Username",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Followers",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Followers",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collaboration",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Collaboration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Analysis",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Analysis",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Profile ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "YOUR_GOOGLE_SHEET_URL",
          "cachedResultName": "TikTok"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "YOUR_GOOGLE_SHEET_URL"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "4db5fe1f-9038-4746-859b-7b38a2b3056d",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        2240,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7c4c648b-a7df-41d6-bc6c-b6d05221f7bf",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Collaboration }}",
              "rightValue": "Highly Relevant"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "50db5760-83fe-4119-bb18-27d637acbee9",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2520,
        0
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Hi,\nI wanted to share some of the best TikTok creators perfectly matched to collaborate with your business. These influencers align closely with your brand and audience, helping you maximize your reach and impact.\nUsername: {{ $('Update Data in the Google Sheet').item.json.Username }}\nTikTok Profile: {{ $('Update Data in the Google Sheet').item.json.URL }}\nFollowers: {{ $('Update Data in the Google Sheet').item.json.Followers }}\n\nLet me know if you'd like more details or to explore specific collaboration opportunities.\n\nBest regards",
        "options": {},
        "subject": "Top TikTok Influencer Match for Your Business Collaboration",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a6067955-adf4-4926-8082-81459d5aff1d",
      "name": "Scrape Data from TikTok through Keyword by BrightData",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        0
      ],
      "parameters": {
        "url": "https://api.brightdata.com/datasets/v3/trigger",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"input\": [\n    {\n      \"search_keyword\": \"{{ $json['Search Keyword'] }}\",\n      \"country\": \"\"\n    }\n  ],\n  \"custom_output_fields\": [\n    \"url\",\n    \"description\",\n    \"profile_id\",\n    \"profile_username\",\n    \"profile_url\",\n    \"profile_followers\"\n  ]\n}",
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "queryParameters": {
          "parameters": [
            {
              "name": "dataset_id",
              "value": "YOUR_BRIGHTDATA_DATASET_ID"
            },
            {
              "name": "include_errors",
              "value": "true"
            },
            {
              "name": "type",
              "value": "discover_new"
            },
            {
              "name": "discover_by",
              "value": "keyword"
            },
            {
              "name": "limit_per_input",
              "value": "5"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fbc8f8b2-5e63-4914-b4b8-a44fa5163cda",
      "name": "3 Minute Wait Time",
      "type": "n8n-nodes-base.wait",
      "position": [
        520,
        0
      ],
      "parameters": {
        "unit": "minutes",
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "9ad6728c-2136-46bb-9ddf-0d445b28be22",
      "name": "Extract Data from Snapshot Generated by BrightData",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        0
      ],
      "parameters": {
        "url": "=https://api.brightdata.com/datasets/v3/snapshot/{{ $json.snapshot_id }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "format",
              "value": "json"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8e3577fb-1077-44d4-bada-ca9f5f2aa141",
      "name": "Update Data in the Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1040,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "URL": "={{ $json.profile_url }}",
            "Username": "={{ $json.profile_username }}",
            "Followers": "={{ $json.profile_followers }}",
            "Profile ID": "={{ $json.profile_id }}",
            "Description": "={{ $json.description }}"
          },
          "schema": [
            {
              "id": "Profile ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Profile ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Username",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Username",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Followers",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Followers",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collaboration",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Collaboration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Analysis",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Analysis",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "YOUR_GOOGLE_SHEET_URL",
          "cachedResultName": "TikTok"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "YOUR_GOOGLE_SHEET_URL"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "16bfd75e-fc30-4e6f-94f2-5e554d25cf64",
      "name": "Find the Collaborator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1300,
        0
      ],
      "parameters": {
        "text": "=Assume you are a social media expert and you find the best influencers based on the business and industry by analyzing the below data.\nHere are the Details of the Influencers.\nProfile URL: {{ $json.URL }}\nDescription: {{ $json.Description }}\nFollowers: {{ $json.Followers }}\nProfile ID: {{ $json['Profile ID'] }}\n\nMy Business Details:\nAbout my business: {{ $('Submit Form with Keyword, Business Info, Industry').item.json['About My Business'] }}\nIndustry: {{ $('Submit Form with Keyword, Business Info, Industry').item.json.Industry }}\n\nRequirements:\nFollowers should be more than 5000\nand Influencer should be in my industry.\nand Just Provide the Output according to below format\n\nFormat:\nOutput should be in Json\nCollaboration: Not Relevant, Highly Relevant\nAnalysis: Explain in 50 words\nProfile ID: Just add the Profile ID without any change\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "6d482ee5-fd98-4ed3-bfac-dc1ca014769f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -80
      ],
      "parameters": {
        "color": 2,
        "width": 220,
        "height": 260,
        "content": "Triggers the workflow when user submits keyword, business info & industry via form."
      },
      "typeVersion": 1
    },
    {
      "id": "2b3f2a04-cee9-4fae-8199-2c5cef6969cd",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        -80
      ],
      "parameters": {
        "color": 3,
        "height": 260,
        "content": "Calls Bright Data API to fetch TikTok profiles by keyword."
      },
      "typeVersion": 1
    },
    {
      "id": "3aed623a-1827-4641-96dc-d652332946e9",
      "name": "Submit Form with Keyword, Business Info, Industry",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "formTitle": "TikTok Profile Scraper",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Search Keyword"
            },
            {
              "fieldLabel": "About My Business"
            },
            {
              "fieldLabel": "Industry"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c8434c0a-5df9-43e6-924e-6078bbf13c3f",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        -80
      ],
      "parameters": {
        "color": 4,
        "height": 260,
        "content": "Waits 3 minutes to allow Bright Data to complete scraping."
      },
      "typeVersion": 1
    },
    {
      "id": "951080be-56e7-4616-a8f3-4bdf6e29be06",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -80
      ],
      "parameters": {
        "color": 5,
        "height": 260,
        "content": "Fetches snapshot data (scraped influencer profiles) from Bright Data."
      },
      "typeVersion": 1
    },
    {
      "id": "2fe42472-7b93-41f3-b2d9-ddf6a1472c32",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        -80
      ],
      "parameters": {
        "color": 6,
        "height": 260,
        "content": "Stores raw influencer data (ID, followers, description, etc.) in Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "c6340b5e-bd02-469c-909c-5300430fcba8",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1260,
        -80
      ],
      "parameters": {
        "color": 2,
        "width": 360,
        "height": 260,
        "content": "Uses Claude AI to evaluate each influencer's relevance to your business. Returns profile ID, relevance, and a 50-word analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "3c94de79-c64d-4d89-ad9d-387314d84d2b",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1380,
        200
      ],
      "parameters": {
        "color": 6,
        "height": 240,
        "content": "Claude Sonnet 4 model that powers the influencer analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "eb61e536-d234-450c-94db-896d24757ad5",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1640,
        -80
      ],
      "parameters": {
        "color": 4,
        "height": 260,
        "content": "Parses Claude AI's markdown output and extracts structured JSON fields for further use."
      },
      "typeVersion": 1
    },
    {
      "id": "d08dd360-e26f-421a-bf1f-95976adce3a2",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1900,
        -80
      ],
      "parameters": {
        "color": 3,
        "width": 260,
        "height": 260,
        "content": "Logs Claude's insights (Profile ID, Collaboration status, Analysis) into Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "02d41818-b12f-4b45-9e93-f3b7162cd6f6",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2180,
        -80
      ],
      "parameters": {
        "height": 260,
        "content": "Filters results to retain only Highly Relevant influencers for email outreach."
      },
      "typeVersion": 1
    },
    {
      "id": "873b1c8a-fb26-40ca-9885-51c80eb1bd61",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2440,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 260,
        "content": "Sends personalized collaboration email to your target contact with top influencer information."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "18042508-1631-4802-8863-d015a36bed62",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3 Minute Wait Time": {
      "main": [
        [
          {
            "node": "Extract Data from Snapshot Generated by BrightData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Find the Collaborator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Find the Collaborator": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Data in the Google Sheet": {
      "main": [
        [
          {
            "node": "Find the Collaborator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Submit Form with Keyword, Business Info, Industry": {
      "main": [
        [
          {
            "node": "Scrape Data from TikTok through Keyword by BrightData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Data from Snapshot Generated by BrightData": {
      "main": [
        [
          {
            "node": "Update Data in the Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Data from TikTok through Keyword by BrightData": {
      "main": [
        [
          {
            "node": "3 Minute Wait Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}