{
  "id": "dbb4609124741d19",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "name": "Auto-reply to form submissions via Gmail and log to Google Sheets using OpenAI",
  "tags": [
    {
      "name": "contact-form"
    },
    {
      "name": "auto-reply"
    },
    {
      "name": "lead-capture"
    },
    {
      "name": "gmail"
    },
    {
      "name": "google-sheets"
    },
    {
      "name": "openai"
    },
    {
      "name": "automation"
    },
    {
      "name": "ai"
    }
  ],
  "nodes": [
    {
      "id": "6cfec3b6-2f52-4859-9f29-866903efa558",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -192
      ],
      "parameters": {
        "width": 480,
        "height": 640,
        "content": "## Auto-reply to form submissions via Gmail and log to Google Sheets using OpenAI\n\n## How it works\n\n1. Trigger runs on new contact form submission.\n2. Draft reply is generated using language model.\n3. Email reply is sent via Gmail.\n4. Submission is logged in Google Sheets.\n\n## Setup steps\n\n- [ ] Set up contact form trigger to start the workflow.\n- [ ] Configure OpenAI credentials to draft replies.\n- [ ] Set up Gmail account for sending auto-replies.\n- [ ] Connect Google Sheets for logging submissions.\n\n## Customization\n\nYou can customize the reply message by modifying the model's prompt settings."
      },
      "typeVersion": 1
    },
    {
      "id": "fc5fb9c5-7446-43d0-8d0b-086b839daa68",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 480,
        "content": "## Trigger and draft reply\n\nInitiates on form submission and drafts a reply using AI."
      },
      "typeVersion": 1
    },
    {
      "id": "41979f68-26f3-4abd-80de-38f913cffcfe",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        -192
      ],
      "parameters": {
        "color": 7,
        "width": 240,
        "height": 304,
        "content": "## Send auto-reply\n\nSends the drafted email reply using Gmail."
      },
      "typeVersion": 1
    },
    {
      "id": "267d7609-6ae8-4018-8b91-77c2e5a17df3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 240,
        "height": 304,
        "content": "## Log submission\n\nLogs the form submission details into Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "221dae63-7347-4b0d-aad0-5a6bfc9d5eed",
      "name": "When Form Submitted",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -40,
        0
      ],
      "parameters": {
        "options": {},
        "formTitle": "Contact Us",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Name",
              "requiredField": true
            },
            {
              "fieldType": "email",
              "fieldLabel": "Email",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Message",
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b47fae92-0fb9-4e83-b2ba-e6befe366743",
      "name": "Prepare Email Reply",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        220,
        0
      ],
      "parameters": {
        "text": "=Write a warm, helpful auto-reply email (max 120 words) that acknowledges the message and sets the expectation of a human follow-up within 1 business day. Sign as 'The Team'.\n\nName: {{ $json.Name }}\nMessage: {{ $json.Message }}",
        "promptType": "define"
      },
      "typeVersion": 1.5
    },
    {
      "id": "58cc57bf-ddae-4ac4-8e37-3b54c5c06cb1",
      "name": "OpenAI GPT-4o Mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        220,
        220
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0.4
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a4e16fc2-5a8c-47d4-b192-856cb3e8a1fc",
      "name": "Send Email via Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        608,
        -64
      ],
      "parameters": {
        "sendTo": "={{ $('When Form Submitted').item.json.Email }}",
        "message": "={{ $json.text }}",
        "options": {},
        "subject": "Thanks for reaching out!"
      },
      "typeVersion": 2.1
    },
    {
      "id": "f6c8e5af-f22b-4c39-937c-1037454a651e",
      "name": "Append to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        608,
        288
      ],
      "parameters": {
        "sheet": {
          "__rl": true,
          "mode": "list",
          "value": "Leads"
        },
        "columns": {
          "value": {},
          "mappingMode": "autoMapInputData"
        },
        "options": {},
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "https://docs.google.com/spreadsheets/d/REPLACE_ID/edit"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "OpenAI GPT-4o Mini": {
      "ai_languageModel": [
        [
          {
            "node": "Prepare Email Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Email Reply": {
      "main": [
        [
          {
            "node": "Send Email via Gmail",
            "type": "main",
            "index": 0
          },
          {
            "node": "Append to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Form Submitted": {
      "main": [
        [
          {
            "node": "Prepare Email Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}