{
  "name": "My Workflow 12",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 10
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        -32,
        0
      ],
      "id": "58af921e-0cc4-4f31-8805-f8de0908ffaa",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "130SMzyTg_3dScifOPAy073aWQn1EIYIRpgYpG_jUX_k",
          "mode": "list",
          "cachedResultName": "Workflow Analisis Brand dan Kompetitor Aku",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/130SMzyTg_3dScifOPAy073aWQn1EIYIRpgYpG_jUX_k/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 948691243,
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/130SMzyTg_3dScifOPAy073aWQn1EIYIRpgYpG_jUX_k/edit#gid=948691243"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Tanggal": "={{ $('Menyiapkan Teks AI').item.json.metrics.processedAt }}",
            "NF Acadeny": "={{ $('Menyiapkan Teks AI').item.json.metrics.breakdown.nfa }}",
            "BISA AI": "={{ $('Menyiapkan Teks AI').item.json.metrics.breakdown.bisa }}",
            "Vinix 7": "={{ $('Menyiapkan Teks AI').item.json.metrics.breakdown.vinix }}",
            "Total Mention": "={{ $('Menyiapkan Teks AI').item.json.metrics.total_mentions }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Tanggal",
              "displayName": "Tanggal",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "NF Acadeny",
              "displayName": "NF Acadeny",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "BISA AI",
              "displayName": "BISA AI",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Vinix 7",
              "displayName": "Vinix 7",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Mention",
              "displayName": "Total Mention",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1344,
        0
      ],
      "id": "c94263c5-ef7c-4600-acae-4a8648347790",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://google.serper.dev/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\"q\": \"\\\"BISA AI\\\"\", \"gl\": \"id\"}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        256,
        0
      ],
      "id": "f9e1903b-d03f-40ad-8514-07e0f57bec18",
      "name": "BISA AI",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Fungsi untuk mengambil data secara aman dari node search\nconst getOrganicData = (nodeName) => {\n  try {\n    const results = $(nodeName).all();\n    // Mengambil array 'organic' dari hasil Serper API\n    return results[0].json.organic || [];\n  } catch (e) {\n    return []; // Jika node gagal, berikan array kosong agar workflow tidak stop\n  }\n};\n\nconst nfaResults = getOrganicData('NFA');\nconst bisaResults = getOrganicData('BISA AI');\nconst vinixResults = getOrganicData('Vinix7');\n\n// Gunakan DateTime.now() dari Luxon (bukan $now.format)\nconst currentTime = DateTime.now().toFormat('yyyy-MM-dd HH:mm');\n\n// Gabungkan dan berikan label brand ke setiap berita\nconst finalData = [\n  ...nfaResults.map(i => ({ json: { ...i, brand: 'NF Academy', processedAt: currentTime } })),\n  ...bisaResults.map(i => ({ json: { ...i, brand: 'BISA AI', processedAt: currentTime } })),\n  ...vinixResults.map(i => ({ json: { ...i, brand: 'Vinix 7', processedAt: currentTime } }))\n];\n\nreturn finalData;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        576,
        0
      ],
      "id": "211a271e-2996-4f84-877f-aee2ae321914",
      "name": "Gabungkan Data"
    },
    {
      "parameters": {
        "jsCode": "// Mengambil seluruh item dari node sebelumnya\nconst allItems = $input.all();\nconst total = allItems.length;\n\n// Menghitung mention per brand secara total\nconst counts = {\n  nfa: allItems.filter(i => i.json.brand === \"NF Academy\").length,\n  bisa: allItems.filter(i => i.json.brand === \"BISA AI\").length,\n  vinix: allItems.filter(i => i.json.brand === \"Vinix 7\").length\n};\n\n// Menghitung Share of Voice (SOV)\nconst sov = {\n  nfa: total > 0 ? ((counts.nfa / total) * 100).toFixed(1) : 0,\n  bisa: total > 0 ? ((counts.bisa / total) * 100).toFixed(1) : 0,\n  vinix: total > 0 ? ((counts.vinix / total) * 100).toFixed(1) : 0\n};\n\n// Menggabungkan seluruh teks berita menjadi satu blok teks untuk AI\nlet combinedText = \"\";\nallItems.forEach(item => {\n  combinedText += `[${item.json.brand}] ${item.json.title}: ${item.json.snippet}\\n\\n`;\n});\n\n// PENTING: Mengembalikan HANYA SATU objek (bukan array)\nreturn {\n  metrics: {\n    processedAt: DateTime.now().toFormat('yyyy-MM-dd HH:mm'),\n    total_mentions: total,\n    breakdown: counts,\n    share_of_voice: sov,\n    dashboard_url: \"https://docs.google.com/spreadsheets/d/19yDBpx981bYwOzIKD7oxHG80YdfDqY_ZUmVyCIYbXNU/edit\"\n  },\n  text_for_ai: combinedText\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        784,
        0
      ],
      "id": "4f217d54-0ecf-4fee-8fc2-8e58f68e8487",
      "name": "Menyiapkan Teks AI"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://google.serper.dev/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\"q\": \"\\\"Vinix 7\\\"\", \"gl\": \"id\"}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        256,
        192
      ],
      "id": "28f03c7f-aa48-4a23-b1f2-6bfce42e5de6",
      "name": "Vinix 7",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://google.serper.dev/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\"q\": \"\\\"NF Academy\\\" OR \\\"Nurul Fikri Academy\\\"\", \"gl\": \"id\"}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        256,
        -192
      ],
      "id": "b2a99079-3e19-4c5b-b6c8-18f6f0eb675e",
      "name": "NFA",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        944,
        208
      ],
      "id": "51d840da-afff-42d5-b0e0-264606336c02",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.pdfshift.io/v3/convert/pdf",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-API-Key",
              "value": "sk_c98c2cd5516345bcc469f68a539128f5c25b7e42"
            }
          ]
        },
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "source",
              "value": "={{ $json.html }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1744,
        0
      ],
      "id": "a7d829d4-5c93-41e3-a3ca-c3399d2bb6b6",
      "name": "HTTP to PDF"
    },
    {
      "parameters": {
        "html": "<!DOCTYPE html>\n<html lang=\"id\">\n<head>\n  <meta charset=\"UTF-8\" />\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>\n  <title>Laporan Strategi Bisnis & Intelijen Kompetitif</title>\n\n  <style>\n    :root {\n      --orange: #FF6B35;\n      --blue: #2E5AAC;\n      --blue-light: #4A7DCC;\n      --gray-bg: #f8f9fa;\n      --text-dark: #333;\n      --text-light: #6c757d;\n    }\n\n    * {\n      margin: 0;\n      padding: 0;\n      box-sizing: border-box;\n    }\n\n    body {\n      font-family: Arial, Helvetica, sans-serif;\n      line-height: 1.6;\n      color: var(--text-dark);\n      background: #ffffff;\n    }\n\n    .container {\n      max-width: 1000px;\n      margin: 0 auto;\n      padding: 24px;\n    }\n\n    header {\n      background: linear-gradient(135deg, var(--blue), var(--blue-light));\n      color: white;\n      padding: 48px 24px;\n      text-align: center;\n      border-radius: 0 0 14px 14px;\n    }\n\n    header h1 {\n      font-size: 28px;\n      font-weight: bold;\n      margin-bottom: 10px;\n    }\n\n    header p {\n      font-size: 15px;\n      opacity: 0.95;\n    }\n\n    .badge {\n      display: inline-block;\n      margin-top: 12px;\n      background: var(--orange);\n      padding: 6px 14px;\n      border-radius: 20px;\n      font-size: 13px;\n      font-weight: bold;\n    }\n\n    section {\n      background: #ffffff;\n      margin: 32px 0;\n      padding: 28px;\n      border-radius: 12px;\n      border: 1px solid #eee;\n    }\n\n    h2 {\n      font-size: 22px;\n      color: var(--blue);\n      margin-bottom: 18px;\n      padding-bottom: 8px;\n      border-bottom: 2px solid var(--orange);\n    }\n\n    h3 {\n      font-size: 18px;\n      color: var(--blue);\n      margin: 18px 0 10px;\n    }\n\n    p {\n      margin-bottom: 12px;\n    }\n\n    ul, ol {\n      margin-left: 22px;\n    }\n\n    li {\n      margin-bottom: 10px;\n    }\n\n    .highlight {\n      background: #fff4e6;\n      padding: 2px 6px;\n      border-radius: 4px;\n      font-weight: bold;\n      color: #d35400;\n    }\n\n    /* Table */\n    table {\n      width: 100%;\n      border-collapse: collapse;\n      margin-top: 16px;\n    }\n\n    th {\n      background: var(--blue);\n      color: white;\n      padding: 12px;\n      font-size: 14px;\n    }\n\n    td {\n      padding: 12px;\n      border-bottom: 1px solid #eee;\n      font-size: 14px;\n      vertical-align: top;\n    }\n\n    .brand-bisa { background: #fff7f1; }\n    .brand-nf { background: #f1f6ff; }\n    .brand-vinix { background: #fafafa; color: #999; }\n\n    .score-bisa { color: var(--orange); font-weight: bold; }\n    .score-nf { color: var(--blue); font-weight: bold; }\n\n    .bar {\n      height: 18px;\n      border-radius: 10px;\n      margin: 6px 0 14px;\n      background: #ddd;\n      overflow: hidden;\n    }\n\n    .bar span {\n      display: block;\n      height: 100%;\n    }\n\n    .bar-bisa span { width: 53.3%; background: var(--orange); }\n    .bar-nf span { width: 46.7%; background: var(--blue); }\n\n    footer {\n      margin-top: 40px;\n      text-align: center;\n      font-size: 13px;\n      color: var(--text-light);\n    }\n\n    @media print {\n      section { page-break-inside: avoid; }\n    }\n  </style>\n</head>\n\n<body>\n\n<header>\n  <div class=\"container\">\n    <h1>\ud83d\udcca Laporan Strategi Bisnis & Intelijen Kompetitif</h1>\n    <p>Analisis Share of Voice (SoV) & Reputasi Digital</p>\n    <div class=\"badge\">\ud83d\udcc5 07 Januari 2026</div>\n  </div>\n</header>\n\n<div class=\"container\">\n\n  <section>\n    <h2>\ud83d\udccc Ringkasan Eksekutif</h2>\n    <p>\n      Dalam percakapan digital terbatas (<strong>15 mention</strong>),\n      <span class=\"highlight\">BISA AI</span> unggul tipis dengan\n      <strong>53.3% Share of Voice</strong>, sementara\n      <strong>NF Academy</strong> berada di <strong>46.7%</strong>.\n    </p>\n\n    <p><strong>BISA AI (53.3%)</strong></p>\n    <div class=\"bar bar-bisa\"><span></span></div>\n\n    <p><strong>NF Academy (46.7%)</strong></p>\n    <div class=\"bar bar-nf\"><span></span></div>\n  </section>\n\n  <section>\n    <h2>\ud83d\udce2 Analisis Share of Voice</h2>\n\n    <h3>\ud83e\udd16 BISA AI</h3>\n    <ul>\n      <li>Fokus topikal AI & Data Science</li>\n      <li>Promosi agresif dan edukatif</li>\n      <li>Akses kursus gratis + sertifikasi</li>\n    </ul>\n\n    <h3>\ud83c\udf93 NF Academy</h3>\n    <ul>\n      <li>Konten dominan profil statis</li>\n      <li>Minim diskusi & CTA viral</li>\n    </ul>\n  </section>\n\n  <section>\n    <h2>\u2b50 Skor Reputasi</h2>\n    <table>\n      <tr>\n        <th>Brand</th>\n        <th>Skor</th>\n        <th>Kelebihan</th>\n        <th>Kelemahan</th>\n      </tr>\n      <tr class=\"brand-bisa\">\n        <td><strong>BISA AI</strong></td>\n        <td class=\"score-bisa\">8.0 / 10</td>\n        <td>Relevan, gratis, online</td>\n        <td>Branding generik</td>\n      </tr>\n      <tr class=\"brand-nf\">\n        <td><strong>NF Academy</strong></td>\n        <td class=\"score-nf\">6.5 / 10</td>\n        <td>Lokasi fisik, B2B</td>\n        <td>Konten kaku</td>\n      </tr>\n      <tr class=\"brand-vinix\">\n        <td><strong>Vinix 7</strong></td>\n        <td>0 / 10</td>\n        <td>\u2014</td>\n        <td>Tidak terdeteksi</td>\n      </tr>\n    </table>\n  </section>\n\n  <section>\n    <h2>\ud83d\udca1 Strategi Rekomendasi untuk NF Academy</h2>\n    <ol>\n      <li>Aktifkan konten sosial & instruktur</li>\n      <li>Tonjolkan keunggulan kelas tatap muka</li>\n      <li>Gunakan promosi berbasis hasil nyata</li>\n    </ol>\n  </section>\n\n  <footer>\n    <p>\u00a9 2026 \u2014 Laporan Strategi Bisnis & Intelijen Kompetitif</p>\n    <p>Data publik & analisis sosial media (Jan 2026)</p>\n  </footer>\n\n</div>\n\n</body>\n</html>"
      },
      "type": "n8n-nodes-base.html",
      "typeVersion": 1.2,
      "position": [
        1536,
        0
      ],
      "id": "535d4bb0-770f-4572-aa53-f305b4f3fdad",
      "name": "Generate HTML"
    },
    {
      "parameters": {
        "operation": "sendDocument",
        "chatId": "6155131672",
        "binaryData": true,
        "additionalFields": {
          "caption": "\ud83d\udcca Laporan Intelijen Kompetitif - 07 Januari 2026  \n\ud83d\udd39 BISA AI unggul tipis dengan SoV 53.3%   \n\ud83d\udd39 NF Academy perlu optimasi konten dinamis   \n\ud83d\udd39 Vinix 7: belum terdeteksi \u2014 masalah awareness!  \n\ud83d\udcce Lampiran: PDF lengkap analisis & rekomendasi strategis.",
          "fileName": "Laporan Kompetitor - 10 April 2026.pdf"
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1920,
        0
      ],
      "id": "a4958366-d9aa-4874-a773-4187dae1c0f5",
      "name": "Kirim PDF ke Telegram",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Lakukan analisis kompetitif berdasarkan DATA METRICS berikut:\n- Total Mentions: {{ $json.metrics.total_mentions }}\n- NF Academy: {{ $json.metrics.breakdown.nfa }} mention ({{ $json.metrics.share_of_voice.nfa }}%)\n- BISA AI: {{ $json.metrics.breakdown.bisa }} mention ({{ $json.metrics.share_of_voice.bisa }}%)\n- Vinix 7: {{ $json.metrics.breakdown.vinix }} mention ({{ $json.metrics.share_of_voice.vinix }}%)\nDan DATA MENTAH berikut:\n{{ $json.text_for_ai }}\n\nTugas Anda:\n1. Mengapa Share of Voice (SoV) NF Academy relatif {{ $json.metrics.share_of_voice.nfa > 33 ? 'TINGGI' : 'RENDAH' }} dibandingkan kompetitor? Apa yang mereka lakukan dengan benar atau salah berdasarkan sentimen di data mentah?\n2.Berikan skor reputasi online (skala 1-10) untuk masing-masing dari 3 brand tersebut berdasarkan analisis sentimen dari data mentah. Jelaskan alasan di balik setiap skor dengan mengutip contoh spesifik.",
        "messages": {
          "messageValues": [
            {
              "message": "=Anda adalah pakar Strategi Bisnis dan Analisis Intelijen Kompetitif. Tugas Anda adalah menganalisis data mention dari internet untuk membandingkan brand NF Academy (milik pengguna) dengan kompetitornya (BISA AI dan Vinix 7). Fokus pada sentimen, tren fitur, dan peluang pasar."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        1008,
        0
      ],
      "id": "1014dff4-546e-4cc1-aba8-394e12f964cc",
      "name": "Prompt untuk perbandingan"
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "NFA",
            "type": "main",
            "index": 0
          },
          {
            "node": "BISA AI",
            "type": "main",
            "index": 0
          },
          {
            "node": "Vinix 7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Generate HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "BISA AI": {
      "main": [
        [
          {
            "node": "Gabungkan Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gabungkan Data": {
      "main": [
        [
          {
            "node": "Menyiapkan Teks AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Menyiapkan Teks AI": {
      "main": [
        [
          {
            "node": "Prompt untuk perbandingan",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vinix 7": {
      "main": [
        [
          {
            "node": "Gabungkan Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NFA": {
      "main": [
        [
          {
            "node": "Gabungkan Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Prompt untuk perbandingan",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "HTTP to PDF": {
      "main": [
        [
          {
            "node": "Kirim PDF ke Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate HTML": {
      "main": [
        [
          {
            "node": "HTTP to PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt untuk perbandingan": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "75bfa83f-64b8-4e97-85ba-b9abce346c46",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "ylCgC3ocgpTowdve",
  "tags": []
}