{
  "name": "Gmail to Slack: AI Summarized Email Alerts",
  "nodes": [
    {
      "name": "Trigger on Unread Email",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "filters": {
          "readStatus": "unread"
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "name": "Get Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        224,
        0
      ],
      "parameters": {
        "simple": false,
        "options": {},
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "typeVersion": 2.1
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        448,
        0
      ],
      "parameters": {
        "text": "=You are an assistant that summarises emails. \nSummarise the following email into a concise message (max 250 characters).\n\nYour output must be valid JSON with exactly two fields:\n- \"sender\": the sender\u2019s name\n- \"summary\": the 250-character summary\n\nHere is the required output format:\n{\n  \"sender\": \"Example Sender\",\n  \"summary\": \"Example summary of the email, no more than 250 characters.\"\n}\n\nEmail content:\n{{ $json[\"text\"] }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        464,
        224
      ],
      "parameters": {
        "model": {
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        592,
        224
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"sender\": {\n      \"type\": \"string\",\n      \"description\": \"The sender\u2019s name from the email\"\n    },\n    \"summary\": {\n      \"type\": \"string\",\n      \"maxLength\": 250,\n      \"description\": \"A concise summary of the email content\"\n    }\n  },\n  \"required\": [\"sender\", \"summary\"],\n  \"additionalProperties\": false\n}"
      },
      "typeVersion": 1.3
    },
    {
      "name": "Send Notification to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        800,
        0
      ],
      "parameters": {
        "text": "={{ $json.output.sender }}: {{ $json.output.summary }}",
        "select": "user",
        "otherOptions": {
          "includeLinkToWorkflow": false
        },
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        304
      ],
      "parameters": {
        "width": 272,
        "height": 128,
        "content": "### \ud83d\udee0\ufe0f Connect Credentials First\nEnsure Gmail, Slack, and OpenAI are connected before activating the workflow."
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -128
      ],
      "parameters": {
        "color": 5,
        "width": 272,
        "height": 304,
        "content": "### \ud83d\udd01 Adjust Frequency\nYou can modify how often the workflow checks for new emails in the Gmail Trigger node"
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -224
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 608,
        "content": "### \ud83e\uddea Tweak the AI Summary\n- Adjust the prompt in the AI Agent node to change the summary style. For example, include action items, highlight urgency, or support longer summaries.\n- Remove or update the 250-character limit in the prompt if you want more detailed outputs."
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -224
      ],
      "parameters": {
        "color": 5,
        "width": 256,
        "height": 608,
        "content": "### \ud83d\udce3 Slack Notification Tips\n\u2022 Customize Slack message format in the Send Notification to Slack node. Select the receiver. \n\u2022 You can include emojis, prefixes (e.g., \u201c\ud83d\udcec New Email\u201d), or sender-based routing if needed."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send Notification to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ],
      "ai_outputParser": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ],
      "ai_languageModel": [
        [
          {
            "node": "OpenAI Chat Model",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Email": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger on Unread Email": {
      "main": [
        [
          {
            "node": "Get Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}