{
  "id": "_JKW3snr3Y6dKOTfF2_FC",
  "name": "Generate sales emails based on business events with Explorium MCP & Slack",
  "tags": [],
  "nodes": [
    {
      "id": "a0b18504-83e1-4b33-b6f7-1051d31a8508",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -832,
        528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "1b589c01-3d0a-46ae-9b41-18acb786ae88",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1008,
        512
      ],
      "parameters": {
        "options": {
          "reset": false
        },
        "batchSize": "={{ 1 }}"
      },
      "typeVersion": 3
    },
    {
      "id": "f0668dc1-e0d7-44af-942c-10b614995635",
      "name": "Company Researcher",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -816,
        352
      ],
      "parameters": {
        "text": "={{ $json }}",
        "options": {
          "maxIterations": 12,
          "systemMessage": "=You are a research analyst helping a sales agent write a highly personalized outbound email. Your job is to generate a detailed research brief that explains:\n\n1. **What the company does**\n2. **What the recent business event is**, and why it's significant\n3. **How the event might reflect on the company\u2019s priorities, pain points, or growth goals**\n4. Any additional company context that might be useful for crafting a relevant sales message\n\n## Guidelines:\n- Your response should be **detailed, structured, and accurate**\n- You are writing **for another AI**, so don't hold back on context \u2014 more is better\n- You can assume the user already passed in the full event details (like a trigger type, a short summary, etc.)\n- Focus more on **interpreting** the event and **linking it to the company**\n- Write in **natural language**, using clear, concise, informative sentences \u2014 not marketing fluff or speculation\n- Keep your tone objective and analytical\n- Avoid repeating generic phrases like \u201cthe company is innovative\u201d unless supported by facts\n\n## Inputs:\n- Business ID: {{ $json.body.business_id }}\n- Event: {{ $json.body.data }}\n\n## Output Structure:\nReturn your findings in 2-3 clear paragraphs. The first paragraph should describe the **event in detail** and explain why it may be relevant. The second should summarize what the **company does** and any other useful GTM signals (size, growth stage, recent changes, priorities, etc.).\n\nNow generate the research summary.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "9cf6886b-95f3-420a-8ff4-0070bf37f4fa",
      "name": "Email Writer ( YES prospect data)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1232,
        384
      ],
      "parameters": {
        "text": "=prospect_data: contact info:{{ $json.email }}, expereince:{{ $json.experience }},skills:{{ $json.skills }}.\ncompany data:{{ $('Company Researcher').first().json.output }}\nevent data: {{ $('Webhook - Product Launch').first().json.body }}\n\n",
        "options": {
          "systemMessage": "=You are a B2B outbound sales email generator.\n\nYour task is to write a short and effective cold outbound email (under 150 words) to a specific prospect at a company. The goal is to be relevant, concise, and persuasive, while introducing Explorium in a way that aligns with the prospect\u2019s role and current company context.\n\n## Prospect Data\n{prospect_data}\n\n## Company \n{company_data}\n\n## Event Data\n{event_data}\n\n## About Explorium (Use this to inform the email \u2014 do not paste directly):\nExplorium is a data-powered intelligence platform on a mission to unlock the full potential of external data for the agent era. We serve as the infrastructure backbone for intelligent systems \u2014 helping go-to-market teams enrich company and prospect data, tap into real-time signals, and dynamically prioritize their best-fit accounts. Our platform fuels the agents and AI products that are redefining the future of sales and marketing.\n\n## MCP Playground (Link to include):\nInvite the prospect to explore Explorium\u2019s capabilities hands-on via our [MCP Playground](https://www.explorium.ai/mcp-playground/), a public environment to experience the power of enriched external data.\n\n## Output Instructions:\n- Personalize the email using the provided prospect, company, and event information\n- Tailor the message to the prospect\u2019s title, department, or function\n- Weave in how Explorium could support their work or goals based on what the company is focused on\n- The email should feel like it\u2019s written by a real SDR \u2014 confident, relevant, and human\n- End the email with a soft CTA inviting them to check out the MCP Playground link but dont forget to also ask to set up a meeting / call\n- At the top of the email, output the selected email address to use. Choose the prospect\u2019s **professional email** if available, or fallback to the next best alternative (personal, current, etc.)\n\nNow write the email.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "383f709f-8194-42d8-a700-1b22ca25d3ff",
      "name": "Email Writer (NO prospect data)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -16,
        112
      ],
      "parameters": {
        "text": "=company data:{{ $('Company Researcher').first().json.output }}\nevent data: {{ $('Webhook - Product Launch').first().json.body }}\n",
        "options": {
          "systemMessage": "=You are a B2B outbound email assistant.\n\nYour task is to write a short, personalized outbound email (under 120 words) that connects Explorium to a recent business event or trigger at a target company. This email will be sent to a general marketing, growth, or data contact \u2014 no specific prospect information is available.\n\n## Context Provided:\n- Company Information: {company_data}\n- Event Information: {event_data}\n\n## About Explorium (Use as context \u2014 DO NOT paste directly):\nExplorium is on a mission to unlock the full potential of data for the agent era. From day one, we\u2019ve been driven to be the data and infrastructure backbone that powers intelligent systems and delivers real business growth.\n\nWe partner with smart, driven teams to turn raw external data into actionable insight\u2014fueling agents, AI products, and GTM strategies for the future of sales and marketing.\n\nIf relevant, you may mention that they can explore Explorium\u2019s capabilities themselves via our [MCP Playground](https://www.explorium.ai/mcp-playground/), a public demo environment showcasing the power of enriched data. \n\ndont forget to always end with a call to action in setting up some sort of call or meeting to talk further\n\n## Instructions:\n- Reference the event to establish relevance and timing\n- Briefly describe what the company does (from the input)\n- Weave in Explorium\u2019s value if it's applicable to their business priorities\n- If appropriate, suggest checking out the MCP Playground link\n- End with a warm, soft CTA\n\nNow write the email.\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "01af666d-4429-4ae4-8de9-f24f707908c4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -832,
        176
      ],
      "parameters": {
        "width": 260,
        "height": 144,
        "content": "## Reaserch\nThis agent uses the Explorium MCP to research the company that just had an event"
      },
      "typeVersion": 1
    },
    {
      "id": "da87fb18-2428-43d3-8a7e-462b8090592e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        192
      ],
      "parameters": {
        "height": 140,
        "content": "## Crossroads \n\nif we cant find data about the company's employees, we fork up, to write a general email "
      },
      "typeVersion": 1
    },
    {
      "id": "5cb399a2-9fbb-44bf-b3ec-26747ab98648",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        -16
      ],
      "parameters": {
        "height": 100,
        "content": "## email writer #1\nGiven the research, this agents writes an email"
      },
      "typeVersion": 1
    },
    {
      "id": "4b29b790-96e5-4b3c-950a-aa08bcd79fe7",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        368
      ],
      "parameters": {
        "width": 256,
        "height": 120,
        "content": "##  Employee Data \nGather data about the 5 employees we will write emails to."
      },
      "typeVersion": 1
    },
    {
      "id": "ec6813eb-2f0d-492d-a902-aa78e852b6c2",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        224
      ],
      "parameters": {
        "width": 256,
        "height": 140,
        "content": "## Email Writer #2\nGiven both data about the email and the employee, the agent will write a highly personalized email to each employee\n"
      },
      "typeVersion": 1
    },
    {
      "id": "708bccb2-612d-44e6-b249-a003e9d8de95",
      "name": "Webhook - Product Launch",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1040,
        352
      ],
      "parameters": {
        "path": "https://lievi.app.n8n.cloud/webhook-test/product-launch",
        "options": {},
        "httpMethod": "POST",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "44770afa-33c9-4c0f-ac36-00d7d2af4edd",
      "name": "Is there data on the company?",
      "type": "n8n-nodes-base.if",
      "position": [
        -240,
        352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8627133a-68d0-4907-b8ca-d8deba93089d",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.length }}\n",
              "rightValue": "=0"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "7ad10732-baf1-42ed-95cd-bf391ac6df24",
      "name": "Claude",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -16,
        272
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "e8fc2008-acd6-416c-90ca-95b6414aaa6f",
      "name": "Code - Format Object",
      "type": "n8n-nodes-base.code",
      "position": [
        48,
        512
      ],
      "parameters": {
        "jsCode": "const candidates = $input.first().json.data;\n\nif (!Array.isArray(candidates) || candidates.length === 0) {\n  throw new Error(\"No candidates found in data.\");\n}\n\nconst result = candidates.map(candidate => {\n  return {\n    json: {\n      prospect_id: candidate.prospect_id,  \n      full_name: candidate.full_name,\n      first_name: candidate.first_name,\n      last_name: candidate.last_name,\n      title: candidate.job_title,\n      department: candidate.job_department,\n      seniority: candidate.job_seniority_level?.join(', ') || '',\n      company: candidate.company_name,\n      location: `${candidate.city}, ${candidate.region_name}, ${candidate.country_name}`,\n      linkedin: candidate.linkedin,\n      email: candidate.professional_email_hashed || '',\n      experience: candidate.experience?.join(' | ') || '',\n      skills: candidate.skills?.join(', ') || '',\n      interests: candidate.interests?.join(', ') || '',\n      business_id: candidate.business_id\n    }\n  };\n});\n\nreturn result;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "28004c6b-ffb1-4ec9-8b66-6a88899d80c4",
      "name": "Code - Get prospect_ids",
      "type": "n8n-nodes-base.code",
      "position": [
        336,
        512
      ],
      "parameters": {
        "jsCode": "const prospectIds = $input.all()\n  .map(item => String(item.json.prospect_id).trim()) // Force string and trim whitespace\n  .filter(Boolean); // remove empty/null\n\nreturn [{\n  json: {\n    prospect_ids: prospectIds\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "44290481-02a8-4441-a34e-2a98bbb0790e",
      "name": "Send Slack Message",
      "type": "n8n-nodes-base.slack",
      "position": [
        304,
        112
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "user": {
          "__rl": true,
          "mode": "list",
          "value": "U08KUURMK2S",
          "cachedResultName": "itamar.levi"
        },
        "select": "user",
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "3a77b8d1-9ff7-455d-89c6-d48945c3a5be",
      "name": "Code - Merge profile with email info",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        512
      ],
      "parameters": {
        "jsCode": "// Get enrichment data from the current input\nconst enrichmentResponse = $input.first().json.enrichmentsResponse;\n\nconst result = [];\n\n// Process each enrichment response\nif (enrichmentResponse && enrichmentResponse.length > 0) {\n  for (const enrichment of enrichmentResponse) {\n    if (enrichment.response && enrichment.response.data) {\n      for (const contact of enrichment.response.data) {\n        // Get the best email from the enrichment data\n        const emailData = contact.data;\n        \n        let email = emailData.professions_email ||\n                    (emailData.emails?.find(e => e.type === \"professional\")?.address) ||\n                    (emailData.emails?.find(e => e.type === \"current_professional\")?.address) ||\n                    (emailData.emails?.[0]?.address) ||\n                    \"\";\n        \n        result.push({\n          json: {\n            prospect_id: contact.prospect_id,\n            email: email,\n            professional_email_status: emailData.professional_email_status,\n            phone_numbers: emailData.phone_numbers\n          }\n        });\n      }\n    }\n  }\n}\n\nreturn result;"
      },
      "typeVersion": 2
    },
    {
      "id": "4044c1d9-2c45-4587-b92a-59949702a537",
      "name": "Anthropic - Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        1232,
        544
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "52c2e52e-af12-461c-b7b3-d1388217ae45",
      "name": "Send Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        1584,
        512
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "user": {
          "__rl": true,
          "mode": "list",
          "value": "U022J54V0RH",
          "cachedResultName": "inna.shestakov"
        },
        "select": "user",
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "238b04c6-889a-444a-9e54-76b3589595b9",
      "name": "Explorium MCP",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        -672,
        528
      ],
      "parameters": {
        "options": {},
        "endpointUrl": "https://mcp-n8n.explorium.ai/mcp",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "480cb222-7d3b-4772-8d16-11aacafae25c",
      "name": "Enrich contact information",
      "type": "@exploriumai/n8n-nodes-explorium-ai.exploriumApiNode",
      "position": [
        560,
        512
      ],
      "parameters": {
        "type": "prospects",
        "jsonInput": "={{ JSON.stringify({ prospect_ids: $json.prospect_ids }) }}\n",
        "operation": "enrich",
        "useJsonInput": true
      },
      "credentials": {
        "exploriumApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3bae4b8a-b0ee-4f03-b066-8c605b450188",
      "name": "Fetch Prospects",
      "type": "@exploriumai/n8n-nodes-explorium-ai.exploriumApiNode",
      "position": [
        -464,
        352
      ],
      "parameters": {
        "type": "prospects",
        "jsonInput": "={\n  \"mode\": \"full\",\n  \"page\": 1,\n  \"size\": 5,\n  \"page_size\": 5,\n  \"filters\": {\n    \"has_email\": { \"value\": true },\n    \"job_level\": {\n      \"values\": [\"owner\", \"cxo\", \"vp\", \"director\", \"manager\", \"senior\"]\n    },\n    \"job_department\": {\n      \"values\": [\"Marketing\"]\n    },\n    \"business_id\": {\n      \"values\": [\"{{ $('Webhook - Product Launch').item.json.business_id }}\"]\n    }\n  }\n}",
        "operation": "fetch",
        "useJsonInput": true
      },
      "credentials": {
        "exploriumApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Claude": {
      "ai_languageModel": [
        [
          {
            "node": "Email Writer (NO prospect data)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send Slack": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Explorium MCP": {
      "ai_tool": [
        [
          {
            "node": "Company Researcher",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Prospects": {
      "main": [
        [
          {
            "node": "Is there data on the company?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Email Writer ( YES prospect data)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Researcher": {
      "main": [
        [
          {
            "node": "Fetch Prospects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Company Researcher",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code - Format Object": {
      "main": [
        [
          {
            "node": "Code - Get prospect_ids",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic - Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Email Writer ( YES prospect data)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code - Get prospect_ids": {
      "main": [
        [
          {
            "node": "Enrich contact information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook - Product Launch": {
      "main": [
        [
          {
            "node": "Company Researcher",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich contact information": {
      "main": [
        [
          {
            "node": "Code - Merge profile with email info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is there data on the company?": {
      "main": [
        [
          {
            "node": "Email Writer (NO prospect data)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code - Format Object",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Writer (NO prospect data)": {
      "main": [
        [
          {
            "node": "Send Slack Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Writer ( YES prospect data)": {
      "main": [
        [
          {
            "node": "Send Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Merge profile with email info": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}