{
  "id": "7O58hqKnq3tiUEoy",
  "name": "eCommerce Ai Agent ( Telegram Bot )",
  "tags": [],
  "nodes": [
    {
      "id": "28dd9f4c-d48d-4926-822a-517edeae5824",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        96,
        112
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "de4ce1b1-e985-4e74-8fd8-c6e2bca4eba2",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        768,
        112
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "=# role : \nYou are an AI Store Manager for a WooCommerce Digital Product Store that sells ebooks.\nYou operate inside an automation system (n8n) and can perform real actions such as reading data, updating products, managing orders and preparing customer emails.\n\nYour job is to understand user commands from Telegram and execute the correct store operations using available tools.\n\nWhen the command /start is active or when i say 'Hello' always greet me with 'Salam Alkiom Mohamed, how can i help you today'.\n\n# Tools\n- use 'Get Orders' to get orders information.\n- use 'Database' to store the orders information.\n- use Gmail to send emails to clients when asked to.\n\n# Supported Languages\nBased on the output from Telegram You can generate responses and emails in:\n\n- English\n- Arabic (Modern Standard Arabic)\n- Moroccan Arabic (Darija) \u2014 only for chat replies not emails\n- French (if requested)\n\n# Context\nCurrent date and time: {{ $now }}\n"
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "6fc9fcaa-9a81-49dd-80a3-683344be2096",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        384,
        336
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "08e3901a-3616-4fd2-945e-c5a4e752167a",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        512,
        336
      ],
      "parameters": {
        "sessionKey": "={{ $json.message.chat.id }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 20
      },
      "typeVersion": 1.3
    },
    {
      "id": "8383f59f-2d25-470f-924c-d06d7d2d4fdf",
      "name": "Get orders",
      "type": "n8n-nodes-base.wooCommerceTool",
      "position": [
        704,
        336
      ],
      "parameters": {
        "options": {},
        "resource": "order",
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "credentials": {
        "wooCommerceApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1203dff9-09a8-44a0-ae02-c469ab02f0cb",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1728,
        112
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bc4b6404-9e9a-40ca-a929-4583d116e74e",
      "name": "Get products",
      "type": "n8n-nodes-base.wooCommerceTool",
      "position": [
        832,
        336
      ],
      "parameters": {
        "options": {},
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "credentials": {
        "wooCommerceApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d1259eb2-4893-4864-b42d-e1503d8be6a0",
      "name": "Update product",
      "type": "n8n-nodes-base.wooCommerceTool",
      "position": [
        960,
        336
      ],
      "parameters": {
        "imagesUi": {},
        "resource": "product",
        "operation": "update",
        "productId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Product_ID', ``, 'string') }}",
        "metadataUi": {},
        "dimensionsUi": {},
        "updateFields": {
          "name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Name', ``, 'string') }}",
          "salePrice": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Sale_Price', ``, 'string') }}",
          "description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}",
          "manageStock": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Manage_Stock', ``, 'boolean') }}",
          "regularPrice": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Regular_Price', ``, 'string') }}",
          "stockQuantity": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Stock_Quantity', ``, 'number') }}",
          "shortDescription": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Short_Description', ``, 'string') }}"
        },
        "descriptionType": "auto"
      },
      "credentials": {
        "wooCommerceApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2caa58ad-bdf8-4fe5-93e3-84cb0f949b68",
      "name": "database",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1168,
        352
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Status', ``, 'string') }}",
            "Country": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Country', ``, 'string') }}",
            "Order ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Order_ID__using_to_match_', ``, 'string') }}",
            "Quantity": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Quantity', ``, 'string') }}",
            "Date Paid": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Date_Paid', ``, 'string') }}",
            "Last Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Last_Name', ``, 'string') }}",
            "First Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('First_Name', ``, 'string') }}",
            "Items Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Items_Name', ``, 'string') }}",
            "Order Date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Order_Date', ``, 'string') }}",
            "Customer Note": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Customer_Note', ``, 'string') }}",
            "Customer Email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Customer_Email', ``, 'string') }}",
            "Payment Method": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Payment_Method', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "Order ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Order ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Items Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Items Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Quantity",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Quantity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Order Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Order Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Customer Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "First Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "First Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Last Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Country",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Payment Method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Payment Method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Note",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Customer Note",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date Paid",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Date Paid",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Order ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1_zPBSN4sD4Tz-jlaY-B2yMI83_6AzRx-NCHrSHrgV5I/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1_zPBSN4sD4Tz-jlaY-B2yMI83_6AzRx-NCHrSHrgV5I",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1_zPBSN4sD4Tz-jlaY-B2yMI83_6AzRx-NCHrSHrgV5I/edit?usp=drivesdk",
          "cachedResultName": "woocoomerce database"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "15ae2cdd-5790-432d-88d7-db5ec38a8928",
      "name": "Send email",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        1312,
        352
      ],
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "senderName": "Morocco vibe",
          "appendAttribution": false
        },
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3d20a9ca-d434-4ea4-94a9-4dffea13cd5d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -112
      ],
      "parameters": {
        "width": 608,
        "height": 912,
        "content": "Telegram AI eCommerce Agent for WooCommerce\n\n@[youtube](cO5SazP1eNI)\n\n\n\nThis workflow allows you to manage your WooCommerce store directly from Telegram using an AI assistant.\n\nFeatures:\n\u2022 Get orders\n\u2022 Retrieve products\n\u2022 Update product information\n\u2022 Store data in Google Sheets\n\u2022 Send emails\n\nSetup Steps:\n1. Connect Telegram credentials\n2. Add WooCommerce API keys\n3. Connect Google Sheets\n4. Connect Gmail\n5. Add OpenRouter/OpenAI API key\n\nUse cases:\n\u2022 Sales monitoring\n\u2022 Product updates\n\u2022 Customer support\n\u2022 Store reporting\n\nSend commands via Telegram to interact with your store conversationally."
      },
      "typeVersion": 1
    },
    {
      "id": "ac309d26-5180-4fd4-8490-7b6517373583",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -16,
        -32
      ],
      "parameters": {
        "color": 6,
        "width": 320,
        "height": 384,
        "content": "## Telegram bot trigger.\n\nReceives user messages and sends them to the AI agent."
      },
      "typeVersion": 1
    },
    {
      "id": "94e64ca4-5015-4b88-8db0-b53e4c4b6dfd",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1616,
        -32
      ],
      "parameters": {
        "color": 6,
        "width": 320,
        "height": 368,
        "content": "## Telegram bot Action .\n\nsends Ai Agent messages to user.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "de3d57d4-4d7b-42ef-a462-3273a552f9ca",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -32
      ],
      "parameters": {
        "color": 4,
        "width": 784,
        "height": 96,
        "content": "## Core AI brain.\nUnderstands user intent and decides which tool to execute.\nPowered by OpenRouter chat model with memory."
      },
      "typeVersion": 1
    },
    {
      "id": "51edaf75-9568-448e-ac88-47ea811216db",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        512
      ],
      "parameters": {
        "width": 416,
        "height": 224,
        "content": "## Woocommerce\n\nStore management tools.\n\nIncludes:\n\u2022 Get orders\n\u2022 Get products\n\u2022 Update products"
      },
      "typeVersion": 1
    },
    {
      "id": "23e2f71f-b975-4366-b1ef-653b4ecfcea3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        512
      ],
      "parameters": {
        "color": 5,
        "width": 416,
        "height": 272,
        "content": "## Google Sheets\n\nDatabase logging.\nStores retrieved or updated store data.\n\n## Gmail\n\nEmail notifications.\nUsed for sending reports or alerts.\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "b694c9e8-22cd-4e92-8bf5-86975a77528c",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "database": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get orders": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send email": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get products": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Update product": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}