{
  "id": "GvlLeSOUPfar0DQS",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automate Product Data Collection & Customer Support via WhatsApp + GPT-4 + Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "370611ee-2725-4ee4-a73a-68d4eaabfe3a",
      "name": "WhatsApp Business Cloud",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1020,
        220
      ],
      "parameters": {
        "textBody": "={{ $json.output }}",
        "operation": "send",
        "phoneNumberId": "574583382412256",
        "additionalFields": {},
        "recipientPhoneNumber": "+212722542056"
      },
      "credentials": {
        "whatsAppApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "30520fe8-a423-4942-85b2-9e8776b45939",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -740,
        -20
      ],
      "parameters": {
        "width": 400,
        "height": 440,
        "content": "## \ud83d\udfe1 1\ub2e8\uacc4 \u2013 WhatsApp \uba54\uc2dc\uc9c0 \uc218\uc2e0\n\n\uc0c8 WhatsApp \uba54\uc2dc\uc9c0\ub97c \uac10\uc9c0\ud569\ub2c8\ub2e4.\n\n\uba54\uc2dc\uc9c0\uac00 train:\uc73c\ub85c \uc2dc\uc791\ud558\uba74, \uc81c\ud488 \ud6c8\ub828 \ud750\ub984\uc744 \ud2b8\ub9ac\uac70\ud569\ub2c8\ub2e4.\n\n\uadf8\ub807\uc9c0 \uc54a\uc73c\uba74, \uace0\uac1d \uc9c0\uc6d0 \ud750\ub984\uc73c\ub85c \uc774\ub3d9\ud569\ub2c8\ub2e4.\n\n**WhatsApp Business Cloud \ub178\ub4dc** : [\uc5ec\uae30](https://www.notion.so/automatisation/WHATSAPP-WORKFLOW-1c63d6550fd980559679e7535938a68d?pvs=4#1c63d6550fd980f9a2a5e25a3654da82)"
      },
      "typeVersion": 1
    },
    {
      "id": "d3259e0e-5368-407d-8ac6-993784c939c9",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        280
      ],
      "parameters": {
        "color": 6,
        "width": 1180,
        "height": 420,
        "content": "## \ud83d\udd35 3\ub2e8\uacc4 \u2013 \uace0\uac1d \uc9c0\uc6d0 \ud750\ub984  \n\uba54\uc2dc\uc9c0\uac00 `train:`\uc73c\ub85c \uc2dc\uc791\ud558\uc9c0 \uc54a\uc744 \ub54c \ud2b8\ub9ac\uac70\ub429\ub2c8\ub2e4.  \n\n1. **AI\uac00 \uba54\uc2dc\uc9c0\ub97c \ubd84\uc11d\ud569\ub2c8\ub2e4**  \n   \uace0\uac1d\uc758 \uc9c8\ubb38\uc774\ub098 \ubb38\uc81c\ub97c \uc774\ud574\ud569\ub2c8\ub2e4.  \n\n2. **\ud544\uc694 \uc2dc \uc81c\ud488 \ub370\uc774\ud130\ub97c \uac00\uc838\uc635\ub2c8\ub2e4**  \n   Google Sheets\uc5d0\uc11c \uad00\ub828 \uc81c\ud488 \uc815\ubcf4\ub97c \uc77d\uc2b5\ub2c8\ub2e4.  \n\n3. **\ubb38\uc81c\ub97c \uc790\ub3d9\uc73c\ub85c \uac10\uc9c0\ud569\ub2c8\ub2e4**  \n   \uc0ac\uc6a9\uc790\uac00 \uc9c1\uba74\ud55c \ud2b9\uc815 \ubb38\uc81c\ub97c \uc2dd\ubcc4\ud569\ub2c8\ub2e4.  \n\n4. **\ud574\uacb0\ucc45\uc744 \uc81c\uc548\ud569\ub2c8\ub2e4**  \n   \ubb38\uc81c\ub97c \ud574\uacb0\ud558\uae30 \uc704\ud574 \ub3c4\uc6c0\uc774 \ub418\uace0 \uba85\ud655\ud55c \uc751\ub2f5\uc744 \uc81c\uc548\ud569\ub2c8\ub2e4.  \n\n5. **\uace0\uac1d \ubb38\uc81c\ub97c \uae30\ub85d\ud569\ub2c8\ub2e4**  \n   \ubb38\uc81c\ub97c, \uc81c\uc548\ub41c \ud574\uacb0\ucc45, \uadf8\ub9ac\uace0 \uce74\ud14c\uace0\ub9ac\ub97c \uc800\uc7a5\ud569\ub2c8\ub2e4.  \n\n6. **\uc0ac\uc6a9\uc790\uc5d0\uac8c \uc751\ub2f5\ud569\ub2c8\ub2e4**  \n   \uc804\ubb38\uc801\uc774\uace0 \ub3c4\uc6c0\uc774 \ub418\ub294 WhatsApp \ub2f5\ubcc0\uc744 \ubcf4\ub0c5\ub2c8\ub2e4."
      },
      "typeVersion": 1
    },
    {
      "id": "455ce4ab-6d14-4d4e-8ff8-04612cf532b9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        -400
      ],
      "parameters": {
        "color": 3,
        "width": 1180,
        "height": 660,
        "content": "## \ud83d\udd34 \ub2e8\uacc4 2 \u2013 \uc81c\ud488 \ub370\uc774\ud130 \ud6c8\ub828 (train:\uc5d0 \uc758\ud574 \ud2b8\ub9ac\uac70\ub428)  \n\ud2b8\ub9ac\uac70\ub41c \uacbd\uc6b0: \uba54\uc2dc\uc9c0\uac00 `train:`\uc73c\ub85c \uc2dc\uc791\ud560 \ub54c.  \n**OpenAI API \ud0a4**: [\uc5ec\uae30](https://platform.openai.com/api-keys)  \n\n1. **\uba54\uc2dc\uc9c0\uc5d0\uc11c URL \ucd94\ucd9c**  \n   \uc815\uaddc \ud45c\ud604\uc2dd\uc744 \uc0ac\uc6a9\ud558\uc5ec \uc81c\ud488 \ub9c1\ud06c\ub97c \uac10\uc9c0\ud558\uace0 \ucd94\ucd9c\ud569\ub2c8\ub2e4.  \n\n2. **HTML \ucf58\ud150\uce20 \uac00\uc838\uc624\uae30**  \n   HTTP \uc694\uccad\uc744 \ubcf4\ub0b4 \uc804\uccb4 \ud398\uc774\uc9c0 \ucf58\ud150\uce20\ub97c \uac00\uc838\uc635\ub2c8\ub2e4.  \n\n3. **HTML \ub370\uc774\ud130 \uc815\ub9ac**  \n   HTML \ud0dc\uadf8, \uc2a4\ud06c\ub9bd\ud2b8 \ub4f1\uc744 \uc81c\uac70\ud558\uace0 \ud14d\uc2a4\ud2b8\ub97c \ud615\uc2dd\ud654\ud569\ub2c8\ub2e4.  \n\n4. **\uc6d0\uc2dc \uc81c\ud488 \uc815\ubcf4 \uc800\uc7a5**  \n   \uc815\ub9ac\ub41c \ucf58\ud150\uce20\uc640 URL\uc744 Google Sheets\uc5d0 \ucd94\uac00\ud569\ub2c8\ub2e4.  \n\n5. **AI: \uc81c\ud488 \uc138\ubd80 \uc815\ubcf4 \uac15\ud654**  \n   - \uc81c\ud488 \uc774\ub984 \ucd94\ucd9c  \n   - \uac00\uaca9 \uac10\uc9c0 (\uad6c\ub3c5\ud615 \ub610\ub294 \uc77c\ud68c\uc131)  \n   - \uc81c\ud488 \uc8fc\uc81c \uc2dd\ubcc4  \n   - FAQ \uc0dd\uc131  \n\n6. **\uc81c\ud488 \uc2dc\ud2b8 \uc5c5\ub370\uc774\ud2b8**  \n   \uad6c\uc870\ud654\ub41c \uc81c\ud488 \ub370\uc774\ud130\ub97c Sheets\uc758 \ud589\uc5d0 \ucd94\uac00\ud569\ub2c8\ub2e4."
      },
      "typeVersion": 1
    },
    {
      "id": "15251a04-a139-4a71-9e96-d5ecd9c2e66c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        920,
        -20
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 440,
        "content": "## \ud83d\udfe2 STEP 4 \u2013 \ud074\ub77c\uc774\uc5b8\ud2b8 \uc751\ub2f5  \n\ud750\ub984\uc758 \ucd5c\uc885 \ub2e8\uacc4.  \n\n- AI\uac00 \uc0dd\uc131\ud55c \uc751\ub2f5\uc744 WhatsApp\uc744 \ud1b5\ud574 \uace0\uac1d\uc5d0\uac8c \ubcf4\ub0c5\ub2c8\ub2e4.  \n- \uba54\uc2dc\uc9c0\uac00 \uba85\ud655\ud558\uace0, \ub3c4\uc6c0\uc774 \ub418\uba70, \uac1c\uc778\ud654\ub418\uc5c8\uc74c\uc744 \ubcf4\uc7a5\ud569\ub2c8\ub2e4."
      },
      "typeVersion": 1
    },
    {
      "id": "f028f5a3-fed3-4f90-89cc-2af211da7362",
      "name": "Incoming Message Trigger",
      "type": "n8n-nodes-base.whatsAppTrigger",
      "position": [
        -700,
        220
      ],
      "parameters": {
        "options": {},
        "updates": [
          "messages"
        ]
      },
      "credentials": {
        "whatsAppTriggerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "54edaa0c-005e-4810-a2fa-76fbcc009b2b",
      "name": "Check If Training",
      "type": "n8n-nodes-base.switch",
      "position": [
        -520,
        220
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "train",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9865cb5b-33da-490c-afc3-186457d5b564",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $json.messages[0].text.body }}",
                    "rightValue": "train:"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5a9a1fee-b408-469f-a08c-e8d690fc9792",
                    "operator": {
                      "type": "string",
                      "operation": "notStartsWith"
                    },
                    "leftValue": "={{ $json.messages[0].text.body }}",
                    "rightValue": "train:"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "b4187b28-efd9-46cb-8d1c-23d89d3f6125",
      "name": "Extract URL from Text",
      "type": "n8n-nodes-base.code",
      "position": [
        -260,
        -320
      ],
      "parameters": {
        "jsCode": "// R\u00e9cup\u00e9rer le texte \u00e0 analyser depuis l'input\nconst texteExemple = $input.first().json.messages[0].text.body;\n\n// Expression r\u00e9guli\u00e8re modifi\u00e9e pour capturer les URL avec ou sans protocole\nconst regex = /((?:https?:\\/\\/)?(?:www\\.)?[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}(?:\\/\\S*)?)/g;\n\n// Extraction des URL \u00e0 partir du texte\nconst matches = texteExemple.match(regex) || [];\n\n// Si des URL ont \u00e9t\u00e9 trouv\u00e9es, on les mappe en objets\nif (matches.length > 0) {\n    const output = matches.map(url => ({ url }));\n    return output;\n} else {\n    // Si aucune URL n'est trouv\u00e9e, on retourne les items d'entr\u00e9e pour que le workflow continue\n    return $input.all();\n}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "dbbcc8cf-2544-4de1-bcfd-6292d96a1017",
      "name": "Fetch HTML Page",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -100,
        -320
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "91e711d0-26c0-41dd-a9c5-28100f0f44f6",
      "name": "Clean HTML Content",
      "type": "n8n-nodes-base.code",
      "position": [
        60,
        -320
      ],
      "parameters": {
        "jsCode": "// Exemple : r\u00e9cup\u00e9ration du contenu HTML depuis le premier item\n// Si vous avez un champ nomm\u00e9 \"html\" dans un noeud pr\u00e9c\u00e9dent.\nconst htmlContent = $input.first().json.html;\n\n// Fonction de nettoyage du HTML\nfunction nettoyerHTML(input) {\n  if (typeof input !== 'string') {\n    throw new Error(\"Expected HTML content as a string.\");\n  }\n  let cleanedText = input;\n\n  // 1. Retirer les liens <a> et leur contenu\n  cleanedText = cleanedText.replace(/<a[^>]*>.*?<\\/a>/gs, '');\n\n  // 2. Retirer <script>, <style>, commentaires, etc.\n  cleanedText = cleanedText.replace(/<script[^>]*>.*?<\\/script>/gs, '');\n  cleanedText = cleanedText.replace(/<style[^>]*>.*?<\\/style>/gs, '');\n  cleanedText = cleanedText.replace(/<!--[\\s\\S]*?-->/g, '');\n\n  // 3. Ins\u00e9rer des retours \u00e0 la ligne pour certaines balises\n  cleanedText = cleanedText.replace(/<h[1-6][^>]*>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<\\/h[1-6]>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<p[^>]*>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<\\/p>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<ul[^>]*>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<\\/ul>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<ol[^>]*>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<\\/ol>/gi, '\\n');\n  cleanedText = cleanedText.replace(/<li[^>]*>/gi, '- ');\n  cleanedText = cleanedText.replace(/<\\/li>/gi, '\\n');\n\n  // 4. Supprimer toutes les balises HTML restantes\n  cleanedText = cleanedText.replace(/<[^>]+>/g, '');\n\n  // 5. Supprimer (ou ajuster) les caract\u00e8res sp\u00e9ciaux\n  cleanedText = cleanedText.replace(/[^\\w\\s\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff]+/g, '');\n\n  // 6. Normaliser les espaces multiples et trim\n  cleanedText = cleanedText.replace(/\\s+/g, ' ').trim();\n\n  return cleanedText;\n}\n\n// Nettoyage\nconst result = nettoyerHTML($input.first().json.data);\n\n// Retour d'un tableau contenant l'objet final\nreturn [\n  {\n    json: {\n      cleanedText: result\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "7e457450-42ef-417e-b5f9-3248c9c7c2ae",
      "name": "Save Raw Product Info",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        240,
        -320
      ],
      "parameters": {
        "columns": {
          "value": {
            "Product Link": "={{ $('Extract URL from Text').item.json.url }}",
            "Product Description": "={{ $json.cleanedText }}"
          },
          "schema": [
            {
              "id": "Product Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Topic",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Topic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 689245338,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit#gid=689245338",
          "cachedResultName": "Products"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit?usp=drivesdk",
          "cachedResultName": "Product Sales - AI Agent WhatsApp"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "d3dfa439-4056-4ce9-b874-100500967de6",
      "name": "OpenAI Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        320,
        -40
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "10217317-f6dd-4890-b05d-197d3d2adb79",
      "name": "Short-Term Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        500,
        -40
      ],
      "parameters": {
        "sessionKey": "={{ $('Incoming Message Trigger').item.json.messages[0].id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 50
      },
      "typeVersion": 1.3
    },
    {
      "id": "58ce0f46-fabc-4b6e-97d7-857dc6f1e568",
      "name": "Update Product Sheet",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        680,
        -40
      ],
      "parameters": {
        "columns": {
          "value": {
            "F&Q": "={{ $fromAI(\"product_faq\", \"these are the most common questions users might have about the product, including answers if available\") }}\n",
            "Product Link": "={{ $fromAI(\"product_url\",\"this is the website link of the product\") }}",
            "Product Name": "={{ $fromAI(\"product_name\",\"this is the name of the product\") }}",
            "Product Price": "={{ $fromAI(\"product_price\",\"this is the price of the product\") }}",
            "Product Topic": "={{ $fromAI(\"product_topic\",\"this is the topic of the product that specifies what it is for, who it is for and what the key benefits are\") }}"
          },
          "schema": [
            {
              "id": "Product Link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Product Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Description",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Product Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Product Topic",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Product Topic",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "F&Q",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "F&Q",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Product Link"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 689245338,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit#gid=689245338",
          "cachedResultName": "Products"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit?usp=drivesdk",
          "cachedResultName": "Product Sales - AI Agent WhatsApp"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "020714ae-5668-4fa5-8ba8-f1e476a8060e",
      "name": "AI Agent -  Customer Support Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        380,
        300
      ],
      "parameters": {
        "text": "={{ $json.messages[0].text.body }}",
        "options": {
          "systemMessage": "You are a helpful and intelligent customer support assistant.\n\nYou have access to a Google Sheets tool that allows you to read any content from a specific sheet to gather necessary information.\nNever mention to the user that you accessed Google Sheets to retrieve any data.\n\nYour main responsibilities:\n\nUnderstand the user\u2019s request or issue.\n\nIf the user is asking about a product, retrieve the relevant product name, price, and details as needed.\n\nDetermine whether the product price is a subscription or a one-time payment, based on the description.\n\nIf you detect that the user is facing a problem:\n\nIdentify and describe the problem clearly.\n\nPropose a practical and helpful solution.\n\nLog this interaction by adding a new row to the Google Sheet with the following columns:\n\nProblem\n\nSuggested Solution\n\nCategory (e.g., payment, login, access, delivery, technical issue, etc.)\n\nBe professional, concise, and empathetic in your responses.\nAlways aim to resolve the issue or provide the next best action."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "53e49985-e1b9-48fd-9ea8-3352a63484e0",
      "name": "AI Agent - Enhance Product Details",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        420,
        -320
      ],
      "parameters": {
        "text": "=My product description :  {{ $json['Product Description'] }}\n\nMy product link : {{ $json['Product Link'] }}",
        "options": {
          "systemMessage": "You are a helpful and intelligent assistant.\n\nYou receive the text content of a product page.\n\nYour tasks are:\n\nExtract the product name.\n\nExtract the product price, and determine whether it is a subscription or a one-time payment.\n\nIdentify the product topic.\n\nExtract the most frequently asked questions (FAQs) related to the product.\n\nYou have access to a Google Sheets tool that allows you to update specific columns and cells.\n\nAlways add the following data to the same row as the product URL in the Google Sheet:\n\nProduct Name\n\nProduct Price (with subscription/one-time label)\n\nProduct Topic\n\nFAQs\n\nBe accurate, structured, and consistent when filling in the sheet.\nDo not mention Google Sheets in your responses."
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "194136b5-872a-492b-882b-d26a2890cbcf",
      "name": "OpenAI Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        220,
        560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "efc89a9b-3141-4735-adaf-7b9e2b6879ed",
      "name": "Conversation Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        400,
        560
      ],
      "parameters": {
        "sessionKey": "={{ $json.messages[0].id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 50
      },
      "typeVersion": 1.3
    },
    {
      "id": "d1a21094-0237-4b17-818c-3af7760b405f",
      "name": "Read Product Sheet",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        560,
        560
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "readRowsUntil": "firstEmptyRow",
              "rangeDefinition": "detectAutomatically"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 689245338,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit#gid=689245338",
          "cachedResultName": "Products"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit?usp=drivesdk",
          "cachedResultName": "Product Sales - AI Agent WhatsApp"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2c2dcf9b-5578-4bd4-85b6-27621927a0a0",
      "name": "Log Customer Issues",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        740,
        560
      ],
      "parameters": {
        "columns": {
          "value": {
            "Category": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Category', ``, 'string') }}",
            "Solution": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Solution', ``, 'string') }}",
            "Support Problem": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Support_Problem', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "Support Problem",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Support Problem",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Solution",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Solution",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1725207764,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit#gid=1725207764",
          "cachedResultName": "Customer Issues"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1wa41S888Ya3sqEkBdzYiDq-5FOu_V30BOe-toX_78xQ/edit?usp=drivesdk",
          "cachedResultName": "Product Sales - AI Agent WhatsApp"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2e8ea310-e164-4d5d-ae0b-ade129b07a4a",
  "connections": {
    "OpenAI Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Enhance Product Details",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent -  Customer Support Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch HTML Page": {
      "main": [
        [
          {
            "node": "Clean HTML Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Training": {
      "main": [
        [
          {
            "node": "Extract URL from Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent -  Customer Support Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Short-Term Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent - Enhance Product Details",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Clean HTML Content": {
      "main": [
        [
          {
            "node": "Save Raw Product Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Product Sheet": {
      "ai_tool": [
        [
          {
            "node": "AI Agent -  Customer Support Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Conversation Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent -  Customer Support Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Log Customer Issues": {
      "ai_tool": [
        [
          {
            "node": "AI Agent -  Customer Support Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Update Product Sheet": {
      "ai_tool": [
        [
          {
            "node": "AI Agent - Enhance Product Details",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Extract URL from Text": {
      "main": [
        [
          {
            "node": "Fetch HTML Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Raw Product Info": {
      "main": [
        [
          {
            "node": "AI Agent - Enhance Product Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Business Cloud": {
      "main": [
        []
      ]
    },
    "Incoming Message Trigger": {
      "main": [
        [
          {
            "node": "Check If Training",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent -  Customer Support Agent": {
      "main": [
        [
          {
            "node": "WhatsApp Business Cloud",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Enhance Product Details": {
      "main": [
        [
          {
            "node": "WhatsApp Business Cloud",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}