AutomationFlowsEmail & Gmail › AI-Powered Gmail Auto-Reply Workflow

AI-Powered Gmail Auto-Reply Workflow

Original n8n title: Code (open Ai)

Code. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.

Event trigger★★★★★ complexityAI-powered49 nodesOpenAIGmail TriggerGmailCryptoGoogle Sheets
Email & Gmail Trigger: Event Nodes: 49 Complexity: ★★★★★ AI nodes: yes Added:

This workflow follows the Gmail → Gmail Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "88c0f64c-a7cd-4f35-96dd-9eee4b1d6a1a",
      "name": "Generate reply",
      "type": "n8n-nodes-base.openAi",
      "position": [
        -480,
        2260
      ],
      "parameters": {
        "prompt": "=From: {{ $json.from.value }}\nTo: {{ $json.to.value }}\nSubject: {{ $json.subject }}\nBody: {{ $json.reply }}\n\n\nReply: ",
        "options": {
          "maxTokens": "={{ $('Configure').first().json.replyTokenSize }}"
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7105b689-9f9c-4354-aad9-8f1abb6c0a06",
      "name": "On email received",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -2460,
        2680
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ea18ed9a-0158-45e1-ac1b-1993ace4ff2c",
      "name": "Only continue for specific emails",
      "type": "n8n-nodes-base.if",
      "position": [
        -1360,
        2460
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $('Configure').first().json.recipients.split(',') }}",
              "value2": "*",
              "operation": "contains"
            },
            {
              "value1": "={{ $('Configure').first().json.recipients.split(',') }}",
              "value2": "={{ $json.from.value[0].address }}",
              "operation": "contains"
            }
          ]
        },
        "combineOperation": "any"
      },
      "typeVersion": 1
    },
    {
      "id": "d1425dff-0fc1-4a4b-9202-418ce30d7cd9",
      "name": "Configure",
      "type": "n8n-nodes-base.set",
      "position": [
        -1940,
        2800
      ],
      "parameters": {
        "values": {
          "number": [
            {
              "name": "maxTokenSize",
              "value": 4000
            },
            {
              "name": "replyTokenSize",
              "value": 300
            }
          ],
          "string": [
            {
              "name": "spreadsheetId"
            },
            {
              "name": "worksheetId"
            },
            {
              "name": "spreadsheetName",
              "value": "ChatGPT responses"
            },
            {
              "name": "worksheetName",
              "value": "Database"
            },
            {
              "name": "recipients",
              "value": "[UPDATE ME]"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "594f77e6-9e7e-4e93-b6e0-95fad57e42f0",
      "name": "Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2060,
        2480
      ],
      "parameters": {
        "width": 330.0279884670691,
        "height": 929.4540475960038,
        "content": "### Configuration\nIf you decide to use your own spreadsheet, it is up to you to ensure all columns are present before running this workflow. A good way to do this is to run this workflow once with **empty** `spreadsheetid` and `worksheetId` variables (see the `Configure` node). Then map the output from `Store spreadsheet ID` to this node.\n\nIt is recommended that you specify the `spreadsheetId` and `worksheetId`, since relying solely on a workflow's static data is considered bad practice.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n__`spreadsheetId`__: The ID of the spreadsheet where Pipedrive deals will be stored.\n__`worksheetId`__: The ID of the worksheet where Pipedrive deals will be stored.\n__`spreadsheetName`(required)__: The human readable name of the spreadsheet where Pipedrive deals will be stored.\n__`worksheetName`(required)__: The human readable name of the worksheet in the spreadsheet where Pipedrive deals will be stored.\n__`recipients`(required)__: Comma-separated list of email recipients to send ChatGPT emails to. Use `*` to send ChatGPT response to every email address.\n__`maxTokenSize`(required)__: The maximum token size for the model you choose. See possible models from OpenAI [here](https://platform.openai.com/docs/models/gpt-3).\n__`replyTokenSize`(required)__: The reply's maximum token size. Default is 300. This determines how much text the AI will reply with."
      },
      "typeVersion": 1
    },
    {
      "id": "2dc3e403-f2a0-43c2-a1e4-187d901d692f",
      "name": "Send reply to recipient",
      "type": "n8n-nodes-base.gmail",
      "position": [
        360,
        1860
      ],
      "parameters": {
        "message": "={{ $json.html }}",
        "options": {},
        "emailType": "html",
        "messageId": "={{ $node[\"On email received\"].json.id }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f845aa4d-5542-4126-a42d-4e5afa1893d1",
      "name": "Generate UUID",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -1140,
        2360
      ],
      "parameters": {
        "action": "generate",
        "dataPropertyName": "uuid"
      },
      "typeVersion": 1
    },
    {
      "id": "3c468585-4546-439b-9e8a-efb7231277d8",
      "name": "Thanks for your response!",
      "type": "n8n-nodes-base.html",
      "position": [
        -1140,
        2980
      ],
      "parameters": {
        "html": "<!DOCTYPE html>\n\n<html>\n<head>\n <meta charset=\"UTF-8\" />\n <title>Thanks for your response!</title>\n</head>\n<body>\n <div class=\"container\">\n <h1>Thanks for your response!</h1>\n <h2>You can safely close this window.</h2>\n </div>\n</body>\n</html>\n\n<style>\n.container {\n background-color: #ffffff;\n text-align: center;\n padding: 16px;\n border-radius: 8px;\n}\n\nh1 {\n color: #ff6d5a;\n font-size: 24px;\n font-weight: bold;\n padding: 8px;\n}\n\nh2 {\n color: #909399;\n font-size: 18px;\n font-weight: bold;\n padding: 8px;\n}\n</style>\n\n<script>\nconsole.log(\"Hello World!\");\n</script>"
      },
      "typeVersion": 1
    },
    {
      "id": "6b0bfa33-84ca-4b9c-98ec-c1bc08a1230d",
      "name": "Extract message content (advanced)",
      "type": "n8n-nodes-base.code",
      "position": [
        -920,
        2360
      ],
      "parameters": {
        "jsCode": "// source: https://gist.github.com/ikbelkirasan/2462073f6c7c760faa6fad7c6a0c4dc3\nvar EmailParser=function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&\"object\"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,\"default\",{enumerable:!0,value:t}),2&r&&\"string\"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,\"a\",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p=\"\",n(n.s=59)}([function(t,r){var n=Array.isArray;t.exports=n},function(t,r,n){var e=n(31),o=\"object\"==typeof self&&self&&self.Object===Object&&self,u=e||o||Function(\"return this\")();t.exports=u},function(t,r,n){var e=n(74),o=n(79);t.exports=function(t,r){var n=o(t,r);return e(n)?n:void 0}},function(t,r){t.exports=function(t){return null!=t&&\"object\"==typeof t}},function(t,r){t.exports=function(t){var r=typeof t;return null!=t&&(\"object\"==r||\"function\"==r)}},function(t,r,n){var e=n(6),o=n(75),u=n(76),i=e?e.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?\"[object Undefined]\":\"[object Null]\":i&&i in Object(t)?o(t):u(t)}},function(t,r,n){var e=n(1).Symbol;t.exports=e},function(t,r,n){var e=n(35),o=n(99),u=n(14);t.exports=function(t){return u(t)?e(t):o(t)}},function(t,r,n){var e=n(64),o=n(65),u=n(66),i=n(67),c=n(68);function a(t){var r=-1,n=null==t?0:t.length;for(this.clear();++r<n;){var e=t[r];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=u,a.prototype.has=i,a.prototype.set=c,t.exports=a},function(t,r,n){var e=n(18);t.exports=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}},function(t,r,n){var e=n(2)(Object,\"create\");t.exports=e},function(t,r,n){var e=n(88);t.exports=function(t,r){var n=t.__data__;return e(r)?n[\"string\"==typeof r?\"string\":\"hash\"]:n.map}},function(t,r,n){var e=n(33),o=n(34);t.exports=function(t,r,n,u){var i=!n;n||(n={});for(var c=-1,a=r.length;++c<a;){var s=r[c],f=u?u(n[s],t[s],s,n,t):void 0;void 0===f&&(f=t[s]),i?o(n,s,f):e(n,s,f)}return n}},function(t,r){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,\"loaded\",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,\"id\",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,r,n){var e=n(30),o=n(22);t.exports=function(t){return null!=t&&o(t.length)&&!e(t)}},function(t,r,n){var e=n(109),o=n(19),u=n(110),i=n(111),c=n(112),a=n(5),s=n(32),f=s(e),p=s(o),l=s(u),v=s(i),b=s(c),h=a;(e&&\"[object DataView]\"!=h(new e(new ArrayBuffer(1)))||o&&\"[object Map]\"!=h(new o)||u&&\"[object Promise]\"!=h(u.resolve())||i&&\"[object Set]\"!=h(new i)||c&&\"[object WeakMap]\"!=h(new c))&&(h=function(t){var r=a(t),n=\"[object Object]\"==r?t.constructor:void 0,e=n?s(n):\"\";if(e)switch(e){case f:return\"[object DataView]\";case p:return\"[object Map]\";case l:return\"[object Promise]\";case v:return\"[object Set]\";case b:return\"[object WeakMap]\"}return r}),t.exports=h},function(t,r,n){var e=n(29);t.exports=function(t){if(\"string\"==typeof t||e(t))return t;var r=t+\"\";return\"0\"==r&&1/t==-1/0?\"-0\":r}},function(t,r,n){var e=n(8),o=n(69),u=n(70),i=n(71),c=n(72),a=n(73);function s(t){var r=this.__data__=new e(t);this.size=r.size}s.prototype.clear=o,s.prototype.delete=u,s.prototype.get=i,s.prototype.has=c,s.prototype.set=a,t.exports=s},function(t,r){t.exports=function(t,r){return t===r||t!=t&&r!=r}},function(t,r,n){var e=n(2)(n(1),\"Map\");t.exports=e},function(t,r,n){var e=n(80),o=n(87),u=n(89),i=n(90),c=n(91);function a(t){var r=-1,n=null==t?0:t.length;for(this.clear();++r<n;){var e=t[r];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=u,a.prototype.has=i,a.prototype.set=c,t.exports=a},function(t,r,n){(function(t){var e=n(1),o=n(97),u=r&&!r.nodeType&&r,i=u&&\"object\"==typeof t&&t&&!t.nodeType&&t,c=i&&i.exports===u?e.Buffer:void 0,a=(c?c.isBuffer:void 0)||o;t.exports=a}).call(this,n(13)(t))},function(t,r){t.exports=function(t){return\"number\"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},function(t,r){t.exports=function(t){return function(r){return t(r)}}},function(t,r,n){(function(t){var e=n(31),o=r&&!r.nodeType&&r,u=o&&\"object\"==typeof t&&t&&!t.nodeType&&t,i=u&&u.exports===o&&e.process,c=function(){try{var t=u&&u.require&&u.require(\"util\").types;return t||i&&i.binding&&i.binding(\"util\")}catch(t){}}();t.exports=c}).call(this,n(13)(t))},function(t,r){var n=Object.prototype;t.exports=function(t){var r=t&&t.constructor;return t===(\"function\"==typeof r&&r.prototype||n)}},function(t,r,n){var e=n(41),o=n(42),u=Object.prototype.propertyIsEnumerable,i=Object.getOwnPropertySymbols,c=i?function(t){return null==t?[]:(t=Object(t),e(i(t),(function(r){return u.call(t,r)})))}:o;t.exports=c},function(t,r,n){var e=n(48);t.exports=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}},function(t,r,n){var e=n(0),o=n(29),u=/\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/,i=/^\\w*$/;t.exports=function(t,r){if(e(t))return!1;var n=typeof t;return!(\"number\"!=n&&\"symbol\"!=n&&\"boolean\"!=n&&null!=t&&!o(t))||(i.test(t)||!u.test(t)||null!=r&&t in Object(r))}},function(t,r,n){var e=n(5),o=n(3);t.exports=function(t){return\"symbol\"==typeof t||o(t)&&\"[object Symbol]\"==e(t)}},function(t,r,n){var e=n(5),o=n(4);t.exports=function(t){if(!o(t))return!1;var r=e(t);return\"[object Function]\"==r||\"[object GeneratorFunction]\"==r||\"[object AsyncFunction]\"==r||\"[object Proxy]\"==r}},function(t,r){var n=\"object\"==typeof global&&global&&global.Object===Object&&global;t.exports=n},function(t,r){var n=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return n.call(t)}catch(t){}try{return t+\"\"}catch(t){}}return\"\"}},function(t,r,n){var e=n(34),o=n(18),u=Object.prototype.hasOwnProperty;t.exports=function(t,r,n){var i=t[r];u.call(t,r)&&o(i,n)&&(void 0!==n||r in t)||e(t,r,n)}},function(t,r,n){var e=n(93);t.exports=function(t,r,n){\"__proto__\"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}},function(t,r,n){var e=n(95),o=n(36),u=n(0),i=n(21),c=n(37),a=n(38),s=Object.prototype.hasOwnProperty;t.exports=function(t,r){var n=u(t),f=!n&&o(t),p=!n&&!f&&i(t),l=!n&&!f&&!p&&a(t),v=n||f||p||l,b=v?e(t.length,String):[],h=b.length;for(var y in t)!r&&!s.call(t,y)||v&&(\"length\"==y||p&&(\"offset\"==y||\"parent\"==y)||l&&(\"buffer\"==y||\"byteLength\"==y||\"byteOffset\"==y)||c(y,h))||b.push(y);return b}},function(t,r,n){var e=n(96),o=n(3),u=Object.prototype,i=u.hasOwnProperty,c=u.propertyIsEnumerable,a=e(function(){return arguments}())?e:function(t){return o(t)&&i.call(t,\"callee\")&&!c.call(t,\"callee\")};t.exports=a},function(t,r){var n=/^(?:0|[1-9]\\d*)$/;t.exports=function(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&(\"number\"==e||\"symbol\"!=e&&n.test(t))&&t>-1&&t%1==0&&t<r}},function(t,r,n){var e=n(98),o=n(23),u=n(24),i=u&&u.isTypedArray,c=i?o(i):e;t.exports=c},function(t,r){t.exports=function(t,r){return function(n){return t(r(n))}}},function(t,r,n){var e=n(35),o=n(102),u=n(14);t.exports=function(t){return u(t)?e(t,!0):o(t)}},function(t,r){t.exports=function(t,r){for(var n=-1,e=null==t?0:t.length,o=0,u=[];++n<e;){var i=t[n];r(i,n,t)&&(u[o++]=i)}return u}},function(t,r){t.exports=function(){return[]}},function(t,r,n){var e=n(44),o=n(45),u=n(26),i=n(42),c=Object.getOwnPropertySymbols?function(t){for(var r=[];t;)e(r,u(t)),t=o(t);return r}:i;t.exports=c},function(t,r){t.exports=function(t,r){for(var n=-1,e=r.length,o=t.length;++n<e;)t[o+n]=r[n];return t}},function(t,r,n){var e=n(39)(Object.getPrototypeOf,Object);t.exports=e},function(t,r,n){var e=n(47),o=n(26),u=n(7);t.exports=function(t){return e(t,u,o)}},function(t,r,n){var e=n(44),o=n(0);t.exports=function(t,r,n){var u=r(t);return o(t)?u:e(u,n(t))}},function(t,r,n){var e=n(1).Uint8Array;t.exports=e},function(t,r,n){var e=n(41),o=n(125),u=n(51),i=n(0);t.exports=function(t,r){return(i(t)?e:o)(t,u(r,3))}},function(t,r,n){var e=n(126),o=n(129)(e);t.exports=o},function(t,r,n){var e=n(130),o=n(143),u=n(153),i=n(0),c=n(154);t.exports=function(t){return\"function\"==typeof t?t:null==t?u:\"object\"==typeof t?i(t)?o(t[0],t[1]):e(t):c(t)}},function(t,r,n){var e=n(132),o=n(3);t.exports=function t(r,n,u,i,c){return r===n||(null==r||null==n||!o(r)&&!o(n)?r!=r&&n!=n:e(r,n,u,i,t,c))}},function(t,r,n){var e=n(133),o=n(136),u=n(137);t.exports=function(t,r,n,i,c,a){var s=1&n,f=t.length,p=r.length;if(f!=p&&!(s&&p>f))return!1;var l=a.get(t);if(l&&a.get(r))return l==r;var v=-1,b=!0,h=2&n?new e:void 0;for(a.set(t,r),a.set(r,t);++v<f;){var y=t[v],x=r[v];if(i)var d=s?i(x,y,v,r,t,a):i(y,x,v,t,r,a);if(void 0!==d){if(d)continue;b=!1;break}if(h){if(!o(r,(function(t,r){if(!u(h,r)&&(y===t||c(y,t,n,i,a)))return h.push(r)}))){b=!1;break}}else if(y!==x&&!c(y,x,n,i,a)){b=!1;break}}return a.delete(t),a.delete(r),b}},function(t,r,n){var e=n(4);t.exports=function(t){return t==t&&!e(t)}},function(t,r){t.exports=function(t,r){return function(n){return null!=n&&(n[t]===r&&(void 0!==r||t in Object(n)))}}},function(t,r,n){var e=n(57),o=n(16);t.exports=function(t,r){for(var n=0,u=(r=e(r,t)).length;null!=t&&n<u;)t=t[o(r[n++])];return n&&n==u?t:void 0}},function(t,r,n){var e=n(0),o=n(28),u=n(145),i=n(148);t.exports=function(t,r){return e(t)?t:o(t,r)?[t]:u(i(t))}},function(t,r){t.exports=function(t,r){for(var n=-1,e=null==t?0:t.length,o=Array(e);++n<e;)o[n]=r(t[n],n,t);return o}},function(t,r,n){var e=n(60);t.exports=function(t,r){var n=(new e).parse(t);return r?n?n.getVisibleText():\"\":n}},function(t,r,n){var e=n(61),o=n(159),u=n(160),i=n(49),c=n(161);const a=/(?:^\\s*--|^\\s*__|^-\\w|^-- $)|(?:^Sent from my (?:\\s*\\w+){1,4}$)|(?:^={30,}$)$/,s=/>+$/,f=[/^\\s*(On(?:(?!.*On\\b|\\bwrote:)[\\s\\S])+wrote:)$/m,/^\\s*(Le(?:(?!.*Le\\b|\\b\u00e9crit:)[\\s\\S])+\u00e9crit :)$/m,/^\\s*(El(?:(?!.*El\\b|\\bescribi\u00f3:)[\\s\\S])+escribi\u00f3:)$/m,/^\\s*(Il(?:(?!.*Il\\b|\\bscritto:)[\\s\\S])+scritto:)$/m,/^\\s*(Op\\s[\\S\\s]+?schreef[\\S\\s]+:)$/m,/^\\s*((W\\sdniu|Dnia)\\s[\\S\\s]+?(pisze|napisa\u0142(\\(a\\))?):)$/mu,/^\\s*(Den\\s.+\\sskrev\\s.+:)$/m,/^\\s*(Am\\s.+\\sum\\s.+\\sschrieb\\s.+:)$/m,/^(\u5728[\\S\\s]+\u5199\u9053\uff1a)$/m,/^(20[0-9]{2}\\..+\\s\uc791\uc131:)$/m,/^(20[0-9]{2}\\/.+\u306e\u30e1\u30c3\u30bb\u30fc\u30b8:)$/m,/^(.+\\s<.+>\\sschrieb:)$/m,/^\\s*(From\\s?:.+\\s?(\\[|<).+(\\]|>))/mu,/^\\s*(De\\s?:.+\\s?(\\[|<).+(\\]|>))/mu,/^\\s*(Van\\s?:.+\\s?(\\[|<).+(\\]|>))/mu,/^\\s*(Da\\s?:.+\\s?(\\[|<).+(\\]|>))/mu,/^(20[0-9]{2}-(?:0?[1-9]|1[012])-(?:0?[0-9]|[1-2][0-9]|3[01]|[1-9])\\s[0-2]?[0-9]:\\d{2}\\s[\\S\\s]+?:)$/m,/^\\s*([a-z]{3,4}\\.[\\s\\S]+\\sskrev[\\s\\S]+:)$/m];\n/**\n * Represents a fragment that hasn't been constructed (yet)\n * @license MIT License\n */\nclass p{constructor(){this.lines=[],this.isHidden=!1,this.isSignature=!1,this.isQuoted=!1}toFragment(){var t=c.reverse(this.lines.join(\"\\n\")).replace(/^\\n/,\"\");return new o(t,this.isHidden,this.isSignature,this.isQuoted)}}t.exports=class{constructor(t,r,n){this._signatureRegex=t||a,this._quotedLineRegex=r||s,this._quoteHeadersRegex=n||f}parse(t){if(\"string\"!=typeof t)return new e([]);var r=[];for(var n of(t=t.replace(\"\\r\\n\",\"\\n\"),this._quoteHeadersRegex)){var o=t.match(n);o&&o.length>=2&&(t=t.replace(o[1],o[1].replace(/\\n/g,\" \")))}var i=null;for(var a of c.reverse(t).split(\"\\n\")){if(a=a.replace(/\\n+$/,\"\"),this._isSignature(a)||(a=a.replace(/^\\s+/,\"\")),i){var s=i.lines[i.lines.length-1];this._isSignature(s)?(i.isSignature=!0,this._addFragment(i,r),i=null):0===a.length&&this._isQuoteHeader(s)&&(i.isQuoted=!0,this._addFragment(i,r),i=null)}var f=this._isQuote(a);null!==i&&this._isFragmentLine(i,a,f)||(i&&this._addFragment(i,r),(i=new p).isQuoted=f),i.lines.push(a)}i&&this._addFragment(i,r);var l=[];for(var v of r)l.push(v.toFragment());return new e(u(l))}_addFragment(t,r){(t.isQuoted||t.isSignature||0===t.lines.join(\"\").length)&&(t.isHidden=!0),r.push(t)}_isFragmentLine(t,r,n){return t.isQuoted===n||!!t.isQuoted&&(this._isQuoteHeader(r)||0===r.length)}_isSignature(t){return this._signatureRegex.test(c.reverse(t))}_isQuote(t){return this._quotedLineRegex.test(t)}_isQuoteHeader(t){return i(this._quoteHeadersRegex,r=>r.test(c.reverse(t))).length>0}}},function(t,r,n){var e=n(62),o=n(49),u=n(157);t.exports=class{constructor(t){this._fragments=t}getFragments(){return e(this._fragments)}getVisibleText(){var t=o(this._fragments,t=>!t.isHidden());return u(t,t=>t.getContent()).join(\"\\n\")}}},function(t,r,n){var e=n(63);t.exports=function(t){return e(t,5)}},function(t,r,n){var e=n(17),o=n(92),u=n(33),i=n(94),c=n(101),a=n(104),s=n(105),f=n(106),p=n(107),l=n(46),v=n(108),b=n(15),h=n(113),y=n(114),x=n(119),d=n(0),j=n(21),_=n(121),g=n(4),m=n(123),O=n(7),w={};w[\"[object Arguments]\"]=w[\"[object Array]\"]=w[\"[object ArrayBuffer]\"]=w[\"[object DataView]\"]=w[\"[object Boolean]\"]=w[\"[object Date]\"]=w[\"[object Float32Array]\"]=w[\"[object Float64Array]\"]=w[\"[object Int8Array]\"]=w[\"[object Int16Array]\"]=w[\"[object Int32Array]\"]=w[\"[object Map]\"]=w[\"[object Number]\"]=w[\"[object Object]\"]=w[\"[object RegExp]\"]=w[\"[object Set]\"]=w[\"[object String]\"]=w[\"[object Symbol]\"]=w[\"[object Uint8Array]\"]=w[\"[object Uint8ClampedArray]\"]=w[\"[object Uint16Array]\"]=w[\"[object Uint32Array]\"]=!0,w[\"[object Error]\"]=w[\"[object Function]\"]=w[\"[object WeakMap]\"]=!1,t.exports=function t(r,n,F,A,S,D){var $,P=1&n,z=2&n,E=4&n;if(F&&($=S?F(r,A,S,D):F(r)),void 0!==$)return $;if(!g(r))return r;var k=d(r);if(k){if($=h(r),!P)return s(r,$)}else{var B=b(r),M=\"[object Function]\"==B||\"[object GeneratorFunction]\"==B;if(j(r))return a(r,P);if(\"[object Object]\"==B||\"[object Arguments]\"==B||M&&!S){if($=z||M?{}:x(r),!P)return z?p(r,c($,r)):f(r,i($,r))}else{if(!w[B])return S?r:{};$=y(r,B,P)}}D||(D=new e);var I=D.get(r);if(I)return I;D.set(r,$),m(r)?r.forEach((function(e){$.add(t(e,n,F,e,r,D))})):_(r)&&r.forEach((function(e,o){$.set(o,t(e,n,F,o,r,D))}));var C=E?z?v:l:z?keysIn:O,Q=k?void 0:C(r);return o(Q||r,(function(e,o){Q&&(e=r[o=e]),u($,o,t(e,n,F,o,r,D))})),$}},function(t,r){t.exports=function(){this.__data__=[],this.size=0}},function(t,r,n){var e=n(9),o=Array.prototype.splice;t.exports=function(t){var r=this.__data__,n=e(r,t);return!(n<0)&&(n==r.length-1?r.pop():o.call(r,n,1),--this.size,!0)}},function(t,r,n){var e=n(9);t.exports=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}},function(t,r,n){var e=n(9);t.exports=function(t){return e(this.__data__,t)>-1}},function(t,r,n){var e=n(9);t.exports=function(t,r){var n=this.__data__,o=e(n,t);return o<0?(++this.size,n.push([t,r])):n[o][1]=r,this}},function(t,r,n){var e=n(8);t.exports=function(){this.__data__=new e,this.size=0}},function(t,r){t.exports=function(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}},function(t,r){t.exports=function(t){return this.__data__.get(t)}},function(t,r){t.exports=function(t){return this.__data__.has(t)}},function(t,r,n){var e=n(8),o=n(19),u=n(20);t.exports=function(t,r){var n=this.__data__;if(n instanceof e){var i=n.__data__;if(!o||i.length<199)return i.push([t,r]),this.size=++n.size,this;n=this.__data__=new u(i)}return n.set(t,r),this.size=n.size,this}},function(t,r,n){var e=n(30),o=n(77),u=n(4),i=n(32),c=/^\\[object .+?Constructor\\]$/,a=Function.prototype,s=Object.prototype,f=a.toString,p=s.hasOwnProperty,l=RegExp(\"^\"+f.call(p).replace(/[\\\\^$.*+?()[\\]{}|]/g,\"\\\\$&\").replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g,\"$1.*?\")+\"$\");t.exports=function(t){return!(!u(t)||o(t))&&(e(t)?l:c).test(i(t))}},function(t,r,n){var e=n(6),o=Object.prototype,u=o.hasOwnProperty,i=o.toString,c=e?e.toStringTag:void 0;t.exports=function(t){var r=u.call(t,c),n=t[c];try{t[c]=void 0;var e=!0}catch(t){}var o=i.call(t);return e&&(r?t[c]=n:delete t[c]),o}},function(t,r){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,r,n){var e,o=n(78),u=(e=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||\"\"))?\"Symbol(src)_1.\"+e:\"\";t.exports=function(t){return!!u&&u in t}},function(t,r,n){var e=n(1)[\"__core-js_shared__\"];t.exports=e},function(t,r){t.exports=function(t,r){return null==t?void 0:t[r]}},function(t,r,n){var e=n(81),o=n(8),u=n(19);t.exports=function(){this.size=0,this.__data__={hash:new e,map:new(u||o),string:new e}}},function(t,r,n){var e=n(82),o=n(83),u=n(84),i=n(85),c=n(86);function a(t){var r=-1,n=null==t?0:t.length;for(this.clear();++r<n;){var e=t[r];this.set(e[0],e[1])}}a.prototype.clear=e,a.prototype.delete=o,a.prototype.get=u,a.prototype.has=i,a.prototype.set=c,t.exports=a},function(t,r,n){var e=n(10);t.exports=function(){this.__data__=e?e(null):{},this.size=0}},function(t,r){t.exports=function(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}},function(t,r,n){var e=n(10),o=Object.prototype.hasOwnProperty;t.exports=function(t){var r=this.__data__;if(e){var n=r[t];return\"__lodash_hash_undefined__\"===n?void 0:n}return o.call(r,t)?r[t]:void 0}},function(t,r,n){var e=n(10),o=Object.prototype.hasOwnProperty;t.exports=function(t){var r=this.__data__;return e?void 0!==r[t]:o.call(r,t)}},function(t,r,n){var e=n(10);t.exports=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?\"__lodash_hash_undefined__\":r,this}},function(t,r,n){var e=n(11);t.exports=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}},function(t,r){t.exports=function(t){var r=typeof t;return\"string\"==r||\"number\"==r||\"symbol\"==r||\"boolean\"==r?\"__proto__\"!==t:null===t}},function(t,r,n){var e=n(11);t.exports=function(t){return e(this,t).get(t)}},function(t,r,n){var e=n(11);t.exports=function(t){return e(this,t).has(t)}},function(t,r,n){var e=n(11);t.exports=function(t,r){var n=e(this,t),o=n.size;return n.set(t,r),this.size+=n.size==o?0:1,this}},function(t,r){t.exports=function(t,r){for(var n=-1,e=null==t?0:t.length;++n<e&&!1!==r(t[n],n,t););return t}},function(t,r,n){var e=n(2),o=function(){try{var t=e(Object,\"defineProperty\");return t({},\"\",{}),t}catch(t){}}();t.exports=o},function(t,r,n){var e=n(12),o=n(7);t.exports=function(t,r){return t&&e(r,o(r),t)}},function(t,r){t.exports=function(t,r){for(var n=-1,e=Array(t);++n<t;)e[n]=r(n);return e}},function(t,r,n){var e=n(5),o=n(3);t.exports=function(t){return o(t)&&\"[object Arguments]\"==e(t)}},function(t,r){t.exports=function(){return!1}},function(t,r,n){var e=n(5),o=n(22),u=n(3),i={};i[\"[object Float32Array]\"]=i[\"[object Float64Array]\"]=i[\"[object Int8Array]\"]=i[\"[object Int16Array]\"]=i[\"[object Int32Array]\"]=i[\"[object Uint8Array]\"]=i[\"[object Uint8ClampedArray]\"]=i[\"[object Uint16Array]\"]=i[\"[object Uint32Array]\"]=!0,i[\"[object Arguments]\"]=i[\"[object Array]\"]=i[\"[object ArrayBuffer]\"]=i[\"[object Boolean]\"]=i[\"[object DataView]\"]=i[\"[object Date]\"]=i[\"[object Error]\"]=i[\"[object Function]\"]=i[\"[object Map]\"]=i[\"[object Number]\"]=i[\"[object Object]\"]=i[\"[object RegExp]\"]=i[\"[object Set]\"]=i[\"[object String]\"]=i[\"[object WeakMap]\"]=!1,t.exports=function(t){return u(t)&&o(t.length)&&!!i[e(t)]}},function(t,r,n){var e=n(25),o=n(100),u=Object.prototype.hasOwnProperty;t.exports=function(t){if(!e(t))return o(t);var r=[];for(var n in Object(t))u.call(t,n)&&\"constructor\"!=n&&r.push(n);return r}},function(t,r,n){var e=n(39)(Object.keys,Object);t.exports=e},function(t,r,n){var e=n(12),o=n(40);t.exports=function(t,r){return t&&e(r,o(r),t)}},function(t,r,n){var e=n(4),o=n(25),u=n(103),i=Object.prototype.hasOwnProperty;t.exports=function(t){if(!e(t))return u(t);var r=o(t),n=[];for(var c in t)(\"constructor\"!=c||!r&&i.call(t,c))&&n.push(c);return n}},function(t,r){t.exports=function(t){var r=[];if(null!=t)for(var n in Object(t))r.push(n);return r}},function(t,r,n){(function(t){var e=n(1),o=r&&!r.nodeType&&r,u=o&&\"object\"==typeof t&&t&&!t.nodeType&&t,i=u&&u.exports===o?e.Buffer:void 0,c=i?i.allocUnsafe:void 0;t.exports=function(t,r){if(r)return t.slice();var n=t.length,e=c?c(n):new t.constructor(n);return t.copy(e),e}}).call(this,n(13)(t))},function(t,r){t.exports=function(t,r){var n=-1,e=t.length;for(r||(r=Array(e));++n<e;)r[n]=t[n];return r}},function(t,r,n){var e=n(12),o=n(26);t.exports=function(t,r){return e(t,o(t),r)}},function(t,r,n){var e=n(12),o=n(43);t.exports=function(t,r){return e(t,o(t),r)}},function(t,r,n){var e=n(47),o=n(43),u=n(40);t.exports=function(t){return e(t,u,o)}},function(t,r,n){var e=n(2)(n(1),\"DataView\");t.exports=e},function(t,r,n){var e=n(2)(n(1),\"Promise\");t.exports=e},function(t,r,n){var e=n(2)(n(1),\"Set\");t.exports=e},function(t,r,n){var e=n(2)(n(1),\"WeakMap\");t.exports=e},function(t,r){var n=Object.prototype.hasOwnProperty;t.exports=function(t){var r=t.length,e=new t.constructor(r);return r&&\"string\"==typeof t[0]&&n.call(t,\"index\")&&(e.index=t.index,e.input=t.input),e}},function(t,r,n){var e=n(27),o=n(115),u=n(116),i=n(117),c=n(118);t.exports=function(t,r,n){var a=t.constructor;switch(r){case\"[object ArrayBuffer]\":return e(t);case\"[object Boolean]\":case\"[object Date]\":return new a(+t);case\"[object DataView]\":return o(t,n);case\"[object Float32Array]\":case\"[object Float64Array]\":case\"[object Int8Array]\":case\"[object Int16Array]\":case\"[object Int32Array]\":case\"[object Uint8Array]\":case\"[object Uint8ClampedArray]\":case\"[object Uint16Array]\":case\"[object Uint32Array]\":return c(t,n);case\"[object Map]\":return new a;case\"[object Number]\":case\"[object String]\":return new a(t);case\"[object RegExp]\":return u(t);case\"[object Set]\":return new a;case\"[object Symbol]\":return i(t)}}},function(t,r,n){var e=n(27);t.exports=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}},function(t,r){var n=/\\w*$/;t.exports=function(t){var r=new t.constructor(t.source,n.exec(t));return r.lastIndex=t.lastIndex,r}},function(t,r,n){var e=n(6),o=e?e.prototype:void 0,u=o?o.valueOf:void 0;t.exports=function(t){return u?Object(u.call(t)):{}}},function(t,r,n){var e=n(27);t.exports=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}},function(t,r,n){var e=n(120),o=n(45),u=n(25);t.exports=function(t){return\"function\"!=typeof t.constructor||u(t)?{}:e(o(t))}},function(t,r,n){var e=n(4),o=Object.create,u=function(){function t(){}return function(r){if(!e(r))return{};if(o)return o(r);t.prototype=r;var n=new t;return t.prototype=void 0,n}}();t.exports=u},function(t,r,n){var e=n(122),o=n(23),u=n(24),i=u&&u.isMap,c=i?o(i):e;t.exports=c},function(t,r,n){var e=n(15),o=n(3);t.exports=function(t){return o(t)&&\"[object Map]\"==e(t)}},function(t,r,n){var e=n(124),o=n(23),u=n(24),i=u&&u.isSet,c=i?o(i):e;t.exports=c},function(t,r,n){var e=n(15),o=n(3);t.exports=function(t){return o(t)&&\"[object Set]\"==e(t)}},function(t,r,n){var e=n(50);t.exports=function(t,r){var n=[];return e(t,(function(t,e,o){r(t,e,o)&&n.push(t)})),n}},function(t,r,n){var e=n(127),o=n(7);t.exports=function(t,r){return t&&e(t,r,o)}},function(t,r,n){var e=n(128)();t.exports=e},function(t,r){t.exports=function(t){return function(r,n,e){for(var o=-1,u=Object(r),i=e(r),c=i.length;c--;){var a=i[t?c:++o];if(!1===n(u[a],a,u))break}return r}}},function(t,r,n){var e=n(14);t.exports=function(t,r){return function(n,o){if(null==n)return n;if(!e(n))return t(n,o);for(var u=n.length,i=r?u:-1,c=Object(n);(r?i--:++i<u)&&!1!==o(c[i],i,c););return n}}},function(t,r,n){var e=n(131),o=n(142),u=n(55);t.exports=function(t){var r=o(t);return 1==r.length&&r[0][2]?u(r[0][0],r[0][1]):function(n){return n===t||e(n,t,r)}}},function(t,r,n){var e=n(17),o=n(52);t.exports=function(t,r,n,u){var i=n.length,c=i,a=!u;if(null==t)return!c;for(t=Object(t);i--;){var s=n[i];if(a&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++i<c;){var f=(s=n[i])[0],p=t[f],l=s[1];if(a&&s[2]){if(void 0===p&&!(f in t))return!1}else{var v=new e;if(u)var b=u(p,l,f,t,r,v);if(!(void 0===b?o(l,p,3,u,v):b))return!1}}return!0}},function(t,r,n){var e=n(17),o=n(53),u=n(138),i=n(141),c=n(15),a=n(0),s=n(21),f=n(38),p=\"[object Object]\",l=Object.prototype.hasOwnProperty;t.exports=function(t,r,n,v,b,h){var y=a(t),x=a(r),d=y?\"[object Array]\":c(t),j=x?\"[object Array]\":c(r),_=(d=\"[object Arguments]\"==d?p:d)==p,g=(j=\"[object Arguments]\"==j?p:j)==p,m=d==j;if(m&&s(t)){if(!s(r))return!1;y=!0,_=!1}if(m&&!_)return h||(h=new e),y||f(t)?o(t,r,n,v,b,h):u(t,r,d,n,v,b,h);if(!(1&n)){var O=_&&l.call(t,\"__wrapped__\"),w=g&&l.call(r,\"__wrapped__\");if(O||w){var F=O?t.value():t,A=w?r.value():r;return h||(h=new e),b(F,A,n,v,h)}}return!!m&&(h||(h=new e),i(t,r,n,v,b,h))}},function(t,r,n){var e=n(20),o=n(134),u=n(135);function i(t){var r=-1,n=null==t?0:t.length;for(this.__data__=new e;++r<n;)this.add(t[r])}i.prototype.add=i.prototype.push=o,i.prototype.has=u,t.exports=i},function(t,r){t.exports=function(t){return this.__data__.set(t,\"__lodash_hash_undefined__\"),this}},function(t,r){t.exports=function(t){return this.__data__.has(t)}},function(t,r){t.exports=function(t,r){for(var n=-1,e=null==t?0:t.length;++n<e;)if(r(t[n],n,t))return!0;return!1}},function(t,r){t.exports=function(t,r){return t.has(r)}},function(t,r,n){var e=n(6),o=n(48),u=n(18),i=n(53),c=n(139),a=n(140),s=e?e.prototype:void 0,f=s?s.valueOf:void 0;t.exports=function(t,r,n,e,s,p,l){switch(n){case\"[object DataView]\":if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case\"[object ArrayBuffer]\":return!(t.byteLength!=r.byteLength||!p(new o(t),new o(r)));case\"[object Boolean]\":case\"[object Date]\":case\"[object Number]\":return u(+t,+r);case\"[object Error]\":return t.name==r.name&&t.message==r.message;case\"[object RegExp]\":case\"[object String]\":return t==r+\"\";case\"[object Map]\":var v=c;case\"[object Set]\":var b=1&e;if(v||(v=a),t.size!=r.size&&!b)return!1;var h=l.get(t);if(h)return h==r;e|=2,l.set(t,r);var y=i(v(t),v(r),e,s,p,l);return l.delete(t),y;case\"[object Symbol]\":if(f)return f.call(t)==f.call(r)}return!1}},function(t,r){t.exports=function(t){var r=-1,n=Array(t.size);return t.forEach((function(t,e){n[++r]=[e,t]})),n}},function(t,r){t.exports=function(t){var r=-1,n=Array(t.size);return t.forEach((function(t){n[++r]=t})),n}},function(t,r,n){var e=n(46),o=Object.prototype.hasOwnProperty;t.exports=function(t,r,n,u,i,c){var a=1&n,s=e(t),f=s.length;if(f!=e(r).length&&!a)return!1;for(var p=f;p--;){var l=s[p];if(!(a?l in r:o.call(r,l)))return!1}var v=c.get(t);if(v&&c.get(r))return v==r;var b=!0;c.set(t,r),c.set(r,t);for(var h=a;++p<f;){var y=t[l=s[p]],x=r[l];if(u)var d=a?u(x,y,l,r,t,c):u(y,x,l,t,r,c);if(!(void 0===d?y===x||i(y,x,n,u,c):d)){b=!1;break}h||(h=\"constructor\"==l)}if(b&&!h){var j=t.constructor,_=r.constructor;j==_||!(\"constructor\"in t)||!(\"constructor\"in r)||\"function\"==typeof j&&j instanceof j&&\"function\"==typeof _&&_ instanceof _||(b=!1)}return c.delete(t),c.delete(r),b}},function(t,r,n){var e=n(54),o=n(7);t.exports=function(t){for(var r=o(t),n=r.length;n--;){var u=r[n],i=t[u];r[n]=[u,i,e(i)]}return r}},function(t,r,n){var e=n(52),o=n(144),u=n(150),i=n(28),c=n(54),a=n(55),s=n(16);t.exports=function(t,r){return i(t)&&c(r)?a(s(t),r):function(n){var i=o(n,t);return void 0===i&&i===r?u(n,t):e(r,i,3)}}},function(t,r,n){var e=n(56);t.exports=function(t,r,n){var o=null==t?void 0:e(t,r);return void 0===o?n:o}},function(t,r,n){var e=n(146),o=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g,u=/\\\\(\\\\)?/g,i=e((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(\"\"),t.replace(o,(function(t,n,e,o){r.push(e?o.replace(u,\"$1\"):n||t)})),r}));t.exports=i},function(t,r,n){var e=n(147);t.exports=function(t){var r=e(t,(function(t){return 500===n.size&&n.clear(),t})),n=r.cache;return r}},function(t,r,n){var e=n(20);function o(t,r){if(\"function\"!=typeof t||null!=r&&\"function\"!=typeof r)throw new TypeError(\"Expected a function\");var n=function(){var e=arguments,o=r?r.apply(this,e):e[0],u=n.cache;if(u.has(o))return u.get(o);var i=t.apply(this,e);return n.cache=u.set(o,i)||u,i};return n.cache=new(o.Cache||e),n}o.Cache=e,t.exports=o},function(t,r,n){var e=n(149);t.exports=function(t){return null==t?\"\":e(t)}},function(t,r,n){var e=n(6),o=n(58),u=n(0),i=n(29),c=e?e.prototype:void 0,a=c?c.toString:void 0;t.exports=function t(r){if(\"string\"==typeof r)return r;if(u(r))return o(r,t)+\"\";if(i(r))return a?a.call(r):\"\";var n=r+\"\";return\"0\"==n&&1/r==-1/0?\"-0\":n}},function(t,r,n){var e=n(151),o=n(152);t.exports=function(t,r){return null!=t&&o(t,r,e)}},function(t,r){t.exports=function(t,r){return null!=t&&r in Object(t)}},function(t,r,n){var e=n(57),o=n(36),u=n(0),i=n(37),c=n(22),a=n(16);t.exports=function(t,r,n){for(var s=-1,f=(r=e(r,t)).length,p=!1;++s<f;){var l=a(r[s]);if(!(p=null!=t&&n(t,l)))break;t=t[l]}return p||++s!=f?p:!!(f=null==t?0:t.length)&&c(f)&&i(l,f)&&(u(t)||o(t))}},function(t,r){t.exports=function(t){return t}},function(t,r,n){var e=n(155),o=n(156),u=n(28),i=n(16);t.exports=function(t){return u(t)?e(i(t)):o(t)}},function(t,r){t.exports=function(t){return function(r){return null==r?void 0:r[t]}}},function(t,r,n){var e=n(56);t.exports=function(t){return function(r){return e(r,t)}}},function(t,r,n){var e=n(58),o=n(51),u=n(158),i=n(0);t.exports=function(t,r){return(i(t)?e:u)(t,o(r,3))}},function(t,r,n){var e=n(50),o=n(14);t.exports=function(t,r){var n=-1,u=o(t)?Array(t.length):[];return e(t,(function(t,e,o){u[++n]=r(t,e,o)})),u}},function(t,r){t.exports=class{constructor(t,r,n,e){this._content=t,this._isHidden=r,this._isSignature=n,this._isQuoted=e}getContent(){return this._content}isHidden(){return this._isHidden}isSignature(){return this._isSignature}isQuoted(){return this._isQuoted}isEmpty(){return 0===this.getContent().replace(\"\\n\",\"\").length}}},function(t,r){var n=Array.prototype.reverse;t.exports=function(t){return null==t?t:n.call(t)}},function(t,r,n){(function(t){var e;/*! https://mths.be/esrever v0.2.0 by @mathias */!function(o){var u=r,i=(t&&t.exports,\"object\"==typeof global&&global);i.global!==i&&i.window;var c=/([\\0-\\u02FF\\u0370-\\u1AAF\\u1B00-\\u1DBF\\u1E00-\\u20CF\\u2100-\\uD7FF\\uE000-\\uFE1F\\uFE30-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF])([\\u0300-\\u036F\\u1AB0-\\u1AFF\\u1DC0-\\u1DFF\\u20D0-\\u20FF\\uFE20-\\uFE2F]+)/g,a=/([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])/g,s=function(t){for(var r=\"\",n=(t=t.replace(c,(function(t,r,n){return s(n)+r})).replace(a,\"$2$1\")).length;n--;)r+=t.charAt(n);return r},f={version:\"0.2.0\",reverse:s};void 0===(e=function(){return f}.call(r,n,r,t))||(t.exports=e)}()}).call(this,n(13)(t))}]);\n\nfunction extractReplyContent(message) {\n const email = EmailParser(message);\n const reply = (email.getFragments()[0].getContent().trim());\n return reply;\n}\n\nfor (const item of $input.all()) {\n item.json.reply = extractReplyContent(item.json.text);\n}\n\nreturn $input.all();"
      },
      "typeVersion": 1
    },
    {
      "id": "4f6998f6-88a8-4b8b-acea-33c3f33d04dd",
      "name": "If spreadsheet doesn't exist",
      "type": "n8n-nodes-base.if",
      "position": [
        1420,
        2500
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json[\"error\"] }}",
              "value2": "The resource you are requesting could not be found"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f3564023-a1c5-42f5-923d-a8e98c95c284",
      "name": "Successfully created or updated row",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1660,
        2640
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "55869b16-3a98-4127-83ec-bcfdf21c2daf",
      "name": "Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        2140
      ],
      "parameters": {
        "width": 778.177339901478,
        "height": 289.16256157635416,
        "content": "### Create spreadsheet and populate with headers and deal information\nA spreadsheet is created if the spreadsheet does not exist. The spreadsheet ID is stored in the `$getWorkflowStaticData('global')` variable. Using `Extract current deal` node, the deal information is formatted for the sending to the new spreadsheet."
      },
      "typeVersion": 1
    },
    {
      "id": "8994f1e7-dd0d-4247-89fd-befcc9c511b0",
      "name": "Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1220,
        2680
      ],
      "parameters": {
        "width": 301.18226600985224,
        "height": 114.67980295566498,
        "content": "### Tip: Deleting old spreadsheets\nIf you ever want to start over, delete the old spreadsheet, __making sure that it is also deleted from Google Drive's trash__."
      },
      "typeVersion": 1
    },
    {
      "id": "cd8c9657-3380-4e25-907e-baa1c02c0793",
      "name": "Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        2140
      ],
      "parameters": {
        "width": 260.3940886699507,
        "height": 333.34975369458095,
        "content": "### `Get spreadsheet ID`\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe spreadsheet ID is stored in this workflow's static data. If you want to refresh the static data you will need to copy this entire workflow into a new workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "ab0348c2-f688-42d3-815b-63290e95baad",
      "name": "Create spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1020,
        2260
      ],
      "parameters": {
        "title": "={{ $(\"Configure\").first().json[\"spreadsheetName\"] }}",
        "options": {},
        "resource": "spreadsheet",
        "sheetsUi": {
          "sheetValues": [
            {
              "title": "={{ $(\"Configure\").first().json[\"worksheetName\"] }}"
            }
          ]
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c56522b2-5eca-497d-afbb-d713abd8d810",
      "name": "Store spreadsheet ID",
      "type": "n8n-nodes-base.code",
      "position": [
        1220,
        2260
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\n\nstaticData.googleSheetsSpreadsheetId = $('Create spreadsheet').first().json.spreadsheetId\nstaticData.googleSheetsWorksheetId = $('Create spreadsheet').first().json.sheets[0].properties.sheetId\n\nreturn {\n \"spreadsheetId\": staticData.googleSheetsSpreadsheetId,\n \"worksheetId\": staticData.googleSheetsWorksheetId\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "ba62fd4d-912b-4b37-9fda-2f80cdeb65f8",
      "name": "Paste data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1620,
        2260
      ],
      "parameters": {
        "options": {
          "cellFormat": "RAW"
        },
        "dataMode": "autoMapInputData",
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $node[\"Store spreadsheet ID\"].json[\"worksheetId\"] }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $node[\"Store spreadsheet ID\"].json[\"spreadsheetId\"] }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "a8be831a-f2be-48c9-a661-bc8c5cde6444",
      "name": "If no sheet IDs",
      "type": "n8n-nodes-base.if",
      "position": [
        800,
        2380
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json[\"spreadsheetId\"] }}",
              "operation": "isEmpty"
            },
            {
              "value1": "={{ $json[\"worksheetId\"] }}",
              "operation": "isEmpty"
            }
          ]
        },
        "combineOperation": "any"
      },
      "typeVersion": 1
    },
    {
      "id": "efdb343d-f5bf-4ba4-bc27-850b9e7935ac",
      "name": "Create or update rows",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1220,
        2500
      ],
      "parameters": {
        "options": {
          "cellFormat": "RAW"
        },
        "dataMode": "autoMapInputData",
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $node[\"If no sheet IDs\"].json[\"worksheetId\"] }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $node[\"If no sheet IDs\"].json[\"spreadsheetId\"] }}"
        },
        "columnToMatchOn": "ID"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3,
      "continueOnFail": true
    },
    {
      "id": "091ad4fa-21aa-42e0-abc5-17221cdf8fb7",
      "name": "Get data from `Format data`",
      "type": "n8n-nodes-base.code",
      "position": [
        1020,
        2500
      ],
      "parameters": {
        "jsCode": "return $('Format data').all()"
      },
      "typeVersion": 1
    },
    {
      "id": "97071540-59b2-48dd-8f88-ab44446832fc",
      "name": "Get data from `Format data` node",
      "type": "n8n-nodes-base.code",
      "position": [
        1420,
        2260
      ],
      "parameters": {
        "jsCode": "return $('Format data').all()"
      },
      "typeVersion": 1
    },
    {
      "id": "ecf03802-51c8-43b1-84d8-5ed5826fd444",
      "name": "Format data",
      "type": "n8n-nodes-base.set",
      "position": [
        -40,
        2380
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "ID",
              "value": "={{ $node[\"Generate UUID\"].json.uuid }}"
            },
            {
              "name": "Initial message",
              "value": "={{ $node[\"Extract message content (advanced)\"].json.reply }}"
            },
            {
              "name": "Generated reply",
              "value": "={{ $node[\"Generate reply\"].json.text }}"
            },
            {
              "name": "Good response?"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "id": "9eedd7b7-ec4e-4dbf-a257-33e73bdff9c1",
      "name": "Send email reply",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -40,
        1860
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8e2f4a3b-d224-4248-9682-184a646e022f",
      "name": "On feedback given",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -2460,
        2940
      ],
      "parameters": {
        "path": "e2aa55fb-618a-4478-805d-d6da46b908d1",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 1
    },
    {
      "id": "87506e44-21aa-4f08-82f9-f47a24ddb9ce",
      "name": "Send feedback for fine-tuned data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -100,
        2980
      ],
      "parameters": {
        "options": {},
        "fieldsUi": {
          "values": [
            {
              "column": "Good response?",
              "fieldValue": "={{ $node[\"On feedback given\"].json.query.feedback }}"
            }
          ]
        },
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json[\"worksheetId\"] }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json[\"spreadsheetId\"] }}"
        },
        "valueToMatchOn": "={{ $node[\"On feedback given\"].json.query.id }}",
        "columnToMatchOn": "ID"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "d2a720d4-8487-4dfa-bdb8-6b59368e44bc",
      "name": "Show HTML page",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -920,
        2980
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "text",
        "responseBody": "={{ $json.html }}"
      },
      "typeVersion": 1
    },
    {
      "id": "2da7a7b1-e96d-4759-b3cb-13558e2ad1d4",
      "name": "Get sheet IDs #1",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        2200
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\n\nreturn {\n \"spreadsheetId\": staticData.googleSheetsSpreadsheetId,\n \"worksheetId\": staticData.googleSheetsWorksheetId\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "08ddeed5-fefe-4acd-918a-00d1fd5a5392",
      "name": "Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        2780
      ],
      "parameters": {
        "width": 260.3940886699507,
        "height": 333.34975369458095,
        "content": "### `Get spreadsheet ID`\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe spreadsheet ID is stored in this workflow's static data. If you want to refresh the static data you will need to copy this entire workflow into a new workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "49d77f89-3c1e-4e86-93e8-ae7a566802b7",
      "name": "If no spreadsheet in configuration #2",
      "type": "n8n-nodes-base.if",
      "position": [
        -700,
        2980
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $('Configure').first().json.spreadsheetId }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e3b8f696-41eb-46e1-a4b1-6ba2d219aa45",
      "name": "Store specific sheet IDs #2",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        3180
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\n\nstaticData.googleSheetsSpreadsheetId = $('Configure').all()[0].json.spreadsheetId\nstaticData.googleSheetsWorksheetId = $('Configure').all()[0].json.worksheetId\n\nreturn {\n \"spreadsheetId\": staticData.googleSheetsSpreadsheetId,\n \"worksheetId\": staticData.googleSheetsWorksheetId\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "44d37f76-af16-4507-b1a1-76fadf530806",
      "name": "Get sheet IDs #2",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        2840
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\n\nreturn {\n \"spreadsheetId\": staticData.googleSheetsSpreadsheetId,\n \"worksheetId\": staticData.googleSheetsWorksheetId\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "fae8cbc5-7462-4eb0-9f60-85e8e7cfd10e",
      "name": "If no spreadsheet in configuration #1",
      "type": "n8n-nodes-base.if",
      "position": [
        180,
        2380
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $('Configure').first().json.spreadsheetId }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "67312347-74c0-4ce4-a78c-615da6937bcf",
      "name": "Store specific sheet IDs #1",
      "type": "n8n-nodes-base.code",
      "position": [
        480,
        2540
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\n\nstaticData.googleSheetsSpreadsheetId = $('Configure').all()[0].json.spreadsheetId\nstaticData.googleSheetsWorksheetId = $('Configure').all()[0].json.worksheetId\n\nreturn {\n \"spreadsheetId\": staticData.googleSheetsSpreadsheetId,\n \"worksheetId\": staticData.googleSheetsWorksheetId\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "400eae76-7b17-48de-a49f-8b0cbc9db1f8",
      "name": "Email template",
      "type": "n8n-nodes-base.html",
      "position": [
        160,
        1860
      ],
      "parameters": {
        "html": "<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <title>Template for ChatGPT email</title>\n <style>\n /* cspell:disable-file */\n /* webkit printing magic: print all background colors */\n html {\n -webkit-print-color-adjust: exact;\n }\n * {\n box-sizing: border-box;\n -webkit-print-color-adjust: exact;\n }\n\n html,\n body {\n margin: 0;\n padding: 0;\n }\n @media only screen {\n body {\n margin: 2em auto;\n max-width: 900px;\n color: rgb(55, 53, 47);\n }\n }\n\n body {\n line-height: 1.5;\n white-space: pre-wrap;\n }\n\n a,\n a.visited {\n color: inherit;\n text-decoration: underline;\n }\n\n .pdf-relative-link-path {\n font-size: 80%;\n color: #444;\n }\n\n h1,\n h2,\n h3 {\n letter-spacing: -0.01em;\n line-height: 1.2;\n font-weight: 600;\n margin-bottom: 0;\n }\n\n .page-title {\n font-size: 2.5rem;\n font-weight: 700;\n margin-top: 0;\n margin-bottom: 0.75em;\n }\n\n h1 {\n font-size: 1.875rem;\n margin-top: 1.875rem;\n }\n\n h2 {\n font-size: 1.5rem;\n margin-top: 1.5rem;\n }\n\n h3 {\n font-size: 1.25rem;\n margin-top: 1.25rem;\n }\n\n .source {\n border: 1px solid #ddd;\n border-radius: 3px;\n padding: 1.5em;\n word-break: break-all;\n }\n\n .callout {\n border-radius: 3px;\n padding: 1rem;\n }\n\n figure {\n margin: 1.25em 0;\n page-break-inside: avoid;\n }\n\n figcaption {\n opacity: 0.5;\n font-size: 85%;\n margin-top: 0.5em;\n }\n\n mark {\n background-color: transparent;\n }\n\n .indented {\n padding-left: 1.5em;\n }\n\n hr {\n background: transparent;\n display: block;\n width: 100%;\n height: 1px;\n visibility: visible;\n border: none;\n border-bottom: 1px solid rgba(55, 53, 47, 0.09);\n }\n\n img {\n max-width: 100%;\n }\n\n @media only print {\n img {\n max-height: 100vh;\n object-fit: contain;\n }\n }\n\n @page {\n margin: 1in;\n }\n\n .collection-content {\n font-size: 0.875rem;\n }\n\n .column-list {\n display: flex;\n justify-content: space-between;\n }\n\n .column {\n padding: 0 1em;\n }\n\n .column:first-child {\n padding-left: 0;\n }\n\n .column:last-child {\n padding-right: 0;\n }\n\n .table_of_contents-item {\n display: block;\n font-size: 0.875rem;\n line-height: 1.3;\n padding: 0.125rem;\n }\n\n .table_of_contents-indent-1 {\n margin-left: 1.5rem;\n }\n\n .table_of_contents-indent-2 {\n margin-left: 3rem;\n }\n\n .table_of_contents-indent-3 {\n margin-left: 4.5rem;\n }\n\n .table_of_contents-link {\n text-decoration: none;\n opacity: 0.7;\n border-bottom: 1px solid rgba(55, 53, 47, 0.18);\n }\n\n table,\n th,\n td {\n border: 1px solid rgba(55, 53, 47, 0.09);\n border-collapse: collapse;\n }\n\n table {\n border-left: none;\n border-right: none;\n }\n\n th,\n td {\n font-weight: normal;\n padding: 0.25em 0.5em;\n line-height: 1.5;\n min-height: 1.5em;\n text-align: left;\n }\n\n th {\n color: rgba(55, 53, 47, 0.6);\n }\n\n ol,\n ul {\n margin: 0;\n margin-block-start: 0.6em;\n margin-block-end: 0.6em;\n }\n\n li > ol:first-child,\n li > ul:first-child {\n margin-block-start: 0.6em;\n }\n\n ul > li {\n list-style: disc;\n }\n\n ul.to-do-list {\n text-indent: -1.7em;\n }\n\n ul.to-do-list > li {\n list-style: none;\n }\n\n .to-do-children-checked {\n text-decoration: line-through;\n opacity: 0.375;\n }\n\n ul.toggle > li {\n list-style: none;\n }\n\n ul {\n padding-inline-start: 1.7em;\n }\n\n ul > li {\n padding-left: 0.1em;\n }\n\n ol {\n padding-inline-start: 1.6em;\n }\n\n ol > li {\n padding-left: 0.2em;\n }\n\n .mono ol {\n padding-inline-start: 2em;\n }\n\n .mono ol > li {\n text-indent: -0.4em;\n }\n\n .toggle {\n padding-inline-start: 0em;\n list-style-type: none;\n }\n\n /* Indent toggle children */\n .toggle > li > details {\n padding-left: 1.7em;\n }\n\n .toggle > li > details > summary {\n margin-left: -1.1em;\n }\n\n .selected-value {\n display: inline-block;\n padding: 0 0.5em;\n background: rgba(206, 205, 202, 0.5);\n border-radius: 3px;\n margin-right: 0.5em;\n margin-top: 0.3em;\n margin-bottom: 0.3em;\n white-space: nowrap;\n }\n\n .collection-title {\n display: inline-block;\n margin-right: 1em;\n }\n\n .simple-table {\n margin-top: 1em;\n font-size: 0.875rem;\n empty-cells: show;\n }\n .simple-table td {\n height: 29px;\n min-width: 120px;\n }\n\n .simple-table th {\n height: 29px;\n min-width: 120px;\n }\n\n .simple-table-header-color {\n background: rgb(247, 246, 243);\n color: black;\n }\n .simple-table-header {\n font-weight: 500;\n }\n\n time {\n opacity: 0.5;\n }\n\n .icon {\n display: inline-block;\n max-width: 1.2em;\n max-height: 1.2em;\n text-decoration: none;\n vertical-align: text-bottom;\n margin-right: 0.5em;\n }\n\n img.icon {\n border-radius: 3px;\n }\n\n .user-icon {\n width: 1.5em;\n height: 1.5em;\n border-radius: 100%;\n margin-right: 0.5rem;\n }\n\n .user-icon-inner {\n font-size: 0.8em;\n }\n\n .text-icon {\n border: 1px solid #000;\n text-align: center;\n }\n\n .page-cover-image {\n display: block;\n object-fit: cover;\n width: 100%;\n max-height: 30vh;\n }\n\n .page-header-icon {\n font-size: 3rem;\n margin-bottom: 1rem;\n }\n\n .page-header-icon-with-cover {\n margin-top: -0.72em;\n margin-left: 0.07em;\n }\n\n .page-header-icon img {\n border-radius: 3px;\n }\n\n .link-to-page {\n margin: 1em 0;\n padding: 0;\n border: none;\n font-weight: 500;\n }\n\n p > .user {\n opacity: 0.5;\n }\n\n td > .user,\n td > time {\n white-space: nowrap;\n }\n\n input[type=\"checkbox\"] {\n transform: scale(1.5);\n margin-right: 0.6em;\n vertical-align: middle;\n }\n\n p {\n margin-top: 0.5em;\n margin-bottom: 0.5em;\n }\n\n .image {\n border: none;\n margin: 1.5em 0;\n padding: 0;\n border-radius: 0;\n text-align: center;\n }\n\n .code,\n code {\n background: rgba(135, 131, 120, 0.15);\n border-radius: 3px;\n padding: 0.2em 0.4em;\n border-radius: 3px;\n font-size: 85%;\n tab-size: 2;\n }\n\n code {\n color: #eb5757;\n }\n\n .code {\n padding: 1.5em 1em;\n }\n\n .code-wrap {\n white-space: pre-wrap;\n word-break: break-all;\n }\n\n .code > code {\n background: none;\n padding: 0;\n font-size: 100%;\n color: inherit;\n }\n\n blockquote {\n font-size: 1.25em;\n margin: 1em 0;\n padding-left: 1em;\n border-left: 3px solid rgb(55, 53, 47);\n }\n\n .bookmark {\n text-decoration: none;\n max-height: 8em;\n padding: 0;\n display: flex;\n width: 100%;\n align-items: stretch;\n }\n\n .bookmark-title {\n font-size: 0.85em;\n overflow: hidden;\n text-overflow: ellipsis;\n height: 1.75em;\n white-space: nowrap;\n }\n\n .bookmark-text {\n display: flex;\n flex-direction: column;\n }\n\n .bookmark-info {\n flex: 4 1 180px;\n padding: 12px 14px 14px;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n }\n\n .bookmark-image {\n width: 33%;\n flex: 1 1 180px;\n display: block;\n position: relative;\n object-fit: cover;\n border-radius: 1px;\n }\n\n .bookmark-description {\n color: rgba(55, 53, 47, 0.6);\n font-size: 0.75em;\n overflow: hidden;\n max-height: 4.5em;\n word-break: break-word;\n }\n\n .bookmark-href {\n font-size: 0.75em;\n margin-top: 0.25em;\n }\n\n .sans {\n font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont,\n \"Segoe UI\", Helvetica, \"Apple Color Emoji\", Arial, sans-serif,\n \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n }\n .code {\n font-family: \"SFMono-Regular\", Menlo, Consolas, \"PT Mono\",\n \"Liberation Mono\", Courier, monospace;\n }\n .serif {\n font-family: Lyon-Text, Georgia, ui-serif, serif;\n }\n .mono {\n font-family: iawriter-mono, Nitti, Menlo, Courier, monospace;\n }\n .pdf .sans {\n font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,\n \"Segoe UI\", Helvetica, \"Apple Color Emoji\", Arial, sans-serif,\n \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Twemoji\", \"Noto Color Emoji\",\n \"Noto Sans CJK JP\";\n }\n .pdf:lang(zh-CN) .sans {\n font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,\n \"Segoe UI\", Helvetica, \"Apple Color Emoji\", Arial, sans-serif,\n \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Twemoji\", \"Noto Color Emoji\",\n \"Noto Sans CJK SC\";\n }\n .pdf:lang(zh-TW) .sans {\n font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,\n \"Segoe UI\", Helvetica, \"Apple Color Emoji\", Arial, sans-serif,\n \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Twemoji\", \"Noto Color Emoji\",\n \"Noto Sans CJK TC\";\n }\n .pdf:lang(

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

How this works

This workflow automates intelligent email responses by analysing incoming messages with OpenAI to generate personalised replies, saving you hours of manual drafting and ensuring consistent communication. It's ideal for busy professionals, customer support teams, or anyone managing high email volumes who wants AI-assisted efficiency without losing a human touch. The key step involves the Gmail trigger detecting new emails, followed by OpenAI crafting a tailored response that's then sent back via Gmail, with optional logging to Google Sheets for tracking.

Use this workflow when you receive frequent similar emails, such as inquiries or feedback, that benefit from quick, context-aware replies to maintain engagement. Avoid it for highly sensitive or legal communications requiring human oversight, or if your email volume is too low to justify automation. Common variations include adding filters for specific senders or integrating with Google Sheets to archive conversation histories for reporting.

About this workflow

Code. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.

Source: https://github.com/Zie619/n8n-workflows — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

Send A Chatgpt Email Reply And Save Responses To Google Sheets. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.

OpenAI, Gmail Trigger, Gmail +2
Email & Gmail

This workflow sends a OpenAI GPT reply when an email is received from specific email recipients. It then saves the initial email and the GPT response to an automatically generated Google spreadsheet.

OpenAI, Gmail Trigger, Gmail +2
Email & Gmail

n8n Recruitment. Uses gmailTrigger, openAi, googleSheets, gmail. Event-driven trigger; 20 nodes.

Gmail Trigger, OpenAI, Google Sheets +4
Email & Gmail

Email AI Agent. Uses gmailTrigger, textClassifier, lmChatOpenAi, gmail. Event-driven trigger; 18 nodes.

Gmail Trigger, Text Classifier, OpenAI Chat +3
Email & Gmail

Email Auto-Responder AI. Uses gmailTrigger, openAi, gmail, googleSheets. Event-driven trigger; 6 nodes.

Gmail Trigger, OpenAI, Gmail +1