{ "meta": { "instanceId": "workflow-aee03af3", "versionId": "1.0.0", "createdAt": "2025-09-29T07:07:43.510223", "updatedAt": "2025-09-29T07:07:43.510235", "owner": "n8n-user", "license": "MIT", "category": "automation", "status": "active", "priority": "high", "environment": "production" }, "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": "YOUR_TOKEN_HERE" } }, "credentials": { "openAiApi": { "id": "{{ $credentials.openAiApi.id }}", "name": "[UPDATE ME]" } }, "typeVersion": 1, "notes": "This openAi node performs automated tasks as part of the workflow." }, { "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": { "id": "{{ $credentials.gmailOAuth2.id }}", "name": "[UPDATE ME]" } }, "typeVersion": 1, "notes": "This gmailTrigger node performs automated tasks as part of the workflow." }, { "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, "notes": "This if node performs automated tasks as part of the workflow." }, { "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, "notes": "This set node performs automated tasks as part of the workflow." }, { "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]({{ $env.WEBHOOK_URL }}\n__`replyTokenSize`(required)__: The reply's maximum token size. Default is 300. This determines how much text the AI will reply with." }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "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": { "id": "{{ $credentials.gmailOAuth2.id }}", "name": "[UPDATE ME]" } }, "typeVersion": 2, "notes": "This gmail node performs automated tasks as part of the workflow." }, { "id": "f845aa4d-5542-4126-a42d-4e5afa1893d1", "name": "Generate UUID", "type": "n8n-nodes-base.crypto", "position": [ -1140, 2360 ], "parameters": { "action": "generate", "dataPropertyName": "uuid" }, "typeVersion": 1, "notes": "This crypto node performs automated tasks as part of the workflow." }, { "id": "3c468585-4546-439b-9e8a-efb7231277d8", "name": "Thanks for your response!", "type": "n8n-nodes-base.html", "position": [ -1140, 2980 ], "parameters": { "html": "\n\n\n\n \n Thanks for your response!\n\n\n
\n

Thanks for your response!

\n

You can safely close this window.

\n
\n\n\n\n\n\n" }, "typeVersion": 1, "notes": "This html node performs automated tasks as part of the workflow." }, { "id": "6b0bfa33-84ca-4b9c-98ec-c1bc08a1230d", "name": "Extract message content (advanced)", "type": "n8n-nodes-base.code", "position": [ -920, 2360 ], "parameters": { "jsCode": "// source: {{ $env.WEBHOOK_URL }}\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-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&&tf))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=[/^\\s*(On(?:(?!.*On\\b|\\bwrote:)[\\s\\S])+wrote:)$/m,/^\\s*(Le(?:(?!.*Le\\b|\\bécrit:)[\\s\\S])+écrit :)$/m,/^\\s*(El(?:(?!.*El\\b|\\bescribió:)[\\s\\S])+escribió:)$/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ł(\\(a\\))?):)$/mu,/^\\s*(Den\\s.+\\sskrev\\s.+:)$/m,/^\\s*(Am\\s.+\\sum\\s.+\\sschrieb\\s.+:)$/m,/^(在[\\S\\s]+写道:)$/m,/^(20[0-9]{2}\\..+\\s작성:)$/m,/^(20[0-9]{2}\\/.+のメッセージ:)$/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 \n \n Template for ChatGPT email\n \n \n \n
\n
\n

\n {{ $json.text }}\n

\n
\n \n

\n Was this message helpful? Yes No\n

\n

\n
\n
\n \n\n" }, "typeVersion": 1, "notes": "This html node performs automated tasks as part of the workflow." }, { "id": "38e0f992-a461-4bc1-9f5c-2ceb0e461708", "name": "Record feedback", "type": "n8n-nodes-base.noOp", "position": [ -1360, 2980 ], "parameters": {}, "typeVersion": 1, "notes": "This noOp node performs automated tasks as part of the workflow." }, { "id": "899a0c63-0333-4dc4-ba83-5615a38ae431", "name": "Fallback route", "type": "n8n-nodes-base.noOp", "position": [ -1360, 3280 ], "parameters": {}, "typeVersion": 1, "notes": "This noOp node performs automated tasks as part of the workflow." }, { "id": "2fd5b109-8a54-4684-a8a3-3f7b2d961ae3", "name": "Identify trigger #2", "type": "n8n-nodes-base.set", "position": [ -2240, 2940 ], "parameters": { "values": { "string": [ { "name": "triggeredFrom", "value": "webhook" } ] }, "options": {} }, "typeVersion": 1, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "8c27f798-d947-432c-bfc9-d22727d0159e", "name": "Identify trigger #1", "type": "n8n-nodes-base.set", "position": [ -2240, 2680 ], "parameters": { "values": { "string": [ { "name": "triggeredFrom", "value": "gmail" } ] }, "options": {} }, "typeVersion": 1, "notes": "This set node performs automated tasks as part of the workflow." }, { "id": "bd8cc1dd-3643-4d2f-9527-cfd740a4072a", "name": "Do not send unfinished email reply", "type": "n8n-nodes-base.noOp", "position": [ -40, 2060 ], "parameters": {}, "typeVersion": 1, "notes": "This noOp node performs automated tasks as part of the workflow." }, { "id": "c8b68fdb-c1c0-4f94-b712-e0570a3ad53c", "name": "If reply is complete", "type": "n8n-nodes-base.if", "position": [ -260, 1960 ], "parameters": { "conditions": { "string": [ { "value1": "={{ $json.finish_reason }}", "value2": "stop" } ] } }, "typeVersion": 1, "notes": "This if node performs automated tasks as part of the workflow." }, { "id": "f9d56d42-aa4e-4394-8c83-8d39164a784e", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [ -100, 2020 ], "parameters": { "width": 225.59802712700315, "height": 314.2786683107279, "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf your workflow reaches this stage, you will need to consider increasing the tokens in `Generate reply` node." }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "039714b3-88ac-4ca8-86fc-ec1c109110c3", "name": "Do not send email to this recipient", "type": "n8n-nodes-base.noOp", "position": [ -1140, 2560 ], "parameters": {}, "typeVersion": 1, "notes": "This noOp node performs automated tasks as part of the workflow." }, { "id": "330c67dd-e538-414d-a144-e05dbf5effb3", "name": "Send reply to database", "type": "n8n-nodes-base.noOp", "position": [ -260, 2380 ], "parameters": {}, "typeVersion": 1, "notes": "This noOp node performs automated tasks as part of the workflow." }, { "id": "6e7586db-f437-4450-a1c7-e5ea7e8767b0", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [ -3060, 2520 ], "parameters": { "width": 516.6954377311955, "height": 680.5491163173024, "content": "## Send a ChatGPT email reply when email received and save responses to Google Sheets\nThis 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. Subsequent GPT responses will be added to the same spreadsheet. Additionally, when feedback is given for any of the GPT responses, it will be recorded to the spreasheet, which can then be used later to fine-tune the GPT model.\n\n### How it works\nThis workflow is essentially a two-in-one workflow. It triggers off from two different nodes and have very different functionality from each trigger.\n\n**`On email received`**:\n1. Triggers off on the `On email received` node.\n2. Extract the email body from the email.\n3. Generate a response from the email body using the `OpenAI` node.\n4. Reply to the email sender using the `Send reply to recipient` node. A feedback link is also included in the email body which will trigger the `On feedback given` node. This is used to fine-tune the GPT model.\n5. Save the email body and OpenAI response to a Google Sheet. If a sheet does not exist, it will be created.\n\n\n**`On feedback given`**:\n1. Triggers off when a feedback link is clicked in the emailed GPT response.\n2. The feedback, either positive or negative, for that specific GPT response is then recorded to the Google Sheet.\n" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "9d5e780e-4282-4c7e-b083-3f769f7dc740", "name": "Determine which trigger ran", "type": "n8n-nodes-base.switch", "position": [ -1660, 2800 ], "parameters": { "rules": { "rules": [ { "value2": "gmail" }, { "output": 1, "value2": "webhook" } ] }, "value1": "={{ $json.triggeredFrom }}", "dataType": "string", "fallbackOutput": 3 }, "typeVersion": 1, "notes": "This switch node performs automated tasks as part of the workflow." }, { "id": "2c6c604c-7f59-42cc-9ed2-6d55f342f0ae", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [ -1420, 3240 ], "parameters": { "width": 225.59802712700315, "height": 289.61775585696694, "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\nThis workflow should never reach this node. It is only here for extending the functionality of this workflow if needed." }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." }, { "id": "3defbf98-0caa-49b1-9bfd-f4640b43d64b", "name": "Is text within token limit?", "type": "n8n-nodes-base.if", "position": [ -700, 2360 ], "parameters": { "conditions": { "boolean": [ { "value1": "={{ $json.reply.length() / 4 <= $('Configure').first().json.maxTokenSize - $('Configure').first().json.replyTokenSize }}", "value2": true } ] } }, "typeVersion": 1, "notes": "This if node performs automated tasks as part of the workflow." }, { "id": "b268b8a3-6361-4515-a995-320cd0979688", "name": "Do nothing", "type": "n8n-nodes-base.noOp", "position": [ -480, 2460 ], "parameters": {}, "typeVersion": 1, "notes": "This noOp node performs automated tasks as part of the workflow." }, { "id": "413588d1-ede0-4a51-85fa-c9035ec2e605", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "position": [ -540, 2420 ], "parameters": { "width": 225.59802712700315, "height": 288.2949081608216, "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThe email that was received is too large to process, as it exceeds token limit. See more on [token limits]({{ $env.WEBHOOK_URL }}" }, "typeVersion": 1, "notes": "This stickyNote node performs automated tasks as part of the workflow." } ], "connections": { "8e2f4a3b-d224-4248-9682-184a646e022f": { "main": [ [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-e7a8133c", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-5dc9d45f", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-739ec86d", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-a9876dac", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-8e35d71f", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-972d7066", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-338ce323", "type": "main", "index": 0 } ], [ { "node": "error-handler-8e2f4a3b-d224-4248-9682-184a646e022f-b74426a2", "type": "main", "index": 0 } ] ] }, "d2a720d4-8487-4dfa-bdb8-6b59368e44bc": { "main": [ [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-b13cf74c", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-8f8bc136", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-4328db23", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-050c9757", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-91575150", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-2e91dc4e", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-039af6ce", "type": "main", "index": 0 } ], [ { "node": "error-handler-d2a720d4-8487-4dfa-bdb8-6b59368e44bc-f46854fc", "type": "main", "index": 0 } ] ] }, "88c0f64c-a7cd-4f35-96dd-9eee4b1d6a1a": { "main": [ [ { "node": "error-handler-88c0f64c-a7cd-4f35-96dd-9eee4b1d6a1a-67122ac9", "type": "main", "index": 0 } ] ] }, "ab0348c2-f688-42d3-815b-63290e95baad": { "main": [ [ { "node": "error-handler-ab0348c2-f688-42d3-815b-63290e95baad-ec7b6ac5", "type": "main", "index": 0 } ] ] }, "ba62fd4d-912b-4b37-9fda-2f80cdeb65f8": { "main": [ [ { "node": "error-handler-ba62fd4d-912b-4b37-9fda-2f80cdeb65f8-12620144", "type": "main", "index": 0 } ] ] }, "efdb343d-f5bf-4ba4-bc27-850b9e7935ac": { "main": [ [ { "node": "error-handler-efdb343d-f5bf-4ba4-bc27-850b9e7935ac-cbb3e7b1", "type": "main", "index": 0 } ] ] }, "87506e44-21aa-4f08-82f9-f47a24ddb9ce": { "main": [ [ { "node": "error-handler-87506e44-21aa-4f08-82f9-f47a24ddb9ce-8a860ea4", "type": "main", "index": 0 } ] ] } }, "name": "Openai Workflow", "settings": { "executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner", "errorWorkflow": null, "timezone": "UTC", "executionTimeout": 3600, "maxExecutions": 1000, "retryOnFail": true, "retryCount": 3, "retryDelay": 1000 }, "description": "Automated workflow: Openai Workflow. This workflow integrates 15 different services: webhook, stickyNote, code, gmailTrigger, switch. It contains 58 nodes and follows best practices for error handling and security.", "tags": [ "automation", "n8n", "production-ready", "excellent", "optimized" ], "notes": "Excellent quality workflow: Openai Workflow. This workflow has been optimized for production use with comprehensive error handling, security, and documentation." }