{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "f68ac8bd-6f7e-42e6-bd43-7db019d5a881",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -880,
        -1296
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 12,
              "triggerAtMinute": 2
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "534fe3e2-dfc0-48d8-a5c9-3f3164cb7270",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        -1632
      ],
      "parameters": {
        "color": 3,
        "width": 2320,
        "height": 880,
        "content": "# Data Engineering Team\n- Lead Generation\n- populate database\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a44e9983-a4e2-4806-af49-5098f6cb4586",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1392,
        -1104
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 320,
        "content": "# Notes:\n1. I used afew sources in case you want to do a PLUG-N-PLAY\n2. Do not use HTTP UNLESS NECESSARY cos Want to be fully Agentic and not Automation\n\n(Final Notes:#underline and bold) I designed and implemeted this whole pipeline from scratch in 3 days. If i can, so can you :] Go programmers! \u2764\ufe0f\u2764\ufe0f"
      },
      "typeVersion": 1
    },
    {
      "id": "a0b46f18-37aa-45f7-bf7f-3ecf17bcc9f7",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        -288,
        -544
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Eligib2Mail",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b9c1ac3b-bac5-4eee-b1c6-d16c56b52e96",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.send_email }}",
                    "rightValue": "TRUE"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "InEligib2Mail",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "49b30f98-40c9-40e5-af9c-cc47d241ee60",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    },
                    "leftValue": "={{ $json.output.send_email }}",
                    "rightValue": "TRUE"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "698eb711-ac8a-47de-9ebf-426af56f3e75",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -576,
        -352
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"send_email\": \"TRUE\",\n  \"selected_email\": \"user@example.com\",\n  \"reason\": \"Email submissions enabled and lead is eligible.\"\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7035b218-985a-46a8-afab-58813c4cf54e",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -768,
        -352
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "82acc6db-4e4e-4f66-b34d-23b7f83e651f",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -672,
        -304
      ],
      "parameters": {
        "sessionKey": "={{ $json['Primary Information Source'] }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "18482439-cf53-453e-80c6-b096d8fc9d61",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -720
      ],
      "parameters": {
        "color": 5,
        "width": 928,
        "height": 528,
        "content": "## Data Analysis Team"
      },
      "typeVersion": 1
    },
    {
      "id": "f960e445-fb12-443d-b045-53f06ee14fde",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -720,
        224
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "5fdaa1f9-1f0e-4680-b9d1-750f306ef353",
      "name": "SalesAgentPrompt",
      "type": "n8n-nodes-base.code",
      "position": [
        -896,
        48
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nreturn items.map(item => ({\n\n  json: {\n    ...item.json,\n    chatInput: `You are drafting ONLY a short personalized opener for a literary agent outreach email.\n\nAgent research (use ONLY this info):\n- Agent name: ${item.json.agent_name || item.json[\"Literary Agent Name\"]}\n- Agent email: ${item.json.agent_email || item.json[\"Agent Email to Email\"]}\n- Agency: ${item.json.agency || \"UNKNOWN\"}\n- Professional background: ${item.json.professional_background || \"UNKNOWN\"}\n- Genres represented: ${item.json.genres_represented_flat || item.json.genres_represented_csv || (Array.isArray(item.json.genres_represented) ? item.json.genres_represented.join(\", \") : (item.json.genres_represented || \"UNKNOWN\"))}\n- Personalization angles: ${item.json.personalization_angles_flat || item.json.personalization_angles_csv || (Array.isArray(item.json.personalization_angles) ? item.json.personalization_angles.join(\" | \") : (item.json.personalization_angles || \"UNKNOWN\"))}\n\nBook context:\n- Title: Suffering Digs The Well\n- Nonfiction about meaning-making through suffering (life, death, love), existential + modern psychology, compassionate tone.\n\nRules:\n- Do NOT mention private life, trauma, health, or family unless explicitly in the research above.\n- Write 2\u20133 sentences max.\n- Must be professional, specific, and relevant to this agent.\n- personalized_opener_html must be exactly ONE paragraph tag: <p>...</p> (no outer <div>, no headings).\n\nSubject rule:\n- 6\u201310 words, professional, non-hype.\n- Include either the title OR a theme (meaning/suffering/resilience).\n\nOUTPUT (STRICT):\nReturn ONLY valid JSON matching exactly this schema (no markdown, no extra keys):\n{\"to_email\":\"string\",\"agent_name\":\"string\",\"subject\":\"string\",\"personalized_opener_html\":\"string\"}\n\n`\n  }\n})); \n"
      },
      "typeVersion": 2
    },
    {
      "id": "51954a1c-427d-417a-9750-add0bcf5cd5b",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -288,
        48
      ],
      "parameters": {
        "sendTo": "=mex3woof@gmail.com",
        "message": "=<div style=\"font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #111; line-height: 1.6;\">\n\n  <p style=\"margin-bottom: 16px;\">\n    Dear <strong>{{ $json.agent_name }}</strong>,\n  </p>\n\n  {{ $json.personalized_opener_html }}\n\n  <!-- Short Description -->\n  <p style=\"font-weight: bold; text-decoration: underline; margin-top: 20px; margin-bottom: 8px;\">\n    Short Description\n  </p>\n\n  <p>\n    While many books explore suffering in isolated forms such as grief, trauma, or relationship\n    breakdown, few examine suffering across its three dimensions \u2014\n    <strong>life, death, and love</strong> \u2014 through a unified existential lens.\n  </p>\n\n  <p>\n    Written in a compassionate tone inspired by the Dalai Lama, combined with the existential\n    philosophy of <strong>Viktor Frankl</strong> and modern psychology, this book explains\n    <strong>why humans suffer</strong> and how meaning can be found <em>through</em> suffering.\n  </p>\n\n  <p>\n    The author writes from personal experience of profound grief, shaping his understanding of love,\n    loss, and human fragility.\n  </p>\n\n  <p>\n    In an age threatened by AI-driven identity crises, this book aspires to be worthy of the education\n    system, helping young people understand suffering and develop resilience against depression and suicide.\n  </p>\n\n  <!-- Brief Synopsis -->\n  <p style=\"font-weight: bold; text-decoration: underline; margin-top: 20px; margin-bottom: 8px;\">\n    Brief Synopsis\n  </p>\n\n  <p>\n    The book is organised into <strong>two main parts</strong>, supported by a\n    <strong>five-tier conceptual framework</strong>. The two parts form the physical structure of the book:\n  </p>\n\n  <ul style=\"padding-left: 18px;\">\n    <li><strong>Part I:</strong> Meaning in Suffering \u2013 theoretical foundation (pp. 1\u201340)</li>\n    <li><strong>Part II:</strong> Value in Suffering \u2013 practical application (pp. 41\u2013250)</li>\n  </ul>\n\n  <p>\n    The five-tier framework operates across both parts, allowing each reader to interpret suffering\n    through a different lens depending on their lived experience.\n  </p>\n\n  <!-- About the Author -->\n  <p style=\"font-weight: bold; text-decoration: underline; margin-top: 20px; margin-bottom: 8px;\">\n    About the Author\n  </p>\n\n  <p>\n    The author previously worked as a data scientist and began this project after encountering\n    profound loss during early adulthood. What stood out most was not only the hurt itself,\n    but the absence of a book that could make suffering feel universal and understandable.\n  </p>\n\n  <p>\n    This book was written to become the guide the author wished had existed during that period.\n  </p>\n\n  <!-- Author\u2019s Aspirations -->\n  <p style=\"font-weight: bold; text-decoration: underline; margin-top: 20px; margin-bottom: 8px;\">\n    Author\u2019s Aspirations\n  </p>\n\n  <p>\n    Since suffering is universal, this book aims to speak across cultures and generations.\n    The long-term aspiration is for it to contribute meaningfully to education systems,\n    helping adolescents and adults find meaning in suffering and build resilience against despair.\n  </p>\n\n  <p>\n    An unlisted YouTube video introducing the project is available upon request.\n  </p>\n\n  <p style=\"margin-top: 24px;\">\n    Warm regards,<br>\n    <strong>Malcolm Tan</strong><br>\n    <span style=\"font-size: 12px; color: #555;\">\n      Author \u2013 <em>Suffering Digs The Well</em>\n    </span>\n  </p>\n\n</div>\n",
        "options": {},
        "subject": "={{ $json.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.2,
      "alwaysOutputData": false
    },
    {
      "id": "2ecbd566-c689-4251-a61f-e11f597e5ba7",
      "name": "Sales Team",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Message personalization ",
      "position": [
        -720,
        48
      ],
      "parameters": {
        "options": {}
      },
      "notesInFlow": true,
      "typeVersion": 3.1
    },
    {
      "id": "a3af00fb-6f45-4d78-81a4-3df35961b106",
      "name": "Mkt Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        -896,
        -544
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\nreturn items.map(item => ({\n\n  json: {\n    ...item.json,\n    chatInput: `You are deciding whether to send an email to a literary agent.\n\nAgent details:\n- Name: ${item.json[\"Literary Agent Name\"]}\n- Email: ${item.json[\"Agent Email to Email\"]}\n- Accepted Genres: ${item.json[\"Accepted Genres\"]}\n- Email Submission Enabled: ${item.json[\"Email Submission Enabled\"]}\n- Eligible for Submission: ${item.json[\"Eligible for Submission\"]}\n\nDecision rules:\n- If Email Submission Enabled is \"TRUE\" AND Eligible for Submission is \"TRUE\" AND Email is not \"UNKNOWN\" -> send_email = \"TRUE\"\n- Otherwise -> send_email = \"FALSE\"\n\nOUTPUT (STRICT):\nReturn ONLY valid JSON matching exactly this schema (no markdown, no extra keys):\n{\"send_email\":\"TRUE|FALSE\",\"selected_email\":\"string\",\"reason\":\"string\"}\n\nSet:\n- selected_email = the Email above if send_email is TRUE, else \"UNKNOWN\"\n- reason = short reason (1 sentence)\n`\n  }\n}));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "de7ad68f-7785-4a36-be4e-b7295e68a06a",
      "name": "Code Readability",
      "type": "n8n-nodes-base.code",
      "position": [
        -448,
        48
      ],
      "parameters": {
        "jsCode": "const results = [];\n\nfor (const item of $input.all()) {\n  const raw = item.json.output ?? \"\";\n\n  try {\n    const parsed = JSON.parse(raw);\n\n    results.push({ json: parsed });\n  } catch (e) {\n    results.push({\n      json: {\n        parse_error: true,\n        error: e.message,\n        raw,\n      },\n    });\n  }\n}\n\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0cd25f48-da30-42cf-9a8b-53fc12f6baf7",
      "name": "Google BQ",
      "type": "n8n-nodes-base.googleBigQuery",
      "notes": "Get Big Query Data",
      "position": [
        -544,
        -1392
      ],
      "parameters": {
        "options": {},
        "sqlQuery": "SELECT * FROM `fiverproject-01.DatasetBQ_SufferingDigsTheWell.TableSufferinDigsTheWell3Rows` LIMIT 1000",
        "projectId": {
          "__rl": true,
          "mode": "list",
          "value": "fiverproject-01",
          "cachedResultUrl": "https://console.cloud.google.com/bigquery?project=fiverproject-01",
          "cachedResultName": "FiverProject-01"
        }
      },
      "credentials": {
        "googleBigQueryOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.1
    },
    {
      "id": "3c11dc10-5913-4602-8066-a1a36c8c3312",
      "name": "Msft Azure Blob",
      "type": "n8n-nodes-base.azureStorage",
      "position": [
        -544,
        -1248
      ],
      "parameters": {
        "blob": {
          "__rl": true,
          "mode": "list",
          "value": "N8N - Suffering Digs The Well Automation - Azure.csv",
          "cachedResultName": "N8N - Suffering Digs The Well Automation - Azure.csv"
        },
        "options": {},
        "resource": "blob",
        "container": {
          "__rl": true,
          "mode": "list",
          "value": "n8ncontainer",
          "cachedResultName": "n8ncontainer"
        },
        "operation": "get",
        "requestOptions": {}
      },
      "credentials": {
        "azureStorageSharedKeyApi": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "1c5392aa-5d50-41ad-b61f-0476b05cd6a3",
      "name": "Amzn AWS S3",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        -544,
        -1120
      ],
      "parameters": {
        "fileKey": "N8N - Suffering Digs The Well Automation - AWS.csv",
        "bucketName": "n8n-data-bucketname"
      },
      "credentials": {
        "aws": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "a2bc62d0-54e0-4a63-b584-9d1ce6e2b361",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Not Recommended",
      "disabled": true,
      "position": [
        -544,
        -1568
      ],
      "parameters": {
        "url": "=Apify_Actor_Endpoint_URL",
        "options": {},
        "jsonBody": "={\n    \"includeWebResults\": false,\n    \"language\": \"en\",\n    \"locationQuery\": \"{{ $json.Location }}\",\n    \"maxCrawledPlacesPerSearch\": {{ $json['Lead Number'] }},\n    \"maxImages\": 0,\n    \"maximumLeadsEnrichmentRecords\": 0,\n    \"scrapeContacts\": false,\n    \"scrapeDirectories\": false,\n    \"scrapeImageAuthors\": false,\n    \"scrapePlaceDetailPage\": false,\n    \"scrapeReviewsPersonalData\": true,\n    \"scrapeTableReservationProvider\": false,\n    \"searchStringsArray\": [\n        \"{{ $json['Business Type'] }}\"\n    ],\n    \"skipClosedPlaces\": false\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "f83de8e8-2fcd-4a44-be45-0a49dc7debe9",
      "name": "Goog Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -544,
        -976
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1743918742,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit#gid=1743918742",
          "cachedResultName": "Sheets"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit?usp=drivesdk",
          "cachedResultName": "N8N - Suffering Digs The Well Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.7
    },
    {
      "id": "4dd5de32-204f-48a4-a73c-3c1fda45044b",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -128,
        -1184
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "72bb6d85-d307-4801-9321-0259afca817b",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        -320,
        -1184
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "936d7706-798a-4dac-aea5-5b1a5bcdf553",
      "name": "Merge2",
      "type": "n8n-nodes-base.merge",
      "position": [
        112,
        -1200
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "8a6791be-9eef-488b-8dab-b61e184d8d2e",
      "name": "AI Agent Determines Which Email to Email1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Purpose: Becasue there are many agents, that do fiction more than non-fiction. \nEven if non-fiction, do not fit the genre i am looking for. ",
      "position": [
        688,
        -1184
      ],
      "parameters": {
        "options": {},
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "c7334e91-ca3c-4eeb-a578-39b230ae12ac",
      "name": "Data Collection Prompt",
      "type": "n8n-nodes-base.code",
      "notes": "Ai Search For Data",
      "position": [
        528,
        -1184
      ],
      "parameters": {
        "jsCode": "`$input.all().length`\nconst itemCount =  3;\n\nconst prompt = `\nYou are part of a team that builds structured datasets for publishing automation.\n\nYour task is to extract literary agent submission information from publicly accessible webpages and return ONLY agents that are immediately eligible for email outreach.\n\nThe extracted data will be appended to a Google Sheet via an n8n workflow.\n\nSOURCE TO ANALYZE:\nhttps://manuscriptwishlist.com/find-agentseditors/agent-list/\n\nAGENT SELECTION RULES (STRICT):\n- Use ONLY publicly available information.\n- Do NOT infer or guess emails.\n- EXCLUDE any agent whose email is not explicitly present.\n  (If email is missing or unclear, DO NOT include the agent.)\n- Do NOT include agents that require login-only platforms.\n- ONLY include agents who represent NON-FICTION and at least ONE of:\n  Memoir, Spiritual, Self-help, Psychology, Relationships, Family.\n\nEMAIL ELIGIBILITY RULE (IMPORTANT):\n- ONLY include agents where email submissions are allowed.\n- EXCLUDE agents who accept submissions ONLY via QueryTracker or QueryManager.\n- As a result:\n  - \"Eligible for Submission\" MUST ALWAYS be \"TRUE\".\n  - \"Email Submission Enabled\" MUST ALWAYS be \"TRUE\".\n\nSUBMISSION STATUS RULES:\n- \"Submission Completed\" MUST ALWAYS be \"FALSE\".\n- \"Submission Timestamp\" MUST be an ISO 8601 string (YYYY-MM-DDTHH:MM:SSZ).\n\nPRIMARY INFORMATION SOURCE RULE:\n- Include the exact public page where the agent\u2019s email was found.\n\nOUTPUT RULES (STRICT \u2014 DO NOT VIOLATE):\n- Return ONLY a valid JSON STRING.\n- Do NOT use markdown.\n- Do NOT include explanations.\n- ALL values MUST be STRINGS.\n- The JSON MUST be an ARRAY.\n- The array MUST contain AT MOST ${itemCount} objects.\n- Each object MUST contain EXACTLY the following keys, IN THIS ORDER:\n\n  1. \"Source Platform\"\n  2. \"Primary Information Source\"\n  3. \"Literary Agent Name\"\n  4. \"Agent Email to Email\"\n  5. \"Accepted Genres\"\n  6. \"Email Submission Enabled\"\n  7. \"QueryTracker Submission Enabled\"\n  8. \"QueryManager Submission Enabled\"\n  9. \"Submission Completed\"\n 10. \"Eligible for Submission\"\n 11. \"Submission Timestamp\"\n\nFORMAT RULES:\n- \"Accepted Genres\" must be a single comma-separated STRING.\n- Use only \"TRUE\" or \"FALSE\" for boolean-like fields.\n- Do NOT return \"UNKNOWN\" for any field.\n- If a required field cannot be confidently populated, EXCLUDE the agent and select another.\n- ONLY include REAL, professional literary agents.\n- EXCLUDE any placeholder, sample, or example entries.\n- EXAMPLES TO EXCLUDE (NON-EXHAUSTIVE):\n  - Names containing: \"Agent One\", \"Agent Two\", \"Agent Three\", \"Sample\", \"Example\", \"Test\"\n  - Emails containing: \"@example.com\"\n  - Emails with local-parts: \"agentone\", \"agenttwo\", \"agentthree\"\n- If zero eligible agents are found, return an empty JSON array: \"[]\".\n\n\nFINAL OUTPUT FORMAT (REQUIRED):\n\"[{...}]\"\n`.trim();\n\nreturn [\n  {\n    json: {\n      chatInput: prompt\n    }\n  }\n];\n"
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "9cd2a4c4-209a-4ebe-9ea4-934e6cb41816",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        688,
        -992
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "8f41d04b-b053-4813-9ee6-8e0ab2498934",
      "name": "Check",
      "type": "n8n-nodes-base.googleSheets",
      "disabled": true,
      "position": [
        320,
        -1312
      ],
      "parameters": {
        "columns": {
          "value": {
            "agency": "={{ $json.agency }}",
            "reason": "={{ $json.reason }}",
            "agent_name": "={{ $json.agent_name }}",
            "send_email": "={{ $json.send_email }}",
            "agent_email": "={{ $json.agent_email }}",
            "Accepted Genres": "={{ $json['Accepted Genres'] }}",
            "genres_represented": "={{ $json.genres_represented }}",
            "Literary Agent Name": "={{ $json.agent_name }}",
            "Agent Email to Email": "={{ $json['Agent Email to Email'] }}",
            "Submission Completed": "=",
            "Submission Timestamp": "={{ $json['Submission Timestamp'] }}",
            "personalization_angles": "={{ $json.personalization_angles }}",
            "Eligible for Submission": "={{ $json['Eligible for Submission'] }}",
            "professional_background": "={{ $json.professional_background }}",
            "Email Submission Enabled": "={{ $json['Email Submission Enabled'] }}",
            "notable_clients_or_books": "={{ $json.notable_clients_or_books }}",
            "QueryManager Submission Enabled": "={{ $json['QueryManager Submission Enabled'] }}",
            "QueryTracker Submission Enabled": "={{ $json['QueryTracker Submission Enabled'] }}",
            "public_statements_or_interviews": "={{ $json.public_statements_or_interviews }}"
          },
          "schema": [
            {
              "id": "Literary Agent Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Literary Agent Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Email to Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Email to Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Accepted Genres",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Accepted Genres",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryTracker Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryTracker Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryManager Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryManager Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Completed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Eligible for Submission",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Eligible for Submission",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "send_email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "send_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "agent_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "agent_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "professional_background",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "professional_background",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "genres_represented",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "genres_represented",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "notable_clients_or_books",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "notable_clients_or_books",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "public_statements_or_interviews",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "public_statements_or_interviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "personalization_angles",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "personalization_angles",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "agent_email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2118729873,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit#gid=2118729873",
          "cachedResultName": "Dev Temp"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit?usp=drivesdk",
          "cachedResultName": "N8N - Suffering Digs The Well Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "49a1e2cc-232d-4770-99a7-2f0eec97a046",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        832,
        -992
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"additionalProperties\": false,\n    \"required\": [\n      \"Source Platform\",\n      \"Primary Information Source\",\n      \"Literary Agent Name\",\n      \"Agent Email to Email\",\n      \"Accepted Genres\",\n      \"Email Submission Enabled\",\n      \"QueryTracker Submission Enabled\",\n      \"QueryManager Submission Enabled\",\n      \"Submission Completed\",\n      \"Eligible for Submission\",\n      \"Submission Timestamp\"\n    ],\n    \"properties\": {\n      \"Source Platform\": {\n        \"type\": \"string\"\n      },\n      \"Primary Information Source\": {\n        \"type\": \"string\"\n      },\n      \"Literary Agent Name\": {\n        \"type\": \"string\"\n      },\n      \"Agent Email to Email\": {\n        \"type\": \"string\"\n      },\n      \"Accepted Genres\": {\n        \"type\": \"string\"\n      },\n      \"Email Submission Enabled\": {\n        \"type\": \"string\",\n        \"enum\": [\"TRUE\"]\n      },\n      \"QueryTracker Submission Enabled\": {\n        \"type\": \"string\",\n        \"enum\": [\"TRUE\", \"FALSE\"]\n      },\n      \"QueryManager Submission Enabled\": {\n        \"type\": \"string\",\n        \"enum\": [\"TRUE\", \"FALSE\"]\n      },\n      \"Submission Completed\": {\n        \"type\": \"string\",\n        \"enum\": [\"FALSE\"]\n      },\n      \"Eligible for Submission\": {\n        \"type\": \"string\",\n        \"enum\": [\"TRUE\"]\n      },\n      \"Submission Timestamp\": {\n        \"type\": \"string\"\n      }\n    }\n  }\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "e4d613cd-9ef6-4d6c-a6ba-df72382355e9",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -1376
      ],
      "parameters": {
        "width": 224,
        "height": 176,
        "content": "## Agent Task\n- Find Compatible Literary agents that represents\n 1. **non-fiction**\n 2. **Genre:** Memoir, Spiritual, Self-help, Psychology, Relationships, Family."
      },
      "typeVersion": 1
    },
    {
      "id": "62b41325-2741-4a3c-9215-0b37ac4e0726",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -640
      ],
      "parameters": {
        "color": 7,
        "width": 230,
        "height": 80,
        "content": "### AI Agent Determines Which Email to Email"
      },
      "typeVersion": 1
    },
    {
      "id": "fc477fda-60f6-4dc5-9309-63921da0c421",
      "name": "Research Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        64,
        -544
      ],
      "parameters": {
        "options": {},
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "f86dee69-0755-44b6-980c-27cd690c3fbd",
      "name": "Research Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        -112,
        -544
      ],
      "parameters": {
        "jsCode": "// n8n Code node: \"Research Prompt\"\n// Outputs `chatInput` so your Agent node can read `{{ $json.chatInput }}` (same as your old working setup)\n\nconst items = $input.all();\n\nreturn items.map((item) => {\n  const j = item.json ?? {};\n\n  // Pull from upstream fields\n  const primarySource = j[\"Primary Information Source\"] ?? \"\";\n  const agentName = j[\"Literary Agent Name\"] ?? \"\";\n  const agentEmail = j[\"Agent Email to Email\"] ?? \"\";\n\n  // If eligibility output is nested under `output`, support that too\n  const sendEmail = j?.output?.send_email ?? j?.send_email ?? \"\";\n  const selectedEmail = j?.output?.selected_email ?? j?.selected_email ?? \"\";\n  const reason = j?.output?.reason ?? j?.reason ?? \"\";\n\n  const chatInput = `\nYou are a research assistant.\n\nYour task:\nProduce a high-quality, source-backed research brief about a literary agent for outreach personalization.\n\nABSOLUTE RULES (DO NOT VIOLATE):\n- Use ONLY publicly available, professional information.\n- Do NOT invent, infer, guess, or \"write as if\" you found something.\n- If a detail is not explicitly stated in a public source, write \"UNKNOWN\".\n- Every factual claim MUST be supported by a citation (a URL) in the \"sources\" array.\n- Do NOT include private life, trauma, health, or family details.\n- Return ONLY valid JSON matching the required schema. No markdown, no backticks.\n\nRESEARCH SCOPE (GO DEEP, BUT STAY VERIFIABLE):\nLook for and extract, when explicitly available:\n1) Agency affiliation + role/title\n2) Professional background (career history, prior roles, editorial experience, notable imprints)\n3) Genres represented + specific interests (especially in nonfiction)\n4) Submission preferences (what they want/avoid, formats, themes, tone)\n5) Notable clients/books/deals (ONLY if explicitly listed publicly)\n6) Public statements/interviews/podcasts/blogs/MWL comments (quote/paraphrase briefly)\n7) LinkedIn / professional bio highlights (ONLY if a public LinkedIn page or official bio is cited)\n8) Recent public news (ONLY if a credible source is cited: interviews, agency announcements, Publisher's Marketplace mentions if public, conference panels, etc.)\n9) SAFE personalization angles that sound thoughtful because they are SPECIFIC and CITED\n\nINPUT DATA:\n- Primary information source: ${primarySource}\n- Agent name: ${agentName}\n- Agent email: ${agentEmail}\n- Outreach decision: ${sendEmail}\n- Selected email: ${selectedEmail}\n- Reason for channel selection: ${reason}\n\nOUTPUT SCHEMA (STRICT):\nReturn exactly ONE JSON object with EXACTLY these keys:\n{\n  \"agent_email\": \"string\",\n  \"agent_name\": \"string\",\n  \"agency\": \"string\",\n  \"professional_background\": \"string\",\n  \"genres_represented\": [\"string\"],\n  \"notable_clients_or_books\": [\"string\"],\n  \"public_statements_or_interviews\": [\n    {\n      \"context\": \"string\",\n      \"summary\": \"string\",\n      \"source\": \"string\"\n    }\n  ],\n  \"personalization_angles\": [\"string\"],\n  \"sources\": [\"string\"]\n}\n\nFORMATTING RULES:\n- If something is unknown, use \"UNKNOWN\" (or [\"UNKNOWN\"] for arrays).\n- For \"public_statements_or_interviews\":\n  - Each item MUST be an object with keys: context, summary, source\n  - \"source\" MUST be a URL string\n  - If none found, return:\n    [{\"context\":\"UNKNOWN\",\"summary\":\"UNKNOWN\",\"source\":\"UNKNOWN\"}]\n- \"sources\" must be a deduplicated list of URLs used. Do NOT include sources you didn't use.\n- Each item in \"personalization_angles\" must end with: \" (source: <URL>)\"\n- Personalization angles must be factual and source-backed (not flattery).\n\nQUALITY BAR:\n- Aim for depth: include prior roles, editorial taste, named interests, and concrete details when publicly stated.\n- Do NOT fabricate LinkedIn/books/news. If you cannot find them, write \"UNKNOWN\" and do not fake it.\n`.trim();\n\n\n  return {\n    json: {\n      ...j,        // keep everything you already have\n      chatInput,   // this is what the Agent node expects\n    },\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6b8d5017-1d60-4673-a093-26a63ce2da0c",
      "name": "Eligibility Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -752,
        -544
      ],
      "parameters": {
        "options": {},
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "263e2540-297c-4172-96d6-89a213b05450",
      "name": "OpenAI Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        64,
        -352
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "8e5ec8c3-4258-48bd-bed8-4f59bfc635e6",
      "name": "Structured Output Parser3",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        224,
        -336
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"additionalProperties\": false,\n  \"required\": [\n    \"agent_email\",\n    \"agent_name\",\n    \"agency\",\n    \"professional_background\",\n    \"genres_represented\",\n    \"notable_clients_or_books\",\n    \"public_statements_or_interviews\",\n    \"personalization_angles\",\n    \"sources\"\n  ],\n  \"properties\": {\n    \"agent_email\": { \"type\": \"string\" },\n    \"agent_name\": { \"type\": \"string\" },\n    \"agency\": { \"type\": \"string\" },\n    \"professional_background\": { \"type\": \"string\" },\n    \"genres_represented\": {\n      \"type\": \"array\",\n      \"items\": { \"type\": \"string\" }\n    },\n    \"notable_clients_or_books\": {\n      \"type\": \"array\",\n      \"items\": { \"type\": \"string\" }\n    },\n    \"public_statements_or_interviews\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"additionalProperties\": false,\n        \"required\": [\"context\", \"summary\", \"source\"],\n        \"properties\": {\n          \"context\": { \"type\": \"string\" },\n          \"summary\": { \"type\": \"string\" },\n          \"source\": { \"type\": \"string\" }\n        }\n      }\n    },\n    \"personalization_angles\": {\n      \"type\": \"array\",\n      \"items\": { \"type\": \"string\" }\n    },\n    \"sources\": {\n      \"type\": \"array\",\n      \"items\": { \"type\": \"string\" }\n    }\n  }\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "fa947b95-9010-4b03-a105-89bf5b605fdc",
      "name": "Data Collection Normalizer",
      "type": "n8n-nodes-base.code",
      "position": [
        1008,
        -1184
      ],
      "parameters": {
        "jsCode": "// Your AI node output is an object like: { output: [ {...}, {...} ] }\nconst root = $input.first().json;\n\nconst arr = Array.isArray(root.output)\n  ? root.output\n  : Array.isArray(root)\n    ? root\n    : [];\n\n// Turn array into individual n8n items\nreturn arr.map(agent => ({ json: agent }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "47d3d9da-2dfc-4591-a0f4-c73a73b70192",
      "name": "Check2",
      "type": "n8n-nodes-base.googleSheets",
      "disabled": true,
      "position": [
        1184,
        -1296
      ],
      "parameters": {
        "columns": {
          "value": {
            "agent_email": "={{ $json['Agent Email to Email'] }}",
            "Accepted Genres": "={{ $json['Accepted Genres'] }}",
            "Literary Agent Name": "={{ $json['Literary Agent Name'] }}",
            "Agent Email to Email": "={{ $json['Agent Email to Email'] }}",
            "Eligible for Submission": "={{ $json['Eligible for Submission'] }}",
            "Email Submission Enabled": "={{ $json['Email Submission Enabled'] }}",
            "QueryManager Submission Enabled": "={{ $json['QueryManager Submission Enabled'] }}",
            "QueryTracker Submission Enabled": "={{ $json['QueryTracker Submission Enabled'] }}"
          },
          "schema": [
            {
              "id": "Literary Agent Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Literary Agent Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Email to Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Agent Email to Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Accepted Genres",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Accepted Genres",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryTracker Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryTracker Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryManager Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryManager Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Completed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Eligible for Submission",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Eligible for Submission",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "send_email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "send_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agent_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agent_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "professional_background",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "professional_background",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "genres_represented",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "genres_represented",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "notable_clients_or_books",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "notable_clients_or_books",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "public_statements_or_interviews",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "public_statements_or_interviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "personalization_angles",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "personalization_angles",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Agent Email to Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2118729873,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit#gid=2118729873",
          "cachedResultName": "Dev Temp"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit?usp=drivesdk",
          "cachedResultName": "N8N - Suffering Digs The Well Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "26d955d7-b2b1-4dd3-b2ab-1d2465d069ae",
      "name": "Mkt Normalizer",
      "type": "n8n-nodes-base.code",
      "position": [
        -464,
        -544
      ],
      "parameters": {
        "jsCode": "const results = [];\n\nfor (const item of $input.all()) {\n  const output = item.json?.output ?? {};\n\n  results.push({\n    json: {\n      send_email: output.send_email ?? \"FALSE\",\n      selected_email: output.selected_email ?? \"UNKNOWN\",\n      reason: output.reason ?? \"\"\n    }\n  });\n}\n\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "89fa19ba-7165-4b96-8363-bc36d2590906",
      "name": "Research Normalizer",
      "type": "n8n-nodes-base.code",
      "position": [
        368,
        -544
      ],
      "parameters": {
        "jsCode": "function toFlatString(val) {\n  if (val === null || val === undefined) return \"\";\n\n  if (typeof val === \"string\") return val;\n  if (typeof val === \"number\" || typeof val === \"boolean\") return String(val);\n\n  // Arrays \u2192 \"a, b, c\"\n  if (Array.isArray(val)) {\n    return val\n      .map(v => toFlatString(v))\n      .filter(Boolean)\n      .join(\", \");\n  }\n\n  // Objects \u2192 \"key: value; key2: value2\"\n  if (typeof val === \"object\") {\n    return Object.entries(val)\n      .map(([k, v]) => `${k}: ${toFlatString(v)}`)\n      .filter(Boolean)\n      .join(\"; \");\n  }\n\n  return String(val);\n}\n\nconst items = $input.all();\n\nreturn items.map(item => {\n  // If the AI Agent + parser returns { output: { ... } }, flatten that inner object\n  const src = (item.json && typeof item.json.output === \"object\" && item.json.output !== null)\n    ? item.json.output\n    : item.json;\n\n  const flat = {};\n  for (const [key, value] of Object.entries(src)) {\n    flat[key] = toFlatString(value);\n  }\n\n  // OPTIONAL: keep original metadata if you need it\n  // flat[\"Source Platform\"] = item.json[\"Source Platform\"] ?? flat[\"Source Platform\"] ?? \"\";\n\n  return { json: flat };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3f446c8f-3e1e-4816-be11-01a0ff4e6234",
      "name": "check3",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        496,
        -672
      ],
      "parameters": {
        "columns": {
          "value": {
            "agency": "={{ $json.agency }}",
            "reason": "={{ $('Switch1').item.json.reason }}",
            "agent_name": "={{ $json.agent_name }}",
            "send_email": "={{ $('Mkt Normalizer').item.json.send_email }}",
            "agent_email": "={{ $json.agent_email }}",
            "Accepted Genres": "={{ $('Data Collection Normalizer').item.json['Accepted Genres'] }}",
            "genres_represented": "={{ $json.genres_represented }}",
            "Literary Agent Name": "={{ $('Data Collection Normalizer').item.json['Literary Agent Name'] }}",
            "Agent Email to Email": "={{ $('Data Collection Normalizer').item.json['Agent Email to Email'] }}",
            "personalization_angles": "={{ $json.personalization_angles }}",
            "Eligible for Submission": "={{ $('Data Collection Normalizer').item.json['Email Submission Enabled'] }}",
            "professional_background": "={{ $json.professional_background }}",
            "Email Submission Enabled": "={{ $('Data Collection Normalizer').item.json['Email Submission Enabled'] }}",
            "notable_clients_or_books": "={{ $json.notable_clients_or_books }}",
            "QueryManager Submission Enabled": "={{ $('Data Collection Normalizer').item.json['QueryManager Submission Enabled'] }}",
            "QueryTracker Submission Enabled": "={{ $('Data Collection Normalizer').item.json['QueryTracker Submission Enabled'] }}",
            "public_statements_or_interviews": "={{ $json.public_statements_or_interviews }}"
          },
          "schema": [
            {
              "id": "Literary Agent Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Literary Agent Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Email to Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Email to Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Accepted Genres",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Accepted Genres",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryTracker Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryTracker Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryManager Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryManager Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Completed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Eligible for Submission",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Eligible for Submission",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "send_email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "send_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "agent_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agent_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "professional_background",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "professional_background",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "genres_represented",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "genres_represented",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "notable_clients_or_books",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "notable_clients_or_books",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "public_statements_or_interviews",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "public_statements_or_interviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "personalization_angles",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "personalization_angles",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "agent_email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "2118729873"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit?usp=drivesdk",
          "cachedResultName": "N8N - Suffering Digs The Well Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "4f2be1a8-b2b5-4160-9eb4-f114c93bd0be",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        720,
        -496
      ],
      "parameters": {
        "options": {},
        "agentName": "jOHN",
        "availableInChat": true
      },
      "typeVersion": 1.4
    },
    {
      "id": "66ca849c-ddff-4053-bc4f-f2e044bbfdb4",
      "name": "QuickChart1",
      "type": "n8n-nodes-base.quickChart",
      "position": [
        1504,
        -496
      ],
      "parameters": {
        "data": "=1\n2\n3\n4\n",
        "labelsUi": {
          "labelsValues": [
            {
              "label": "Completed"
            },
            {
              "label": "not completed"
            }
          ]
        },
        "chartOptions": {},
        "datasetOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "d06a8a18-fc9d-49f4-9d46-5831264bf952",
      "name": "Analysis Normalizer",
      "type": "n8n-nodes-base.code",
      "position": [
        1344,
        -496
      ],
      "parameters": {
        "jsCode": "const results = [];\n\nfor (const item of $input.all()) {\n  const output = item.json?.output ?? {};\n\n  results.push({\n    json: {\n      send_email: output.send_email ?? \"FALSE\",\n      selected_email: output.selected_email ?? \"UNKNOWN\",\n      reason: output.reason ?? \"\"\n    }\n  });\n}\n\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "29cddd7f-a206-4a7f-8032-f66c11e96a13",
      "name": "Analysis Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        -496
      ],
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "typeVersion": 2
    },
    {
      "id": "653822e2-ed38-4548-a64b-920789325802",
      "name": "Google Analytics 4",
      "type": "n8n-nodes-base.googleAnalytics",
      "notes": "Get a Report",
      "disabled": true,
      "position": [
        720,
        -672
      ],
      "parameters": {
        "metricsGA4": {
          "metricValues": [
            {}
          ]
        },
        "propertyId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "dimensionsGA4": {
          "dimensionValues": [
            {}
          ]
        },
        "additionalFields": {}
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "05ca28b8-149a-45a9-b804-d7a277179e83",
      "name": "PowerBi Dashboard",
      "type": "n8n-nodes-powerbi.powerBi",
      "disabled": true,
      "position": [
        880,
        -672
      ],
      "parameters": {
        "operation": "get"
      },
      "typeVersion": 1
    },
    {
      "id": "33985c5d-d9b3-43fd-b338-74ac07aa3134",
      "name": "Update Submission Time",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -64,
        48
      ],
      "parameters": {
        "columns": {
          "value": {
            "agent_email": "={{ $('Research Normalizer').item.json.agent_email }}",
            "Submission Completed": "TRUE",
            "Submission Timestamp": "={{ \n  new Date().toLocaleString('en-US', {\n    month: 'numeric',\n    day: 'numeric',\n    year: 'numeric',\n    hour: 'numeric',\n    minute: '2-digit',\n    second: '2-digit',\n    hour12: false\n  })\n}}\n"
          },
          "schema": [
            {
              "id": "Literary Agent Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Literary Agent Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Email to Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Email to Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Accepted Genres",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Accepted Genres",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryTracker Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryTracker Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "QueryManager Submission Enabled",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "QueryManager Submission Enabled",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Completed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Completed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Eligible for Submission",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Eligible for Submission",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submission Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submission Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "send_email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "send_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "agent_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agent_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agent_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "agency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "agency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "professional_background",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "professional_background",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "genres_represented",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "genres_represented",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "notable_clients_or_books",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "notable_clients_or_books",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "public_statements_or_interviews",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "public_statements_or_interviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "personalization_angles",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "personalization_angles",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "agent_email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2118729873,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit#gid=2118729873",
          "cachedResultName": "Dev Temp"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SAFY60bPI7cTfR-4YRTyV_hSgpR0oOO64DSTMzJzchk/edit?usp=drivesdk",
          "cachedResultName": "N8N - Suffering Digs The Well Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.7
    },
    {
      "id": "bb9e1177-6c1e-4649-a06f-981a50e46e81",
      "name": "Sticky Note21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1392,
        -1632
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 504,
        "content": "## Main Objective\n\n### Marketing\n1. Audience discovery (agent discovery)\n2. Market segmentation (genre filtering)\n3. Channel qualification (email vs platform)\n4. Message personalization (agent-specific emails)\n5. Campaign readiness (HTML email templates)\n6. Funnel top-of-pipeline automation\n\n### Sales\n1. Lead qualification (eligible vs ineligible)\n2. Lead deduplication\n3. CRM-style tracking (submission status, timestamps)\n4. Outreach execution\n5. Post-send state updates\n6. Pipeline hygiene"
      },
      "typeVersion": 1
    },
    {
      "id": "6f78baf8-64ac-4a2c-a769-8bed2b27eef8",
      "name": "Sticky Note22",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -720
      ],
      "parameters": {
        "color": 4,
        "width": 1584,
        "height": 528,
        "content": "# Marketing & Research Team"
      },
      "typeVersion": 1
    },
    {
      "id": "7e3d1d40-8ed0-4356-b11d-bd9fc41dc0e5",
      "name": "Sticky Note23",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -176
      ],
      "parameters": {
        "width": 1072,
        "height": 384,
        "content": "# Sales Team"
      },
      "typeVersion": 1
    },
    {
      "id": "e01e0c71-39bb-4c09-837b-5d506efb09b8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        -688
      ],
      "parameters": {
        "width": 224,
        "height": 128,
        "content": "## Agent Task\n### For Each Literary, Research on them to write tailored email"
      },
      "typeVersion": 1
    },
    {
      "id": "ba0e9918-69c4-4af7-88cf-c0d2493fc434",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        -688
      ],
      "parameters": {
        "width": 224,
        "height": 176,
        "content": "## Agent Task\n### Write in chat, send to Prompt and AI Generates Quick Chart. Alternaively, you can use BI or Google Analytics too"
      },
      "typeVersion": 1
    },
    {
      "id": "3e6f764e-8dd6-4395-954a-5d3e3cd35f1f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 128,
        "content": "## Agent Task\nAI Writes Message personalized emails to improve sales % Hit-rate\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1aa70620-3172-486d-9d39-ef941b771fbd",
      "name": "Eligibility Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1056,
        -496
      ],
      "parameters": {
        "options": {},
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "f5bf9e98-2064-4d53-97fa-b6e7d1717e08",
      "name": "OpenAI Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1056,
        -304
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    }
  ],
  "connections": {
    "Check": {
      "main": [
        []
      ]
    },
    "Check2": {
      "main": [
        []
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge2": {
      "main": [
        [
          {
            "node": "Check",
            "type": "main",
            "index": 0
          },
          {
            "node": "Data Collection Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Research Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google BQ": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mkt Prompt": {
      "main": [
        [
          {
            "node": "Eligibility Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sales Team": {
      "main": [
        [
          {
            "node": "Code Readability",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Amzn AWS S3": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Goog Sheets": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        []
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Eligibility Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Mkt Normalizer": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research Agent": {
      "main": [
        [
          {
            "node": "Research Normalizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        [
          {
            "node": "Update Submission Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analysis Prompt": {
      "main": [
        [
          {
            "node": "Eligibility Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Msft Azure Blob": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research Prompt": {
      "main": [
        [
          {
            "node": "Research Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code Readability": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SalesAgentPrompt": {
      "main": [
        [
          {
            "node": "Sales Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google BQ",
            "type": "main",
            "index": 0
          },
          {
            "node": "Msft Azure Blob",
            "type": "main",
            "index": 0
          },
          {
            "node": "Amzn AWS S3",
            "type": "main",
            "index": 0
          },
          {
            "node": "Goog Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Eligibility Agent": {
      "main": [
        [
          {
            "node": "Mkt Normalizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Eligibility Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Eligibility Agent1": {
      "main": [
        [
          {
            "node": "Analysis Normalizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Analytics 4": {
      "main": [
        [
          {
            "node": "PowerBi Dashboard",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Sales Team",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Determines Which Email to Email1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Research Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Eligibility Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Analysis Normalizer": {
      "main": [
        [
          {
            "node": "QuickChart1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research Normalizer": {
      "main": [
        [
          {
            "node": "SalesAgentPrompt",
            "type": "main",
            "index": 0
          },
          {
            "node": "check3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Collection Prompt": {
      "main": [
        [
          {
            "node": "AI Agent Determines Which Email to Email1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Eligibility Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent Determines Which Email to Email1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser3": {
      "ai_outputParser": [
        [
          {
            "node": "Research Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Data Collection Normalizer": {
      "main": [
        [
          {
            "node": "Check2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Mkt Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Analysis Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Determines Which Email to Email1": {
      "main": [
        [
          {
            "node": "Data Collection Normalizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}