{
  "id": "vKjQAPaaL1cUVXtj",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Extract Marketing Insights from TikTok Videos Using Dumpling AI and GPT-4",
  "tags": [],
  "nodes": [
    {
      "id": "2f93eea5-5e9b-4f5e-88db-bbfc689fad92",
      "name": "Form: Submit TikTok URL + Product Info",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -760,
        150
      ],
      "parameters": {
        "options": {},
        "formTitle": "TikTok Scraper ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Tiktok Video URL"
            },
            {
              "fieldLabel": "Keyword "
            },
            {
              "fieldLabel": "Product "
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3fed2762-757b-4b3b-8fe1-19b04eb6d447",
      "name": "Dumpling AI: Get TikTok Transcript",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -540,
        150
      ],
      "parameters": {
        "url": "=https://app.dumplingai.com/api/v1/get-tiktok-transcript",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text",
              "outputPropertyName": "body"
            }
          }
        },
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "videoUrl",
              "value": "={{ $json['Tiktok Video URL'] }}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c713b45f-f4af-40cd-a67d-640a96903a85",
      "name": "Format: Clean VTT Captions",
      "type": "n8n-nodes-base.code",
      "position": [
        -320,
        150
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const vtt = $json.body;                // text we just downloaded\n\nif (!vtt) {\n  return { transcript: null, note: \"no TikTok captions\" };\n}\n\nconst lines = vtt\n  .split(/\\r?\\n/)\n  .filter(l => l && !l.match(/^(\\d+|WEBVTT|X-TIMESTAMP|[:\\d+.\\-> ]+$)/));\n\nreturn { transcript: lines.join(\" \") };\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5f405063-4e4c-42d3-9f0a-98c0fda55bb3",
      "name": "GPT-4: Extract Pain Points & Insights",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -20,
        -80
      ],
      "parameters": {
        "text": "=Here is a TikTok transcript. Analyze it for the following:\n\n1. Determine whether the speaker is describing a **problem**, a **solution**, or **both** regarding the keyword: \"{{ $('Form: Submit TikTok URL + Product Info').item.json['Keyword '] }}\".\n2. Extract:\n   - Pain points\n   - Desired outcomes\n   - Triggers or motivating events\n   - Interesting direct quotes or phrases\n\nTranscript: {{ $json.transcript }}\n",
        "options": {
          "systemMessage": "=You are a customer research analyst. Your job is to extract actionable marketing insights from user-generated content like TikTok transcripts.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "6d7d57a8-b44e-4b25-8af2-1b86b72c534b",
      "name": "Parse: Separate Insights (pain points, outcomes, etc)",
      "type": "n8n-nodes-base.aiTransform",
      "position": [
        400,
        -20
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst outputItems = items.map((item) => {\n  const output = item?.json?.output;\n\n  const painPointsIndex = output.indexOf(\"Pain Points\") + \"Pain Points\".length;\n  const desiredOutcomesIndex = output.indexOf(\"Desired Outcomes\");\n  const triggersIndex = output.indexOf(\"Triggers or Motivating Events\");\n  const quotesIndex = output.indexOf(\"Interesting Direct Quotes or Phrases\");\n\n  const painPoints = output.slice(painPointsIndex, desiredOutcomesIndex).trim();\n  const desiredOutcomes = output\n    .slice(desiredOutcomesIndex, triggersIndex)\n    .trim();\n  const triggers = output.slice(triggersIndex, quotesIndex).trim();\n  const quotes = output.slice(quotesIndex).trim();\n\n  return {\n    painPoints,\n    desiredOutcomes,\n    triggers,\n    quotes,\n  };\n});\n\nreturn outputItems;\n",
        "instructions": "I want to extract the output from the AI agent into own separate outputs. So extract the pain points, desired outcomes, triggers or motivating events, interesting direct quotes or phrases",
        "codeGeneratedForPrompt": "I want to extract the output from the AI agent into own separate outputs. So extract the pain points, desired outcomes, triggers or motivating events, interesting direct quotes or phrases"
      },
      "typeVersion": 1
    },
    {
      "id": "6baf0404-4ea2-42ce-927f-7a0207d04f41",
      "name": " Google Sheets: Log Insights + Post Copy",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        652,
        150
      ],
      "parameters": {
        "columns": {
          "value": {
            "Video URL": "={{ $('Form: Submit TikTok URL + Product Info').item.json['Tiktok Video URL'] }}",
            "New Script": "={{ $json.output }}",
            "Pain points": "={{ $('Parse: Separate Insights (pain points, outcomes, etc)').first().json.painPoints}}",
            "Desired outcomes": "={{ $('Parse: Separate Insights (pain points, outcomes, etc)').first().json.desiredOutcomes }}",
            "Original Transcription": "={{ $('Format: Clean VTT Captions').item.json.transcript }}",
            "Interesting direct quotes": "={{$('Parse: Separate Insights (pain points, outcomes, etc)').first().json.quotes}}",
            "Triggers or motivating events": "={{ $('Parse: Separate Insights (pain points, outcomes, etc)').first().json.triggers }}"
          },
          "schema": [
            {
              "id": "Video URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Video URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Original Transcription",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Original Transcription",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Pain points",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Pain points",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Desired outcomes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Desired outcomes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Triggers or motivating events",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Triggers or motivating events",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Interesting direct quotes",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Interesting direct quotes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "New Script",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "New Script",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Video URL"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1aXRi2vdugC2YJ4Up8vSkeDEpbTem9-t8x5m5H7Or9w8/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/17HGdr1TvWdv6aLVlElGqqz8Q6aS90IXIlJBYsW5rPtk/edit?usp=drivesdk",
          "cachedResultName": "TikTok URL"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "37d135b2-9861-4829-906f-13a0d781012f",
      "name": "GPT-4: Rewrite Transcript as Marketing Post",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        40,
        360
      ],
      "parameters": {
        "text": "=Analyze the following TikTok transcript and determine whether the speaker is primarily describing:\n\n- a **problem** related to the keyword \"{{ $('Form: Submit TikTok URL + Product Info').item.json['Keyword '] }}\".\n- a **solution** they've found, or\n- **both** a problem and a solution.\n\nThen, rewrite the transcript with the following goals:\n\n1. Frame our product or service \"{{ $('Form: Submit TikTok URL + Product Info').item.json['Product '] }}\" as the ideal solution to the problem, or a key part of the solution being described.\n2. Preserve the speaker\u2019s tone, voice, and informal/social style.\n3. Make it sound like a natural social media post or spoken monologue.\n4. Ensure it's conversational and authentic.\n\n\nTranscript: {{ $json.transcript }}\n\n\n\n\n\n\n\n",
        "options": {
          "systemMessage": "=You are a persuasive copywriter skilled at rewriting user-generated content to position a product or service as the solution to customer problems or goals, while preserving the original voice and tone.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "13fb5224-ab7e-4202-804d-0c5f186b742a",
      "name": "GPT-4: Used in Research Agent",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -72,
        220
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b6f39362-75bf-48c9-b4be-2f2250fd01b5",
      "name": "GPT-4: Used in Rewrite Agent",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -140,
        560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "dba84dc4-769f-45a6-bff9-bd11f7fb0c1b",
      "name": "\ud83e\udde0 LangChain Tools (for Agents)",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        48,
        220
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "39c7099f-c491-44d3-99bc-1fb716227b79",
      "name": "\ud83e\udde0 LangChain Tools (for Agents)1",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        280,
        600
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b1505793-aefe-421d-bb59-7a5e579cfee6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -220
      ],
      "parameters": {
        "width": 740,
        "height": 460,
        "content": "### \ud83c\udfaf Workflow Summary\n\nThis workflow takes a TikTok link and product keyword,  \nextracts the transcript, and uses GPT-4 to generate:\n\n- Key pain points  \n- Desired outcomes  \n- Motivating events  \n- Direct quotes  \n- A rewritten post for marketing\n\nAll results are saved to Google Sheets.\n\nTools: Dumpling AI, GPT-4, LangChain, Google Sheets\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8b9e4413-072a-40a1-9ec3-f079f3a38b80",
  "connections": {
    "Format: Clean VTT Captions": {
      "main": [
        [
          {
            "node": "GPT-4: Extract Pain Points & Insights",
            "type": "main",
            "index": 0
          },
          {
            "node": "GPT-4: Rewrite Transcript as Marketing Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4: Used in Rewrite Agent": {
      "ai_languageModel": [
        [
          {
            "node": "GPT-4: Rewrite Transcript as Marketing Post",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4: Used in Research Agent": {
      "ai_languageModel": [
        [
          {
            "node": "GPT-4: Extract Pain Points & Insights",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "\ud83e\udde0 LangChain Tools (for Agents)": {
      "ai_tool": [
        [
          {
            "node": "GPT-4: Extract Pain Points & Insights",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Dumpling AI: Get TikTok Transcript": {
      "main": [
        [
          {
            "node": "Format: Clean VTT Captions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83e\udde0 LangChain Tools (for Agents)1": {
      "ai_tool": [
        [
          {
            "node": "GPT-4: Rewrite Transcript as Marketing Post",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4: Extract Pain Points & Insights": {
      "main": [
        [
          {
            "node": "Parse: Separate Insights (pain points, outcomes, etc)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form: Submit TikTok URL + Product Info": {
      "main": [
        [
          {
            "node": "Dumpling AI: Get TikTok Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4: Rewrite Transcript as Marketing Post": {
      "main": [
        [
          {
            "node": " Google Sheets: Log Insights + Post Copy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse: Separate Insights (pain points, outcomes, etc)": {
      "main": [
        [
          {
            "node": " Google Sheets: Log Insights + Post Copy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}