予備モデルを使った最初のメールエージェントを構築する

中級

これはTicket Management, AI Chatbot分野の自動化ワークフローで、11個のノードを含みます。主にGmail, GmailTrigger, Agent, GoogleSheetsTool, LmChatOpenAiなどのノードを使用。 最初の自動化されたメールサポートエージェントを構築する(AIバックアップとログ記録を含む)

前提条件
  • Googleアカウント + Gmail API認証情報
  • Google Sheets API認証情報
  • OpenAI API Key
  • Google Gemini API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "e63GF6KHkhFUFKfz",
  "meta": {
    "instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc",
    "templateCredsSetupCompleted": true
  },
  "name": "Build your first email agent with fall back model",
  "tags": [],
  "nodes": [
    {
      "id": "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        288,
        0
      ],
      "parameters": {
        "text": "={{ $json.Subject }} {{ $json.snippet }}",
        "options": {
          "systemMessage": "\n## Primary Role\nYou are a professional customer support AI agent that processes incoming Gmail messages, provides helpful responses to customers, and logs all support requests for tracking purposes.\n\n## Core Responsibilities\n\n### 1. Email Analysis & Response\n- **Read and analyze** each incoming email carefully\n- **Identify the type of request**: technical issue, billing question, feature request, complaint, general inquiry, etc.\n- **Determine urgency level**: Low, Medium, High, Critical\n- **Extract key information**: customer details, issue description, requested action, timeline expectations\n\n### 2. Customer Reply Generation\nGenerate professional, helpful, and empathetic email responses that:\n- **Acknowledge** the customer's concern promptly\n- **Provide clear solutions** or next steps when possible\n- **Set appropriate expectations** for resolution timeline\n- **Maintain a friendly, professional tone**\n- **Include relevant resources** (links, documentation, FAQs) when helpful\n- **Ask clarifying questions** if more information is needed\n- **Escalate to human support** when issues are complex or sensitive\n\n### 3. Google Sheets Logging\nFor every email processed, log the following information:\n- **Date/Time**: When the email was received\n- **Customer Email**: Sender's email address\n- **Customer Name**: If available\n- **Subject Line**: Email subject\n- **Request Type**: Category (Technical, Billing, Feature Request, etc.)\n- **Priority Level**: Low/Medium/High/Critical\n- **Issue Summary**: Brief description (2-3 sentences max)\n- **Status**: New/In Progress/Resolved/Escalated\n- **Response Sent**: Yes/No\n- **Follow-up Required**: Yes/No/Date\n- **Agent Notes**: Any additional context or actions taken\n\n## Response Templates & Guidelines\n\n### Standard Greeting\n\"Hi [Customer Name],\n\nThank you for reaching out to us. I've received your message regarding [brief issue summary].\"\n\n### Common Scenarios\n\n**Technical Issues:**\n- Acknowledge the frustration\n- Provide step-by-step troubleshooting\n- Offer alternative solutions\n- Set expectations for resolution\n\n**Billing Questions:**\n- Confirm account details (without exposing sensitive info)\n- Explain charges clearly\n- Provide next steps for disputes\n- Include relevant billing resources\n\n**Feature Requests:**\n- Thank them for the suggestion\n- Explain current roadmap (if applicable)\n- Suggest workarounds if available\n- Confirm request has been logged for product team\n\n**Complaints:**\n- Acknowledge their concern with empathy\n- Take responsibility where appropriate\n- Outline steps to resolve\n- Offer compensation if warranted\n\n### Escalation Criteria\nEscalate to human support when:\n- Customer is extremely upset or threatening\n- Issue involves sensitive account information\n- Technical problem requires developer intervention\n- Billing dispute over significant amount\n- Legal or compliance matters\n- Multiple failed resolution attempts\n\n### Tone Guidelines\n- **Professional** yet conversational\n- **Empathetic** and understanding\n- **Clear** and concise\n- **Proactive** in offering solutions\n- **Apologetic** when appropriate (without admitting fault unnecessarily)\n\n## Memory & Context Management\n- **Remember** previous interactions with the same customer\n- **Reference** past solutions or conversations when relevant\n- **Track** ongoing issues to ensure continuity\n- **Note** customer preferences or special circumstances\n\n## Quality Standards\n- **Response time**: Aim for acknowledgment within 1 hour during business hours\n- **Accuracy**: Ensure all information provided is correct and up-to-date\n- **Completeness**: Address all questions/concerns in the customer's email\n- **Follow-up**: Set reminders for promised callbacks or updates\n\n## Example Response Format\n\nSubject: Re: [Original Subject] - We're here to help!\n\nHi [Customer Name],\n\nThank you for contacting us about [issue]. I understand [acknowledge their concern/situation].\n\n[Provide solution/next steps/information requested]\n\n[If applicable: set expectations, provide timeline, or explain next steps]\n\nIs there anything else I can help you with today? We're always here to support you.\n\nBest regards,\n[Your Name]\nCustomer Support Team\n\n---\n\n**Note**: Always maintain customer privacy and confidentiality. Never share sensitive information inappropriately, and ensure all logging complies with data protection standards."
        },
        "promptType": "define",
        "needsFallback": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "a2a87327-902b-4f95-b819-25221793fb77",
      "name": "Gmailトリガー",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -32,
        0
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "LVRUgE95PAvkE1Mc",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "06d647bb-b03d-42bf-8462-204546d3b427",
      "name": "シンプルメモリ",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        384,
        256
      ],
      "parameters": {
        "sessionKey": "={{ $('Gmail Trigger').item.json.id }}",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "4ce6dbd6-e68a-4e86-92db-4ed5c9b362b4",
      "name": "Googleシートに行を追加または更新",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        528,
        256
      ],
      "parameters": {
        "columns": {
          "value": {
            "email address ": "={{ $('Gmail Trigger').item.json.To }}"
          },
          "schema": [
            {
              "id": "customer_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "customer_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email address ",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email address ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Service type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Service type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "appointment date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "appointment date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "estimated duration",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "estimated duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "estimated price",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "estimated price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "stylist name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "stylist name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "hair length",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "hair length",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone number ",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "phone number ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "customer_name"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KFjFpYS9akNv_I-JcQKMQVBT-rXYfK2sC4dP6QYpcp4/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1KFjFpYS9akNv_I-JcQKMQVBT-rXYfK2sC4dP6QYpcp4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KFjFpYS9akNv_I-JcQKMQVBT-rXYfK2sC4dP6QYpcp4/edit?usp=drivesdk",
          "cachedResultName": "SUPPORT LOG "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "vL25dYTf9oT1CSvl",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "4310966d-894d-490b-9d52-49c1aa03b9ae",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        -352
      ],
      "parameters": {
        "width": 768,
        "height": 848,
        "content": "# 🤖 Your First Email Agent with Fallback Model\n\n## 📧 What This Workflow Does\nThis automation creates an intelligent email support system that:\n- **Monitors Gmail** for new customer emails\n- **Processes requests** using AI with smart fallback options\n- **Sends personalized replies** automatically\n- **Logs everything** to Google Sheets for tracking\n\n## 🔄 How the Fallback Model Works\n\n### Primary Model: Google Gemini Chat\n- **Fast & Cost-Effective** - Handles 90% of standard support queries\n- **Great for**: FAQ responses, basic troubleshooting, general inquiries\n\n### Fallback Model: OpenAI GPT\n- **Kicks in when** Gemini fails or encounters complex queries\n- **Better for**: Nuanced responses, technical issues, edge cases\n- **Higher accuracy** for complex customer situations\n\n## 🏗️ Workflow Architecture\n\n```\nGmail Trigger → AI Agent → Response Decision → Actions\n                   ↓\n            [Primary Model]\n                   ↓\n            [Fallback Model] ← (if needed)\n                   ↓\n         [Send Reply + Log Data]\n```\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ddc5d69b-8386-45e1-9b7f-139e5b42c15f",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        -512
      ],
      "parameters": {
        "width": 640,
        "height": 1360,
        "content": "\n## 💡 Why Use a Fallback Model?\n\n### Reliability\n- **99.9% uptime** - If one model fails, the other continues\n- **No missed emails** - Every customer gets a response\n\n### Cost Optimization\n- **Use cheaper models first** (Gemini) for simple queries\n- **Reserve premium models** (GPT-4) for complex cases\n- **Reduce API costs** by 60-80%\n\n### Quality Assurance\n- **Best of both worlds** - Speed + accuracy\n- **Consistent responses** even during API outages\n- **Improved customer satisfaction**\n\n\n## 🚀 Getting Started Checklist\n\n- [ ] **Gmail account** with API access enabled\n- [ ] **Google Sheets** document created\n- [ ] **Gemini API key** (primary model)\n- [ ] **OpenAI API key** (fallback model)\n- [ ] **N8N instance** running\n- [ ] **Import this workflow** and configure credentials\n\n## 📊 What Gets Logged\n- Customer email & timestamp\n- Request type & priority level\n- Which AI model responded\n- Response time & success rate\n- Follow-up requirements\n\n## 🔧 Customization Options\n- **Modify response templates** for your brand voice\n- **Add more fallback models** (Claude, etc.)\n- **Create custom triggers** (Slack, Discord, etc.)\n- **Build escalation rules** for human handoff\n\n## 💭 Learning Outcomes\nAfter building this workflow, you'll understand:\n- **AI model orchestration** strategiess  \n- **Customer service** automation best practices\n- **Multi-model AI** implementation patterns\n\n---\n\n\n\n**🎓 Educational Focus**: This isn't just automation - it's your introduction to building resilient, intelligent systems that handle real-world business challenges."
      },
      "typeVersion": 1
    },
    {
      "id": "08ff7ff4-4c41-43e9-a71d-43e07f0c75e4",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -448
      ],
      "parameters": {
        "width": 464,
        "height": 448,
        "content": "## 🎯 Perfect for Beginners Because:\n\n### Simple Setup\n- **Drag & drop** workflow design\n- **Pre-built integrations** with Gmail & Sheets\n- **Copy-paste ready** - Just add your API keys\n\n### Educational Value\n- **Learn AI orchestration** concepts\n- **Understand fallback patterns** in automation\n- **See real-world AI applications** in action\n\n### Immediate Results\n- **Works out of the box** with minimal configuration\n- **See responses** within minutes of setup\n- **Track performance** in Google Sheets dashboard\n"
      },
      "typeVersion": 1
    },
    {
      "id": "99dd9b98-5384-498e-b3e5-2552bb7016b0",
      "name": "OpenAIモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -96,
        288
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "BXMUxnyGzjtZQOK4",
          "name": "OpenAi account Dave"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b91e9199-c9cd-4dc6-bd8e-9a97aad2f9c4",
      "name": "Geminiチャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -192,
        272
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "OCsJdRrt1Xxv1ZGe",
          "name": "paid google console"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b56d1d13-8b88-4a69-b0d9-c2c35e6f95da",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        176
      ],
      "parameters": {
        "height": 224,
        "content": "## Ai Models"
      },
      "typeVersion": 1
    },
    {
      "id": "9ecaa23a-40af-4d5f-80ef-a6df1dc9acf9",
      "name": "メッセージへの返信(スレッド)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        784,
        0
      ],
      "webhookId": "c3d3ef78-4b9a-4392-8b21-497aa09e33af",
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {},
        "resource": "thread",
        "threadId": "={{ $('Gmail Trigger').item.json.id }}",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "LVRUgE95PAvkE1Mc",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "51d6850a-e062-4209-b0d3-e6f4d5f0eb05",
  "connections": {
    "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68": {
      "main": [
        [
          {
            "node": "9ecaa23a-40af-4d5f-80ef-a6df1dc9acf9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a2a87327-902b-4f95-b819-25221793fb77": {
      "main": [
        [
          {
            "node": "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "99dd9b98-5384-498e-b3e5-2552bb7016b0": {
      "ai_languageModel": [
        [
          {
            "node": "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "06d647bb-b03d-42bf-8462-204546d3b427": {
      "ai_memory": [
        [
          {
            "node": "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "b91e9199-c9cd-4dc6-bd8e-9a97aad2f9c4": {
      "ai_languageModel": [
        [
          {
            "node": "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "4ce6dbd6-e68a-4e86-92db-4ed5c9b362b4": {
      "ai_tool": [
        [
          {
            "node": "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

中級 - チケット管理, AIチャットボット

有料ですか?

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

関連ワークフロー

AI駆動型カスタマーサポート:メール、ナレッジベース、リ Humanアップグレードの自動化
AIメールサポートシステム:Gmail、Gemini、GPT-4、Slack、Google Sheetsを統合したワークフロー
Set
Gmail
Slack
+
Set
Gmail
Slack
26 ノードDavid Olusola
チケット管理
Airtable、Gmail、OpenAI を使って顧客メールを自動返信
Airtable、Gmail、GPT-4.1 Mini を使って注文メールを自動で返信する
Gmail
Airtable
Gmail Trigger
+
Gmail
Airtable
Gmail Trigger
12 ノードBaptiste Fort
チケット管理
ジェミニ2.0フラッシュAIとGoogleスプレッドシートを活用した会話型リードキャプチャ
Gemini 2.0 Flash AI と Google Sheets を基にした対話型リードキャプチャー
Webhook
Agent
Google Sheets Tool
+
Webhook
Agent
Google Sheets Tool
10 ノードDavid Olusola
リード獲得
WhatsApp / Telegram WooCommerce注文サポート
Telegram と Gmail を使用したGemini と GPT を使用した WooCommerce カスタマーサポートの自動化
Set
Gmail
Merge
+
Set
Gmail
Merge
25 ノードAppStoneLab Technologies LLP
サポートチャットボット
マイワークフロー2
複数のGPT-4o AIエージェントで個人データを管理する:Telegram上のGmail、タスク、財務
Set
Code
Gmail
+
Set
Code
Gmail
62 ノードMahmoud Shrouf
AIチャットボット
Gmail からの自動返信と Linear チケット作成(GPT-5、gotoHuman、人間審査使用)
Gmailから自動返信し、Linearチケットを作成するためにGPT-5、gotoHuman、および人間の承認を使用
Set
Code
Gmail
+
Set
Code
Gmail
37 ノードgotoHuman
チケット管理
ワークフロー情報
難易度
中級
ノード数11
カテゴリー2
ノードタイプ8
難易度説明

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

作成者
David Olusola

David Olusola

@dae221

I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34