AI駆動のメール返信システム、スパムフィルタリングとFAQ検索を統合、GPT-4o miniとPineconeを活用

中級

これはAI分野の自動化ワークフローで、13個のノードを含みます。主にIf, Gmail, GmailTool, GmailTrigger, Agentなどのノードを使用、AI技術を活用したスマート自動化を実現。 AI駆動のメール返信システム、スパムフィルタリングとFAQ検索を統合、GPT-4o miniとPineconeを活用

前提条件
  • Googleアカウント + Gmail API認証情報
  • OpenAI API Key
  • Pinecone API Key

カテゴリー

ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "eef1c32da34f97cb889cc6dbc544123406b39d27266f625630b9aa0893bf45d7"
  },
  "nodes": [
    {
      "id": "d68e1936-eec7-4334-8317-70805c95b0ab",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        140,
        180
      ],
      "parameters": {
        "text": "={{ $('get_message').item.json.text }}",
        "options": {
          "systemMessage": "You are a polite and professional virtual assistant.\n\nYou receive an email.\n\nYour knowledge base is stored in the Pinecone Vector Store, which contains all relevant FAQs and information needed to assist the user accurately.\n\nAlways consult the Pinecone Vector Store before generating your response.\n\nYour final answer must be sent using the \"Gmail\" tool.\n\nWhen using the Gmail tool, make sure to:\n\nFill in the Message field with the response content\n\nFill in the Subject field with a short subject line (you can use \"Reply\" if unsure)"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "0d136348-a945-43c0-bebe-1599f4aef1bd",
      "name": "OpenAI チャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        80,
        360
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "OTuydMANCBoed1Fr",
          "name": "OpenAi account 2"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1f6e0331-b1e0-4450-a41a-acff7f0ccae6",
      "name": "シンプルメモリ",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        240,
        360
      ],
      "parameters": {
        "sessionKey": "={{'key'}}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7af79daa-d3e0-4111-9005-0930debe0c03",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        380,
        360
      ],
      "webhookId": "f8feb0d1-c7dd-4172-8ebd-e125f18f2c4c",
      "parameters": {
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "appendAttribution": false
        },
        "emailType": "text",
        "messageId": "={{ $('get_message').item.json.id }}",
        "operation": "reply"
      },
      "typeVersion": 2.1
    },
    {
      "id": "5b1779a5-1cf5-4660-ab6f-456de5f07137",
      "name": "Gmail トリガー",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1160,
        400
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            },
            {}
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "1YbI98PAg8EdHQyr",
          "name": "total_ai_solutions"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a8fb6a4f-037f-42d0-b5a6-e14acef1bf8a",
      "name": "メッセージ取得",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -880,
        400
      ],
      "webhookId": "364e19bb-56a0-4cfe-8f89-1bedce5345ae",
      "parameters": {
        "simple": false,
        "options": {},
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "1YbI98PAg8EdHQyr",
          "name": "total_ai_solutions"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "26dd84f5-99e5-4e53-acde-ebbdf8d889d0",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1220,
        160
      ],
      "parameters": {
        "color": 3,
        "width": 1220,
        "height": 460,
        "content": "## Gmail input\n\nGmail trigger get the full email\nSpam checker is a Openai node with specific system prompt.\nIf the email is from services (google, microsoft, ecc) it considered as spam.\nIn this case the model try to extract only business emails.\nThe node print only 2 different output: \"spam\" and \"no spam\".\nIf \"spam\", nothing happen, if \"no spam\" the \"if node\" pass the message to the Agentic node"
      },
      "typeVersion": 1
    },
    {
      "id": "14915f5c-0375-46b8-90ee-c412a6b0e40c",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 540,
        "height": 620,
        "content": "## AI Agent\n\nAI Agent get the message and respond to the email autonomously in base of contest.\nHere we have a vector store too, where you can add your data, like FAQ, product prices and so on"
      },
      "typeVersion": 1
    },
    {
      "id": "09a0c5ca-6d4f-46ef-aa34-09b565f698f7",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        620
      ],
      "parameters": {
        "color": 6,
        "width": 540,
        "height": 300,
        "content": "## VECTOR STORE\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4a56b1ab-39d6-424c-a614-06febe5f5f63",
      "name": "Pinecone ベクトルストア",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        200,
        680
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "toolName": "FAQ",
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "faqmattabott",
          "cachedResultName": "faqmattabott"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "435fa9d9-cee9-4aad-a51b-25566a96b2af",
      "name": "OpenAI 埋め込み",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        60,
        800
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "OTuydMANCBoed1Fr",
          "name": "OpenAi account 2"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d0801a3b-d336-4e50-a8da-58ff218c3673",
      "name": "条件分岐",
      "type": "n8n-nodes-base.if",
      "position": [
        -280,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "921d0426-0dbf-49ac-ab67-b5538856deee",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.message.content }}",
              "rightValue": "spam"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ddea4fe7-e458-4949-aba5-57da659ab15c",
      "name": "スパムチェッカー",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -640,
        400
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a e-mail assistant. You have to check if the received e-mail are spam or not.\nYou have to check not only normal spam, but everything is not sent from a person, for example, automatic e-mail, google email, and anything out of a possible client.\n\nIf an e-mail is considered spam, as I sayd befor, your output will be \"spam\". If not, say \"no spam\".\n\nDon't respond anything else \"spam\" or \"not spam\"."
            },
            {
              "content": "={{ $json.headers.subject }}{{ $json.headers.from }}{{ $json.text }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "OTuydMANCBoed1Fr",
          "name": "OpenAi account 2"
        }
      },
      "typeVersion": 1.8
    }
  ],
  "pinData": {},
  "connections": {
    "d0801a3b-d336-4e50-a8da-58ff218c3673": {
      "main": [
        [
          {
            "node": "d68e1936-eec7-4334-8317-70805c95b0ab",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7af79daa-d3e0-4111-9005-0930debe0c03": {
      "ai_tool": [
        [
          {
            "node": "d68e1936-eec7-4334-8317-70805c95b0ab",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "d68e1936-eec7-4334-8317-70805c95b0ab": {
      "main": [
        []
      ]
    },
    "a8fb6a4f-037f-42d0-b5a6-e14acef1bf8a": {
      "main": [
        [
          {
            "node": "ddea4fe7-e458-4949-aba5-57da659ab15c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ddea4fe7-e458-4949-aba5-57da659ab15c": {
      "main": [
        [
          {
            "node": "d0801a3b-d336-4e50-a8da-58ff218c3673",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5b1779a5-1cf5-4660-ab6f-456de5f07137": {
      "main": [
        [
          {
            "node": "a8fb6a4f-037f-42d0-b5a6-e14acef1bf8a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1f6e0331-b1e0-4450-a41a-acff7f0ccae6": {
      "ai_memory": [
        [
          {
            "node": "d68e1936-eec7-4334-8317-70805c95b0ab",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "435fa9d9-cee9-4aad-a51b-25566a96b2af": {
      "ai_embedding": [
        [
          {
            "node": "4a56b1ab-39d6-424c-a614-06febe5f5f63",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "0d136348-a945-43c0-bebe-1599f4aef1bd": {
      "ai_languageModel": [
        [
          {
            "node": "d68e1936-eec7-4334-8317-70805c95b0ab",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "4a56b1ab-39d6-424c-a614-06febe5f5f63": {
      "ai_tool": [
        [
          {
            "node": "d68e1936-eec7-4334-8317-70805c95b0ab",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

中級 - 人工知能

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
中級
ノード数13
カテゴリー1
ノードタイプ11
難易度説明

経験者向け、6-15ノードの中程度の複雑さのワークフロー

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34