{
  "id": "z82YLTAObSRGi4C7",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Find TikTok Video Questions from Keywords Using Dumpling AI + GPT-4",
  "tags": [],
  "nodes": [
    {
      "id": "1fb5c245-3539-4d68-bdb6-60619577e6d4",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1040,
        -240
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b09c504c-ceeb-4a00-889f-4a9c19eb0be4",
      "name": "Receive Keyword Input",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -528,
        208
      ],
      "parameters": {
        "options": {},
        "formTitle": "Tik Tok Search ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Keywords"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "bc607c71-7c66-43ef-b879-98f9131bb35d",
      "name": "Search TikTok Users (Dumpling AI)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -304,
        208
      ],
      "parameters": {
        "url": "https://app.dumplingai.com/api/v1/search-tiktok-users",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "query",
              "value": "={{ $json.Keywords }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cd3017fb-7ff0-477c-b213-b90dfe728225",
      "name": "Split Search Results into Users",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -80,
        208
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "userList"
      },
      "typeVersion": 1
    },
    {
      "id": "589d6871-c469-403a-adbc-f387eb07d007",
      "name": "Limit to 3 Users (Optional)",
      "type": "n8n-nodes-base.limit",
      "position": [
        144,
        208
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "986d014a-8c4e-40b5-9350-dc31e1529319",
      "name": "Loop Through TikTok Users",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        368,
        208
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "27944e93-66b9-4e2a-a6c7-2a0978cfe96d",
      "name": "Wait to Respect Rate Limits",
      "type": "n8n-nodes-base.wait",
      "position": [
        624,
        288
      ],
      "parameters": {
        "amount": 15
      },
      "typeVersion": 1.1
    },
    {
      "id": "314fddf5-735e-43a2-bf2f-d2758d010640",
      "name": "Get TikTok Profile Videos (Dumpling AI)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        816,
        288
      ],
      "parameters": {
        "url": "https://app.dumplingai.com/api/v1/get-tiktok-profile-videos",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "handle",
              "value": "={{ $json.user.search_user_name }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fd4266b2-8de3-46ea-9d9c-699cdc4ed31d",
      "name": "Split Videos from Profile",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        528,
        -112
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "aweme_list"
      },
      "typeVersion": 1
    },
    {
      "id": "ae9dbbbe-6fed-4c34-ba8b-1923b39f5f66",
      "name": "Loop Through Videos",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        848,
        -112
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "06fc76b0-85a2-4313-948d-50e46a2882b2",
      "name": "Get Comments for Each Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1040,
        -64
      ],
      "parameters": {
        "url": "https://app.dumplingai.com/api/v1/get-tiktok-video-comments",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.share_info.share_url }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e8c9360a-2ea2-4814-90a8-691f4774a37c",
      "name": "Extract Clean Comments (Python)",
      "type": "n8n-nodes-base.code",
      "position": [
        1264,
        -64
      ],
      "parameters": {
        "language": "python",
        "pythonCode": "# n8n Python Code Node\n# Extract all TikTok comment texts and return them in one structured block under \"Comment\"\n\ncomments_list = []\n\ndef extract_texts(comments):\n    for comment in comments:\n        if \"text\" in comment and comment[\"text\"]:\n            comments_list.append({\"text\": comment[\"text\"]})\n        if \"reply_comment\" in comment and comment[\"reply_comment\"]:\n            extract_texts(comment[\"reply_comment\"])\n\ndata = items[0].get(\"json\", {})\n\nif isinstance(data, list) and len(data) > 0 and \"comments\" in data[0]:\n    extract_texts(data[0][\"comments\"])\nelif \"comments\" in data:\n    extract_texts(data[\"comments\"])\n\nreturn [{\n    \"json\": {\n        \"Comment\": comments_list\n    }\n}]\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2d41131b-a582-46ce-ae5a-167fdf213ec6",
      "name": "Find Top Viewer Questions (GPT-4)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1488,
        -64
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "GPT-4.1"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an experienced TikTok content strategist. I will give you a collection of comments from a TikTok video. Your job is to carefully read through all the comments and identify the most commonly asked questions. These questions should be phrased exactly or very closely to how viewers ask them, not reworded in a generic way.\n\nPlease follow these steps:\n\nRead all the comments carefully and group similar questions together, even if they are worded slightly differently.\n\nIdentify the top recurring questions that appear the most.\n\nPresent the top questions clearly and concisely, ranked by frequency.\n\nExclude spam, unrelated chatter, or emoji-only comments.\n\nDo not generate answers, only list the questions."
            },
            {
              "content": "=Here is the comment data: {{ JSON.stringify($json.Comment) }}\n\n"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "7dfc9bb9-8fbe-443d-abb5-5c8cafb17009",
      "name": "Insert Result into DataTable",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1840,
        16
      ],
      "parameters": {
        "columns": {
          "value": {
            "Videos": "={{ $('Loop Through Videos').item.json.share_info.share_url }}",
            "Keywords": "={{ $json.message.content }}"
          },
          "schema": [
            {
              "id": "Videos",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Videos",
              "defaultMatch": false
            },
            {
              "id": "Keywords",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Keywords",
              "defaultMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "list",
          "value": "2fPy6VQQ9KIeBIFC",
          "cachedResultUrl": "/projects/BTzFLWjYjhwngt0G/datatables/2fPy6VQQ9KIeBIFC",
          "cachedResultName": "Tik Tok Keywords"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f1dddf8a-5393-4a3c-a719-7a9b8977bea3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        -64
      ],
      "parameters": {
        "width": 1008,
        "height": 512,
        "content": "## \ud83d\udd0e Branch 1 \u2013 Search TikTok Users and Get Videos\n\n1. Trigger runs when a keyword is submitted via form  \n2. Dumpling AI searches TikTok for matching users  \n3. Splits users and limits to 3 (optional)  \n4. For each user, fetches their latest videos  \n5. Splits video list for individual processing\n\n\u2705 Uses Dumpling AI to fetch TikTok profiles and their video content\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1b1e9809-c98a-4bd6-a5e3-ab354330319b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        -464
      ],
      "parameters": {
        "color": 6,
        "width": 1440,
        "height": 576,
        "content": "## \ud83d\udcac Branch 2 \u2013 Extract Questions from Comments with AI\n\n1. Loops through each video  \n2. Uses Dumpling AI to get video comments  \n3. Python code cleans raw comments  \n4. GPT-4 processes clean text and extracts top viewer questions  \n5. Final result is saved to DataTable\n\n\u2705 Ideal for finding content ideas or FAQ-style engagement hooks\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4997fe2b-496d-446d-8f99-0c35d1b65b29",
  "connections": {
    "Loop Through Videos": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Comments for Each Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Keyword Input": {
      "main": [
        [
          {
            "node": "Search TikTok Users (Dumpling AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Through TikTok Users": {
      "main": [
        [
          {
            "node": "Split Videos from Profile",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait to Respect Rate Limits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Videos from Profile": {
      "main": [
        [
          {
            "node": "Loop Through Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Comments for Each Video": {
      "main": [
        [
          {
            "node": "Extract Clean Comments (Python)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit to 3 Users (Optional)": {
      "main": [
        [
          {
            "node": "Loop Through TikTok Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait to Respect Rate Limits": {
      "main": [
        [
          {
            "node": "Get TikTok Profile Videos (Dumpling AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Result into DataTable": {
      "main": [
        [
          {
            "node": "Loop Through Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Clean Comments (Python)": {
      "main": [
        [
          {
            "node": "Find Top Viewer Questions (GPT-4)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Search Results into Users": {
      "main": [
        [
          {
            "node": "Limit to 3 Users (Optional)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Top Viewer Questions (GPT-4)": {
      "main": [
        [
          {
            "node": "Insert Result into DataTable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search TikTok Users (Dumpling AI)": {
      "main": [
        [
          {
            "node": "Split Search Results into Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get TikTok Profile Videos (Dumpling AI)": {
      "main": [
        [
          {
            "node": "Loop Through TikTok Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}