{
  "name": "Sponsor reply",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {},
        "options": {}
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "id": "0d6f45f7-dd9a-4ba8-ae96-eea8a5bb18ea",
      "name": "Gmail Trigger",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "48362988-8561-4a24-9ee5-e177b43e956c",
              "name": "Email Context",
              "value": "=From: {{ $json.headers.from }}\n\nSubject: {{ $json.headers.subject }}\n\nEmail Body: {{ $json.text }}\n",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        180,
        0
      ],
      "id": "ee489d8a-a53f-4f99-b03d-5e737541d794",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=**Role:**  \nYour task is to determine whether an email is related to a sponsorship deal or not.  \n\nRespond with a JSON object containing the following fields:  \n\n- **isSponsorship:** Can be either `\"true\"` or `\"false\"`.  \n- **reasoning:** Explain your answer.  \n\nThink step by step about your response.\n\n{{ $json['Email Context'] }}",
        "hasOutputParser": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        340,
        0
      ],
      "id": "ca342c6b-e56b-4b59-bcaa-dffccb95bd97",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        340,
        260
      ],
      "id": "d5250c9b-ff90-497c-bd3b-fcb6c0c36e94",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"isSponsorship\": {\n\t\t\t\"type\": \"boolean\"\n\t\t},\n\t\t\"reasoning\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        500,
        260
      ],
      "id": "ee9f8671-567e-4e10-b635-3670dbd8eef5",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f7b8641c-39bc-4c31-b68a-1d673389ac0f",
              "leftValue": "={{ $json.output.isSponsorship }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        640,
        0
      ],
      "id": "cfdd775a-8f14-4a0c-85f6-499d95200e4f",
      "name": "If"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1100,
        160
      ],
      "id": "d292a035-352a-4789-9215-898b89a82706",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=**Role:**  \nYou work for a YouTube channel called *AI mit Arnie*.  \nYour task is to respond to sponsorship inquiries by drafting a reply email.  \n\n**Task:**  \nCarefully review the email context below and write a friendly and professional email.  \nReturn only the **email body in HTML format**\u2014do **not** include a header, only the body!  \nThe email should include details about sponsorship costs and conditions.  \n\n**Conditions:**  \n\n### Sponsorship Terms for the YouTube Channel *AI mit Arnie*  \n\n#### **Channel Overview**  \n- **Channel Name:** AI mit Arnie  \n- **Subscribers:** 15,000+  \n- **Average Views per Video:** 3,000 \u2013 10,000  \n- **Content Focus:** Artificial Intelligence  \n\n#### **Sponsorship Pricing**  \n- **Standalone Video:** \u20ac800 \u2013 \u20ac1,300  \n- **Integrated Sponsorship Mention (60 seconds):** \u20ac600  \n\n#### **Additional Info**  \n*AI mit Arnie* only accepts sponsors that make sense for its target audience. In general, the channel rejects anything that does not provide real value to viewers and does not promote products that the creator does not personally use.",
              "role": "system"
            },
            {
              "content": "=Email Context: {{ $('Edit Fields').item.json['Email Context'] }}"
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        800,
        -100
      ],
      "id": "74672a31-8aff-4576-a9cd-2cf4ef9e4df6",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "reply",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "message": "={{ $json.message.content }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1100,
        -100
      ],
      "id": "30cf5db7-bdbc-4fab-8825-e0e9632fd055",
      "name": "Gmail",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1835e3c9-9bff-4b10-9856-b6b696966024",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "LPn4cNIKqht5Mkb4",
  "tags": []
}