{
  "name": "07 - Manual Touchpoint Intake",
  "nodes": [
    {
      "id": "a7000000-0000-0000-0000-0000000000n1",
      "name": "Overview Note RU",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -460,
        -260
      ],
      "parameters": {
        "content": "## 07 \u2014 \u0420\u0443\u0447\u043d\u043e\u0439 \u043f\u0440\u0438\u0451\u043c \u0442\u043e\u0447\u0435\u043a \u043a\u0430\u0441\u0430\u043d\u0438\u044f (Manual Touchpoint Intake) \u2014 Stage 3.1\n\n\u041d\u0415 \u043f\u0430\u0440\u0441\u0435\u0440 \u0438 \u041d\u0415 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u042d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043f\u0440\u0438\u0451\u043c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.\n\n\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442:\n1. \u0420\u0443\u0447\u043d\u043e\u0439 \u0441\u0442\u0430\u0440\u0442.\n2. \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 agent_requests (request_type=manual_intake).\n3. \u0411\u0435\u0440\u0451\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 12 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 (Avito, Dzen, VK, Telegram, \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b/\u043e\u0442\u0437\u044b\u0432\u044b, \u0444\u043e\u0440\u0443\u043c, \u043d\u0435\u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0435 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b).\n4. \u0414\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u0442: record_id, dedup_key, text_hash, region_hint, urgency_hint, lead_intent_hint, confidence_score, lead_temperature, next_action. \u0411\u0415\u0417 LLM.\n5. \u0427\u0438\u0442\u0430\u0435\u0442 market_record_registry \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0434\u0435\u0434\u0443\u043f \u043f\u043e dedup_key (\u0432 \u0440\u0435\u0435\u0441\u0442\u0440\u0435 / \u0432 \u0431\u0430\u0442\u0447\u0435 / \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e).\n6. \u041f\u0438\u0448\u0435\u0442 \u0412\u0421\u0415 12 \u0441\u0442\u0440\u043e\u043a \u0432 raw_market_records (40 \u043a\u043e\u043b\u043e\u043d\u043e\u043a) \u2014 \u044d\u0442\u043e \u0430\u0443\u0434\u0438\u0442-\u0441\u043b\u0435\u0434 \u043f\u0440\u0438\u0451\u043c\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u044b \u0438 \u043d\u0435\u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b\u0435.\n7. \u041f\u0438\u0448\u0435\u0442 \u0422\u041e\u041b\u042c\u041a\u041e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 market_record_registry (15 \u043a\u043e\u043b\u043e\u043d\u043e\u043a).\n8. \u041f\u0438\u0448\u0435\u0442 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 agent_requests (21 \u043a\u043e\u043b\u043e\u043d\u043a\u0430), status=needs_review.\n9. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0432\u043e\u0434\u043a\u0443 \u043f\u0440\u043e\u0433\u043e\u043d\u0430.\n\n\u0427\u0415\u0413\u041e \u041d\u0415 \u0414\u0415\u041b\u0410\u0415\u0422:\n- \u041d\u0415 \u0441\u043a\u0440\u0435\u0439\u043f\u0438\u0442, \u041d\u0415 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Apify/Firecrawl/Claude, \u041d\u0415 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 API.\n- \u041d\u0415 \u043f\u0438\u0448\u0435\u0442 agent_memory.\n- \u041d\u0415 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 LLM (\u044d\u0442\u043e Stage 3.2 \u2014 Touchpoint Analyzer).\n- \u041d\u0415 Telegram-\u0431\u043e\u0442, \u041d\u0415 \u043f\u0430\u0440\u0441\u0435\u0440, \u041d\u0415 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435, active=false.",
        "height": 640,
        "width": 600,
        "color": 4
      }
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000n2",
      "name": "Setup and Test Note RU",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        180,
        -260
      ],
      "parameters": {
        "content": "## \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438 \u0442\u0435\u0441\u0442 (\u0432\u0440\u0443\u0447\u043d\u0443\u044e)\n\n1. \u041d\u0415 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c workflow (active=false).\n2. \u0412\u043a\u043b\u0430\u0434\u043a\u0438 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c:\n   - agent_requests (21 \u043a\u043e\u043b\u043e\u043d\u043a\u0430)\n   - raw_market_records (40 \u043a\u043e\u043b\u043e\u043d\u043e\u043a)\n   - market_record_registry (15 \u043a\u043e\u043b\u043e\u043d\u043e\u043a)\n   - agent_memory (13 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u2014 \u0437\u0434\u0435\u0441\u044c \u041d\u0415 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f)\n   Stage 2 \u0432\u043a\u043b\u0430\u0434\u043a\u0438 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044e\u0442\u0441\u044f.\n3. \u041f\u041e\u0421\u041b\u0415 \u0418\u041c\u041f\u041e\u0420\u0422\u0410 \u043f\u0435\u0440\u0435\u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u043a\u0440\u0435\u0434\u0435\u043d\u0448\u043b (ID \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b) \u043d\u0430 \u0442\u0440\u0451\u0445 Google Sheets \u043d\u043e\u0434\u0430\u0445:\n   Read market_record_registry, Append raw_market_records, Append market_record_registry, Append agent_requests\n   \u2192 Google Sheets - Marketing Scout Service Account.\n4. \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c PASTE_SPREADSHEET_ID_HERE \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 Spreadsheet ID \u043d\u0430 \u0432\u0441\u0435\u0445 Google Sheets \u043d\u043e\u0434\u0430\u0445.\n5. \u0412\u043d\u0435\u0448\u043d\u0438\u0445 API-\u043a\u043b\u044e\u0447\u0435\u0439 \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 (\u043d\u0435\u0442 Apify/Firecrawl/Claude).\n\n\u041f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442 (\u043f\u0443\u0441\u0442\u043e\u0439 \u0440\u0435\u0435\u0441\u0442\u0440):\n1. Execute Workflow \u043e\u0434\u0438\u043d \u0440\u0430\u0437.\n2. \u041e\u0436\u0438\u0434\u0430\u0435\u043c\u043e: 12 \u0441\u0442\u0440\u043e\u043a \u0432 raw_market_records; \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 ~12 \u0432 market_record_registry; 1 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 agent_requests (status=needs_review).\n3. Final Summary Output: total_records=12, unique_count, duplicate_count, irrelevant_count=2, platform_counts, record_type_counts.\n\n\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u043e\u043d (\u0440\u0435\u0435\u0441\u0442\u0440 \u0443\u0436\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d):\n- \u0422\u0435 \u0436\u0435 12 \u2192 \u0432\u0441\u0435 dedup_status=duplicate_in_registry, approval_status=duplicate; raw_market_records \u0441\u043d\u043e\u0432\u0430 +12 (\u0430\u0443\u0434\u0438\u0442), \u0440\u0435\u0435\u0441\u0442\u0440 +0.\n\n\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c: 0 (\u043d\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043d\u0435\u0442 LLM). estimated_analysis_cost_usd \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u0430\u043d.",
        "height": 640,
        "width": 600,
        "color": 4
      }
    },
    {
      "id": "a7000000-0000-0000-0000-000000000002",
      "name": "Manual Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        120,
        420
      ],
      "parameters": {}
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000rq",
      "name": "Set Manual Intake Request",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        320,
        420
      ],
      "parameters": {
        "jsCode": "// One manual-intake request. Deterministic id; no external calls.\nfunction pad(n){return String(n).padStart(2,'0');}\nfunction moscowIsoNow(){var m=new Date(Date.now()+10800000);return m.toISOString().replace('Z','+03:00');}\nfunction moscowStamp(){var z=function(n){return String(n).padStart(2,'0');};var m=new Date(Date.now()+10800000);return m.getUTCFullYear()+z(m.getUTCMonth()+1)+z(m.getUTCDate())+'_'+z(m.getUTCHours())+z(m.getUTCMinutes())+z(m.getUTCSeconds());}\nconst now=moscowIsoNow();\nconst stamp=moscowStamp();\nreturn [{ json: {\n  agent_request_id:'agentreq_'+stamp,\n  created_at:now,\n  requested_by:'operator',\n  request_text:'\u0440\u0443\u0447\u043d\u043e\u0439 \u0442\u0435\u0441\u0442 \u0442\u043e\u0447\u0435\u043a \u043a\u0430\u0441\u0430\u043d\u0438\u044f: \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0435 \u0431\u0440\u043e\u043a\u0435\u0440\u044b, \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0434\u0435\u043d\u044c\u0433\u0438, \u041c\u043e\u0441\u043a\u0432\u0430',\n  request_type:'manual_intake',\n  source_scope:'manual_mixed_sources',\n  platforms:'avito,dzen,vk,telegram,forum,reviews,web',\n  query:'\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u041c\u043e\u0441\u043a\u0432\u0430; \u0431\u044b\u0441\u0442\u0440\u044b\u0435 \u0434\u0435\u043d\u044c\u0433\u0438; \u0437\u0430\u0439\u043c \u043f\u043e\u0434 \u041f\u0422\u0421; \u0431\u0440\u043e\u043a\u0435\u0440\u044b',\n  region:'\u041c\u043e\u0441\u043a\u0432\u0430',\n  service_focus:'secured_lending',\n  requested_limit:12\n}}];"
      }
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000rg",
      "name": "Read market_record_registry",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        540,
        420
      ],
      "alwaysOutputData": true,
      "onError": "continueRegularOutput",
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "PASTE_SPREADSHEET_ID_HERE",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "market_record_registry",
          "mode": "name"
        },
        "options": {}
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000mr",
      "name": "Set Manual Records",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        760,
        420
      ],
      "parameters": {
        "jsCode": "// Fixed array of 12 manually-provided example records (operator notes). No external calls.\nconst records = [\n  { platform:'avito', source_type:'classified', source_url:'https://www.avito.ru/moskva/predlozheniya_uslug/pomosch_v_poluchenii_kredita_kreditnyy_broker_4379480780', text_context:'\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 Avito: \u00ab\u041f\u043e\u043c\u043e\u0449\u044c \u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043a\u0440\u0435\u0434\u0438\u0442\u0430 / \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440\u00bb. \u0426\u0435\u043d\u0430 \u043e\u0442 30 000 \u20bd. \u0420\u0430\u0431\u043e\u0442\u0430 \u043f\u043e \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0443, \u043f\u043e\u043c\u043e\u0449\u044c \u0444\u0438\u0437\u043b\u0438\u0446\u0430\u043c \u0438 \u0431\u0438\u0437\u043d\u0435\u0441\u0443.', record_type_hint:'competitor_activity', touchpoint_type:'competitor_listing', competitor_related:true, interest_topic:'\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u041c\u043e\u0441\u043a\u0432\u0430', service_hint:'credit_broker' },\n  { platform:'avito', source_type:'classified', source_url:'https://www.avito.ru/moskva/predlozheniya_uslug/kreditnyy_broker._realnaya_pomosch_s_kreditami_7961833832', text_context:'\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 Avito: \u00ab\u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440. \u0420\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u043c\u043e\u0449\u044c \u0441 \u043a\u0440\u0435\u0434\u0438\u0442\u0430\u043c\u0438\u00bb. \u0426\u0435\u043d\u0430 \u043e\u0442 500 \u20bd. \u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438 \u043e\u0442\u043a\u0430\u0437\u0430\u0445 \u0431\u0430\u043d\u043a\u043e\u0432.', record_type_hint:'competitor_activity', touchpoint_type:'competitor_listing', competitor_related:true, interest_topic:'\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u041c\u043e\u0441\u043a\u0432\u0430', service_hint:'credit_broker' },\n  { platform:'dzen', source_type:'social_content', source_url:'https://dzen.ru/id/62f60855a481471c44a877a4', text_context:'\u041a\u0430\u043d\u0430\u043b \u00ab\u0412\u0430\u0448 \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0411\u0440\u043e\u043a\u0435\u0440\u00bb \u043d\u0430 \u0414\u0437\u0435\u043d: \u0432\u0441\u0451 \u043e \u043a\u0440\u0435\u0434\u0438\u0442\u0430\u0445 \u0438 \u0438\u043f\u043e\u0442\u0435\u043a\u0435, \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u0435\u0439\u0441\u043e\u0432, \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438. \u0410\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b.', record_type_hint:'competitor_activity', touchpoint_type:'competitor_content_channel', competitor_related:true, interest_topic:'\u043a\u0440\u0435\u0434\u0438\u0442\u044b \u0438\u043f\u043e\u0442\u0435\u043a\u0430 \u0431\u0440\u043e\u043a\u0435\u0440', service_hint:'credit_broker' },\n  { platform:'dzen', source_type:'social_content', source_url:'https://dzen.ru/a/agwcFsrUsS23bWfb', text_context:'\u0421\u0442\u0430\u0442\u044c\u044f \u00ab\u041c\u0447\u0438\u043c \u043d\u0430 \u0441\u0434\u0435\u043b\u043a\u0443 \u0432 \u0421\u0430\u043c\u0430\u0440\u0443\u00bb \u043e\u0442 \u00ab\u041a\u0440\u0435\u0434\u0438\u0442 \u0438 \u041f\u043e\u0440\u044f\u0434\u043e\u043a\u00bb: \u043a\u0435\u0439\u0441 \u0432\u044b\u0435\u0437\u0434\u0430 \u043d\u0430 \u0441\u0434\u0435\u043b\u043a\u0443. \u0415\u0441\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432.', record_type_hint:'competitor_activity', touchpoint_type:'competitor_content_post', competitor_related:true, interest_topic:'\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u043a\u0435\u0439\u0441 \u0441\u0434\u0435\u043b\u043a\u0430', service_hint:'credit_broker' },\n  { platform:'vk', source_type:'social_search', source_url:'https://vk.com/search?c[q]=\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439+\u0431\u0440\u043e\u043a\u0435\u0440+\u041c\u043e\u0441\u043a\u0432\u0430&c[section]=auto', text_context:'\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u0430\u044f \u0432\u044b\u0434\u0430\u0447\u0430 VK \u043f\u043e \u0442\u0435\u043c\u0435 \u00ab\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u041c\u043e\u0441\u043a\u0432\u0430\u00bb. \u0422\u0440\u0435\u0431\u0443\u0435\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430/\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432.', record_type_hint:'market_signal', touchpoint_type:'source_candidate', competitor_related:false, interest_topic:'\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u041c\u043e\u0441\u043a\u0432\u0430', service_hint:'credit_broker' },\n  { platform:'yandex_maps', source_type:'review_platform', source_url:'https://yandex.ru/maps/org/vash_kreditny_broker/58664902214/reviews/', text_context:'\u041e\u0442\u0437\u044b\u0432\u044b \u043d\u0430 \u00ab\u0412\u0430\u0448 \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0411\u0440\u043e\u043a\u0435\u0440\u00bb \u0432 \u042f\u043d\u0434\u0435\u043a\u0441.\u041a\u0430\u0440\u0442\u0430\u0445. \u0420\u0435\u0439\u0442\u0438\u043d\u0433 5.0, 66 \u043e\u0442\u0437\u044b\u0432\u043e\u0432. \u041c\u043e\u0441\u043a\u0432\u0430, \u0443\u043b. \u0417\u043e\u043b\u043e\u0442\u043e\u0440\u043e\u0436\u0441\u043a\u0438\u0439 \u0412\u0430\u043b, 11. \u0410\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044f \u0441 \u043e\u0442\u0437\u044b\u0432\u0430\u043c\u0438.', record_type_hint:'market_signal', touchpoint_type:'review_source', competitor_related:true, competitor_name:'\u0412\u0430\u0448 \u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0411\u0440\u043e\u043a\u0435\u0440', interest_topic:'\u043e\u0442\u0437\u044b\u0432\u044b \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440', service_hint:'credit_broker' },\n  { platform:'telegram', source_type:'social_channel', source_url:'https://t.me/creditbrokers', profile_url:'https://t.me/creditbrokers', profile_name:'\u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0411\u0440\u043e\u043a\u0435\u0440 \u0440\u0444', author_handle:'@creditbrokers', text_context:'\u041f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 Telegram-\u0447\u0430\u0442/\u043a\u0430\u043d\u0430\u043b \u00ab\u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0411\u0440\u043e\u043a\u0435\u0440 \u0440\u0444\u00bb: \u0431\u0430\u043d\u043a\u0438, \u0438\u043d\u0432\u0435\u0441\u0442\u043e\u0440\u044b, \u0431\u0440\u043e\u043a\u0435\u0440\u044b/\u043f\u0430\u0440\u0442\u043d\u0451\u0440\u044b, \u0440\u0438\u0435\u043b\u0442\u043e\u0440\u044b. \u0410\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e.', record_type_hint:'market_signal', touchpoint_type:'source_candidate', competitor_related:false, interest_topic:'\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0435 \u0431\u0440\u043e\u043a\u0435\u0440\u044b \u0431\u0430\u043d\u043a\u0438 \u0438\u043d\u0432\u0435\u0441\u0442\u043e\u0440\u044b', service_hint:'credit_broker' },\n  { platform:'telegram', source_type:'social_channel', source_url:'https://t.me/fintrack_cbr', profile_url:'https://t.me/fintrack_cbr', profile_name:'\u0424\u0438\u043d\u0442\u0440\u0435\u043a \u0426\u0411 \u0420\u0424', author_handle:'@fintrack_cbr', text_context:'Telegram-\u043a\u0430\u043d\u0430\u043b \u0411\u0430\u043d\u043a\u0430 \u0420\u043e\u0441\u0441\u0438\u0438 \u043e \u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0438\u043d\u0430\u043d\u0441\u0430\u0445. \u0410\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044f \u0437\u0430\u0434\u0430\u0451\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043e \u043a\u0440\u0435\u0434\u0438\u0442\u0430\u0445; \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.', record_type_hint:'market_signal', touchpoint_type:'source_candidate', competitor_related:false, interest_topic:'\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0438\u043d\u0430\u043d\u0441\u044b \u043a\u0440\u0435\u0434\u0438\u0442\u044b', service_hint:'consumer_credit' },\n  { platform:'web', source_type:'website', source_url:'https://www.zen.com', text_context:'ZEN.COM \u2014 \u0435\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u043a\u043e\u0435 \u0444\u0438\u043d\u0442\u0435\u0445-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0435 \u042f\u043d\u0434\u0435\u043a\u0441.\u0414\u0437\u0435\u043d \u0438 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u043e\u043c\u0443 \u0431\u0440\u043e\u043a\u0435\u0440\u0441\u0442\u0432\u0443 \u0432 \u0420\u043e\u0441\u0441\u0438\u0438.', record_type_hint:'irrelevant', touchpoint_type:'irrelevant_source', competitor_related:false, interest_topic:'irrelevant', service_hint:'unknown' },\n  { platform:'dzen', source_type:'social_content', source_url:'https://dzen.ru/b/agcCqW1Xn1cVb1Nh', text_context:'\u0421\u0442\u0430\u0442\u044c\u044f \u00ab\u041c\u0438\u043a\u0440\u043e\u0431\u0438\u0437\u043d\u0435\u0441: \u0434\u043e 15% \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u043f\u0435\u0440\u0435\u0436\u0438\u0442\u044c 2026 \u0433\u043e\u0434\u00bb. \u0423\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043a\u0440\u0435\u0434\u0438\u0442\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u043a\u043e\u043b\u044c\u0437\u044c, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0443\u0441\u043b\u0443\u0433\u0443 \u0431\u0440\u043e\u043a\u0435\u0440\u0430.', record_type_hint:'irrelevant', touchpoint_type:'weak_market_noise', competitor_related:false, interest_topic:'\u043c\u0438\u043a\u0440\u043e\u0431\u0438\u0437\u043d\u0435\u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u044b', service_hint:'unknown' },\n  { platform:'banki_forum', source_type:'forum', source_url:'https://www.banki.ru/forum/?PAGE_NAME=read&FID=36&TID=252009', text_context:'\u0424\u043e\u0440\u0443\u043c Banki.ru, \u0432\u0435\u0442\u043a\u0430 \u00ab\u041a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u2014 \u0432\u0440\u0430\u0433 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433?\u00bb. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442, \u043a\u0430\u043a \u043d\u0430\u0439\u0442\u0438 \u0447\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0431\u0440\u043e\u043a\u0435\u0440\u0430, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442 \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e, \u043f\u0440\u043e\u0441\u044f\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0431\u0430\u043d\u043a\u0430. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0433\u043e\u0440\u044f\u0447\u0438\u0439 \u043b\u0438\u0434-\u043f\u0430\u0442\u0442\u0435\u0440\u043d: \u00ab\u041e\u0442\u043a\u0430\u0437\u0430\u043b\u0438 \u0432 3 \u0431\u0430\u043d\u043a\u0430\u0445, \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u043a\u0438, \u043d\u0443\u0436\u0435\u043d \u043a\u0440\u0435\u0434\u0438\u0442 700 \u0442\u044b\u0441. \u2014 \u043a\u0443\u0434\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f?\u00bb', record_type_hint:'question_objection', touchpoint_type:'forum_discussion', competitor_related:false, interest_topic:'\u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0439 \u0431\u0440\u043e\u043a\u0435\u0440 \u043e\u0442\u043a\u0430\u0437 \u0431\u0430\u043d\u043a\u0430 \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u043a\u0438', probable_need:'\u043d\u0443\u0436\u0435\u043d \u043a\u0440\u0435\u0434\u0438\u0442 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043a\u0430\u0437\u043e\u0432 \u0431\u0430\u043d\u043a\u043e\u0432', service_hint:'credit_broker' },\n  { platform:'zoon', source_type:'review_platform', source_url:'https://zoon.ru/msk/p-other-kreditnye_brokery/', text_context:'Zoon.ru, \u043e\u0442\u0437\u044b\u0432\u044b \u043f\u043e \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u043c \u0431\u0440\u043e\u043a\u0435\u0440\u0430\u043c \u041c\u043e\u0441\u043a\u0432\u044b. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u043e\u0442\u0437\u044b\u0432\u044b: \u00ab\u041e\u0434\u043e\u0431\u0440\u0438\u043b\u0438 \u043a\u0440\u0435\u0434\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u043e, \u0431\u0435\u0437 \u043f\u043e\u0440\u0443\u0447\u0438\u0442\u0435\u043b\u0435\u0439 \u0438 \u043a\u0443\u0447\u0438 \u0441\u043f\u0440\u0430\u0432\u043e\u043a. \u041a\u043e\u043c\u0438\u0441\u0441\u0438\u044e \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u043b \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0435\u043d\u0435\u0433\u00bb. \u0413\u043e\u0440\u044f\u0447\u0438\u0439 \u0440\u044b\u043d\u043e\u0447\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d: \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u0449\u0435\u0442 \u0431\u0440\u043e\u043a\u0435\u0440\u0430, \u0433\u043e\u0442\u043e\u0432 \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0437\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.', record_type_hint:'market_signal', touchpoint_type:'review_source', competitor_related:true, interest_topic:'\u043e\u0442\u0437\u044b\u0432\u044b \u043a\u0440\u0435\u0434\u0438\u0442\u043d\u044b\u0435 \u0431\u0440\u043e\u043a\u0435\u0440\u044b \u041c\u043e\u0441\u043a\u0432\u0430', probable_need:'\u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0432 \u0431\u0440\u043e\u043a\u0435\u0440\u0435 \u0441 \u043e\u043f\u043b\u0430\u0442\u043e\u0439 \u0437\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442', service_hint:'credit_broker' }\n];\nreturn records.map((r,i)=>({ json: Object.assign({ _index: i+1 }, r) }));"
      }
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000nm",
      "name": "Normalize Manual Records",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        980,
        420
      ],
      "parameters": {
        "jsCode": "// Deterministic normalization only. No LLM, no external calls.\nfunction pad(n){return String(n).padStart(2,'0');}\nfunction moscowIsoNow(){var m=new Date(Date.now()+10800000);return m.toISOString().replace('Z','+03:00');}\nfunction moscowStamp(){var z=function(n){return String(n).padStart(2,'0');};var m=new Date(Date.now()+10800000);return m.getUTCFullYear()+z(m.getUTCMonth()+1)+z(m.getUTCDate())+'_'+z(m.getUTCHours())+z(m.getUTCMinutes())+z(m.getUTCSeconds());}\nconst now=moscowIsoNow();\nconst stamp=moscowStamp();\nconst req=$('Set Manual Intake Request').first().json;\nconst reqId=req.agent_request_id;\nconst reqQuery=req.query||'';\nfunction str(v){return v==null?'':String(v).trim();}\nfunction low(v){return str(v).toLowerCase();}\nfunction any(b,arr){for(const w of arr){if(b.indexOf(w)>=0)return true;}return false;}\nfunction normUrl(u){u=str(u);if(!u)return '';try{const x=new URL(u.split('#')[0]);x.hostname=(x.hostname||'').toLowerCase();let p=x.pathname||'/';if(p.length>1&&p.endsWith('/'))p=p.slice(0,-1);x.pathname=p;return x.toString();}catch(e){return u.toLowerCase();}}\nfunction hashText(s){s=str(s);let h=5381;for(let i=0;i<s.length;i++){h=((h<<5)+h+s.charCodeAt(i))>>>0;}return ('00000000'+h.toString(16)).slice(-8);}\nconst recs=$('Set Manual Records').all().map(i=>i.json);\nconst out=[];let idx=0;\nfor(const r of recs){\n  idx++;\n  const platform=low(r.platform);\n  const source_type=low(r.source_type);\n  const source_url=normUrl(r.source_url);\n  const post_url=normUrl(r.post_url);\n  const profile_url=normUrl(r.profile_url);\n  const text_context=str(r.text_context);\n  const comment_text=str(r.comment_text);\n  const rth=low(r.record_type_hint)||'unknown';\n  const tpt=low(r.touchpoint_type)||'';\n  const blob=(text_context+' '+comment_text+' '+str(r.interest_topic)+' '+str(r.probable_need)).toLowerCase();\n  const text_hash=hashText(text_context+'||'+comment_text);\n  let dedup_key;\n  if(post_url){dedup_key=platform+'::post::'+post_url;}\n  else if(source_url){dedup_key=platform+'::source::'+source_url;}\n  else if(profile_url&&text_hash){dedup_key=platform+'::profile_text::'+profile_url+'::'+text_hash;}\n  else{dedup_key=platform+'::text::'+text_hash;}\n  let region_hint='';\n  if(any(blob,['\u043c\u043e\u0441\u043a\u0432\u0430','\u043c\u0441\u043a','moscow','\u043f\u043e\u0434\u043c\u043e\u0441\u043a\u043e\u0432\u044c\u0435']))region_hint='\u041c\u043e\u0441\u043a\u0432\u0430/\u041c\u041e';\n  let urgency_hint='low';\n  if(any(blob,['\u0441\u0440\u043e\u0447\u043d\u043e','\u0441\u0435\u0433\u043e\u0434\u043d\u044f','\u043e\u0442\u043a\u0430\u0437\u0430\u043b','\u043f\u0440\u043e\u0441\u0440\u043e\u0447\u043a','\u043d\u0443\u0436\u043d\u044b \u0434\u0435\u043d\u044c\u0433\u0438']))urgency_hint='high';\n  else if(any(blob,['\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0441\u044f','\u0438\u0449\u0435\u0442','\u0432\u043e\u043f\u0440\u043e\u0441','\u043a\u0443\u0434\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f']))urgency_hint='medium';\n  let lead_intent_hint;\n  if(rth==='competitor_activity'||rth==='irrelevant'||tpt==='source_candidate'||tpt==='irrelevant_source'||tpt==='weak_market_noise')lead_intent_hint='low';\n  else if(rth==='question_objection'||tpt==='forum_discussion'||tpt==='review_source'||rth==='market_signal')lead_intent_hint='medium';\n  else lead_intent_hint='low';\n  if(urgency_hint==='high'&&any(blob,['\u043d\u0443\u0436\u0435\u043d \u043a\u0440\u0435\u0434\u0438\u0442','\u043d\u0443\u0436\u043d\u044b \u0434\u0435\u043d\u044c\u0433\u0438','\u043e\u0442\u043a\u0430\u0437\u0430\u043b','\u043f\u0440\u043e\u0441\u0440\u043e\u0447\u043a'])&&rth!=='competitor_activity'&&rth!=='irrelevant')lead_intent_hint='high';\n  let confidence_score=1;\n  if(rth==='competitor_activity'&&source_url)confidence_score=80;\n  else if(rth==='question_objection'||rth==='market_signal')confidence_score=70;\n  if(tpt==='source_candidate')confidence_score=40;\n  if(rth==='irrelevant')confidence_score=1;\n  let lead_temperature='none';\n  if(rth==='competitor_activity'||rth==='irrelevant')lead_temperature='none';\n  else if(tpt==='source_candidate')lead_temperature='cold';\n  else if(rth==='question_objection'||tpt==='forum_discussion'||(tpt==='review_source'&&str(r.probable_need)))lead_temperature='warm';\n  else if(rth==='market_signal')lead_temperature='warm';\n  if(lead_intent_hint==='high'&&urgency_hint==='high')lead_temperature='hot';\n  let next_action='investigate';\n  if(rth==='irrelevant')next_action='ignore';\n  else if(rth==='competitor_activity')next_action='monitor';\n  else if(rth==='client_pain')next_action='create_content';\n  else if(rth==='question_objection')next_action='investigate';\n  else if(rth==='market_signal')next_action='investigate';\n  const estimated_analysis_cost_usd=(rth==='irrelevant')?0:0.02;\n  out.push({ json: {\n    record_id:'rec_'+stamp+'_'+idx,\n    agent_request_id:reqId,\n    created_at:now,\n    source_type:source_type,\n    platform:platform,\n    source_url:source_url,\n    post_url:post_url,\n    profile_url:profile_url,\n    profile_name:str(r.profile_name),\n    author_handle:str(r.author_handle),\n    published_at:'',\n    region_hint:region_hint,\n    service_hint:low(r.service_hint),\n    query:reqQuery,\n    text_context:text_context,\n    comment_text:comment_text,\n    contact_public:'',\n    contact_channel:'none',\n    dedup_key:dedup_key,\n    record_type_hint:rth,\n    touchpoint_type:tpt,\n    lead_intent_hint:lead_intent_hint,\n    urgency_hint:urgency_hint,\n    interest_topic:str(r.interest_topic),\n    probable_need:str(r.probable_need),\n    competitor_related:(r.competitor_related===true||low(r.competitor_related)==='true'),\n    competitor_name:str(r.competitor_name),\n    semantic_keywords:'',\n    ad_channel_hint:'',\n    confidence_score:confidence_score,\n    lead_temperature:lead_temperature,\n    next_action:next_action,\n    responsible:'',\n    dedup_status:'pending',\n    approval_status:'new',\n    approved_by:'',\n    approved_at:'',\n    estimated_analysis_cost_usd:estimated_analysis_cost_usd,\n    manager_note:'',\n    notes:'stage_3_1_manual_intake'\n  }});\n}\nreturn out;"
      }
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000dd",
      "name": "Dedup Against Registry",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1200,
        420
      ],
      "parameters": {
        "jsCode": "// Dedup against market_record_registry (by dedup_key) and within this batch. No external calls.\nfunction str(v){return v==null?'':String(v).trim();}\nconst recs=$('Normalize Manual Records').all().map(i=>i.json);\nconst __req=$('Set Manual Intake Request').first().json||{};\nlet reg=[];\ntry{reg=$('Read market_record_registry').all().map(i=>i.json).filter(Boolean);}catch(e){reg=[];}\nconst regSet=new Set(reg.map(r=>str(r&&r.dedup_key)).filter(Boolean));\nconst seen=new Set();\nconst out=[];\nfor(const r of recs){\n  const key=str(r.dedup_key);\n  let dedup_status='unique';\n  let approval_status=r.approval_status||'new';\n  if(key&&regSet.has(key)){dedup_status='duplicate_in_registry';approval_status='duplicate';}\n  else if(key&&seen.has(key)){dedup_status='duplicate_in_batch';approval_status='duplicate';}\n  else{dedup_status='unique';if(key)seen.add(key);}\n  const __irr=(str(r.record_type_hint)==='irrelevant');\n  out.push({ json: Object.assign({}, r, { dedup_status:dedup_status, approval_status:approval_status,\n    source_run_id:str(__req.agent_request_id), data_mode:'manual_test',\n    quality_status:(__irr?'quarantined':'healthy'), report_eligible:(!__irr), review_status:'confirmed', quality_flags:'' }) });\n}\nreturn out;"
      }
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000ar",
      "name": "Append raw_market_records",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        1420,
        420
      ],
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "PASTE_SPREADSHEET_ID_HERE",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "raw_market_records",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000br",
      "name": "Build Registry Rows",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1640,
        280
      ],
      "parameters": {
        "jsCode": "// Build market_record_registry rows for UNIQUE records only (15 columns). No external calls.\nfunction str(v){return v==null?'':String(v).trim();}\nfunction hashText(s){s=str(s);let h=5381;for(let i=0;i<s.length;i++){h=((h<<5)+h+s.charCodeAt(i))>>>0;}return ('00000000'+h.toString(16)).slice(-8);}\nfunction moscowIsoNow(){var m=new Date(Date.now()+10800000);return m.toISOString().replace('Z','+03:00');}\nconst now=moscowIsoNow();\nconst recs=$('Dedup Against Registry').all().map(i=>i.json);\nconst out=[];\nfor(const r of recs){\n  if(str(r.dedup_status)!=='unique')continue;\n  const text_hash=hashText(str(r.text_context)+'||'+str(r.comment_text));\n  out.push({ json: {\n    dedup_key:str(r.dedup_key),\n    source_type:str(r.source_type),\n    platform:str(r.platform),\n    source_url:str(r.source_url),\n    post_url:str(r.post_url),\n    profile_url:str(r.profile_url),\n    author_handle:str(r.author_handle),\n    text_hash:text_hash,\n    first_seen_at:now,\n    last_seen_at:now,\n    last_route:'raw_market_records',\n    last_processing_status:'intake_recorded',\n    last_entity_type:str(r.record_type_hint),\n    agent_request_id:str(r.agent_request_id),\n    note:'manual_intake_stage_3_1'\n  }});\n}\nreturn out;"
      }
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000rr",
      "name": "Append market_record_registry",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        1860,
        280
      ],
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "PASTE_SPREADSHEET_ID_HERE",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "market_record_registry",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000bq",
      "name": "Build agent_requests Row",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1640,
        560
      ],
      "parameters": {
        "jsCode": "// One agent_requests row (21 columns). status=needs_review. No external calls.\nfunction str(v){return v==null?'':String(v).trim();}\nconst req=$('Set Manual Intake Request').first().json;\nconst recs=$('Dedup Against Registry').all().map(i=>i.json);\nconst total=recs.length;\nconst unique=recs.filter(r=>str(r.dedup_status)==='unique').length;\nconst duplicate=recs.filter(r=>str(r.dedup_status).indexOf('duplicate')===0).length;\nconst irrelevant=recs.filter(r=>str(r.record_type_hint)==='irrelevant').length;\nlet cost=0;for(const r of recs){cost+=Number(r.estimated_analysis_cost_usd)||0;}\ncost=Math.round(cost*1000)/1000;\nreturn [{ json: {\n  agent_request_id:req.agent_request_id,\n  created_at:req.created_at,\n  requested_by:'operator',\n  request_text:req.request_text,\n  request_type:'manual_intake',\n  source_scope:'manual_mixed_sources',\n  platforms:'avito,dzen,vk,telegram,forum,reviews,web',\n  query:req.query,\n  region:'\u041c\u043e\u0441\u043a\u0432\u0430',\n  service_focus:'secured_lending',\n  requested_limit:12,\n  status:'needs_review',\n  plan_summary:'Manual mixed-source touchpoint intake for Stage 3.1.',\n  estimated_source_cost_usd:0,\n  estimated_analysis_cost_usd:cost,\n  approval_required:false,\n  approved_by:'',\n  approved_at:'',\n  result_summary:total+' records normalized; '+unique+' unique; '+duplicate+' duplicates; '+irrelevant+' irrelevant.',\n  next_action:'Review raw_market_records, then build Touchpoint Analyzer.',\n  notes:'No scraping, no LLM, no external API.'\n}}];"
      }
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000aq",
      "name": "Append agent_requests",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        1860,
        560
      ],
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "PASTE_SPREADSHEET_ID_HERE",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "agent_requests",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "id": "a7000000-0000-0000-0000-0000000000fs",
      "name": "Final Summary Output",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2080,
        560
      ],
      "parameters": {
        "jsCode": "// Final run summary. No external calls.\nfunction str(v){return v==null?'':String(v).trim();}\nconst req=$('Set Manual Intake Request').first().json;\nconst recs=$('Dedup Against Registry').all().map(i=>i.json);\nconst total=recs.length;\nconst unique=recs.filter(r=>str(r.dedup_status)==='unique').length;\nconst duplicate=recs.filter(r=>str(r.dedup_status).indexOf('duplicate')===0).length;\nconst irrelevant=recs.filter(r=>str(r.record_type_hint)==='irrelevant').length;\n// Audit rows = every intake record stored (incl. irrelevant). Irrelevant rows are STORED audit rows,\n// NOT hard-skipped (S3-D19). Eligible-for-analysis = unique AND relevant. Estimated future Claude cost\n// (WF08) is derived ONLY from eligible-unique rows; THIS workflow performs no analysis (actual cost=0).\nconst EST_ANALYSIS_COST_PER_RECORD_USD=0.004; // claude-sonnet-4-6 rough per-record estimate (documented)\nconst eligible_unique_for_analysis=recs.filter(r=>str(r.dedup_status)==='unique'&&str(r.record_type_hint)!=='irrelevant').length;\nconst estimated_future_analysis_cost_usd=Math.round(eligible_unique_for_analysis*EST_ANALYSIS_COST_PER_RECORD_USD*10000)/10000;\nconst platform_counts={};const record_type_counts={};\nfor(const r of recs){\n  const p=str(r.platform)||'unknown';platform_counts[p]=(platform_counts[p]||0)+1;\n  const t=str(r.record_type_hint)||'unknown';record_type_counts[t]=(record_type_counts[t]||0)+1;\n}\nreturn [{ json: {\n  workflow:'07 - Manual Touchpoint Intake',\n  agent_request_id:req.agent_request_id,\n  total_records:total,\n  unique_count:unique,\n  duplicate_count:duplicate,\n  irrelevant_count:irrelevant,\n  platform_counts:platform_counts,\n  record_type_counts:record_type_counts,\n  data_mode:'manual_test',\n  audit_rows_written:total,\n  raw_market_records_written:total,\n  eligible_unique_for_analysis:eligible_unique_for_analysis,\n  irrelevant_items:irrelevant,\n  hard_skipped_items:0,\n  actual_analysis_cost_usd:0,\n  estimated_future_analysis_cost_usd:estimated_future_analysis_cost_usd,\n  cost_status:'not_applicable',\n  external_calls:0,\n  llm_calls:0,\n  registry_rows_written:unique,\n  next_action:'Review raw_market_records and market_record_registry; then design/build the Touchpoint Analyzer (Stage 3.2). No scraping, no LLM here.'\n}}];"
      }
    },
    {
      "id": "wf07-build-runlog",
      "name": "Build live_source_runs Row",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2000,
        820
      ],
      "parameters": {
        "jsCode": "function moscowIsoNow(){var m=new Date(Date.now()+10800000);return m.toISOString().replace('Z','+03:00');}\n// WF07 live_source_runs ledger (23 cols, DEC-126). Manual deterministic intake; no external calls, no LLM.\nfunction str(v){return v==null?'':String(v).trim();}\nconst req=$('Set Manual Intake Request').first().json||{};\nconst recs=$('Dedup Against Registry').all().map(i=>i.json);\nconst total=recs.length;\nconst unique=recs.filter(r=>str(r.dedup_status)==='unique').length;\nconst dup=recs.filter(r=>str(r.dedup_status).indexOf('duplicate')===0).length;\nconst irrelevant=recs.filter(r=>str(r.record_type_hint)==='irrelevant').length;\nreturn [{ json: {\n  run_id:str(req.agent_request_id)||('manual_'+Date.now()),\n  created_at:moscowIsoNow(),\n  workflow:'WF07 - Manual Touchpoint Intake',\n  source_family:'other',\n  platform:'manual',\n  mode:'deterministic',\n  approval_token_used:'no',\n  source_allowlist:'manual_mixed_sources',\n  max_items:Number(req.requested_limit)||12,\n  items_received:total,\n  items_relevant:total-irrelevant,\n  items_written_raw:total,\n  items_unique:unique,\n  items_duplicate:dup,\n  data_mode:'manual_test',\n  irrelevant_items:irrelevant,\n  hard_skipped:0,\n  external_calls:0,\n  estimated_source_cost_usd:0,\n  llm_calls:0,\n  estimated_llm_cost_usd:0,\n  status:'completed',\n  error_summary:'',\n  operator_next_action:'Review raw_market_records, then run WF08.',\n  notes:'Manual intake; no scraping, no LLM, no external API.'\n}}];"
      }
    },
    {
      "id": "wf07-app-runlog",
      "name": "Append live_source_runs",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [
        2220,
        820
      ],
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "PASTE_SPREADSHEET_ID_HERE",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "live_source_runs",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    }
  ],
  "connections": {
    "Manual Start": {
      "main": [
        [
          {
            "node": "Set Manual Intake Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Manual Intake Request": {
      "main": [
        [
          {
            "node": "Read market_record_registry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read market_record_registry": {
      "main": [
        [
          {
            "node": "Set Manual Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Manual Records": {
      "main": [
        [
          {
            "node": "Normalize Manual Records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Manual Records": {
      "main": [
        [
          {
            "node": "Dedup Against Registry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dedup Against Registry": {
      "main": [
        [
          {
            "node": "Append raw_market_records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append raw_market_records": {
      "main": [
        [
          {
            "node": "Build Registry Rows",
            "type": "main",
            "index": 0
          },
          {
            "node": "Build agent_requests Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Registry Rows": {
      "main": [
        [
          {
            "node": "Append market_record_registry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build agent_requests Row": {
      "main": [
        [
          {
            "node": "Append agent_requests",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append agent_requests": {
      "main": [
        [
          {
            "node": "Final Summary Output",
            "type": "main",
            "index": 0
          },
          {
            "node": "Build live_source_runs Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build live_source_runs Row": {
      "main": [
        [
          {
            "node": "Append live_source_runs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a7000000-manual-touchpoint-intake-v001-stage-3-1-20260608"
}