{
  "id": "DAU5WFpBTz7nG32DbZg-n",
  "meta": {
    "instanceId": "bbf9adc88f338d1ced357dceaba8bd2f72c26ee04b626d0400768108c4dc860f",
    "templateCredsSetupCompleted": true
  },
  "name": "Find and share AliExpress affiliate products through Telegram",
  "tags": [],
  "nodes": [
    {
      "id": "7f079fe2-1137-4992-b14e-24330966e124",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1408,
        2304
      ],
      "webhookId": "25eec435-bf7b-4c31-b104-6c9b14ddb6ab",
      "parameters": {
        "updates": [
          "message",
          "callback_query"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7a8820af-a1dd-4502-8790-1a38e62ecb48",
      "name": "If2",
      "type": "n8n-nodes-base.if",
      "position": [
        288,
        1824
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c8246e95-f69d-41be-98d2-76249ef79ed2",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.result.status }}",
              "rightValue": "left"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "85cf82ed-c50d-45d6-89b4-aa6cebb7fead",
      "name": "If4",
      "type": "n8n-nodes-base.if",
      "position": [
        512,
        1728
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "14a0a153-4f9c-4928-9406-6c773f1d2c95",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
              "rightValue": "תמצא לי"
            },
            {
              "id": "cdc7381c-24de-441f-8552-b357cd36db70",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
              "rightValue": "תחפש לי"
            },
            {
              "id": "048e53dc-bcba-476f-a650-93c27fa155ce",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
              "rightValue": "חפש לי"
            },
            {
              "id": "b0e935a4-0e71-4a1e-9a38-58e799172b9a",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
              "rightValue": "מצא לי"
            },
            {
              "id": "a47a4cf9-3ffc-4445-87cd-604359ff6f94",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
              "rightValue": "תשלח לי"
            },
            {
              "id": "22cb197b-b0cf-45dc-a07b-63727181c85f",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
              "rightValue": "שלח לי"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0a32a3b9-0932-47cb-b0ca-61e44f4ee88f",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        2848,
        1552
      ],
      "parameters": {
        "jsCode": "const data = $input.all();\n// Check if there is at least one item with code 200\nconst hasSuccess = data.some(item => \n  item.json.aliexpress_affiliate_link_generate_response?.resp_result?.resp_code === 200\n);\nif (hasSuccess) {\n  return data;\n} else {\n  return [{ json: { result: 2 } }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "62406aad-2e3b-4932-8d34-f8700eb031a0",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -736,
        1920
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "GPT-5.2"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "={{ $json.message.text }}"
            },
            {
              "role": "system",
              "content": "=## **Role:**\nAutomatic moderator for groups - checks message content and prevents inappropriate content.\n\n---\n\n## **Objective:**\nIdentify requests or content related to actual illegal activity, sexual content, or links, and return a polite and clear rejection message.\n\n---\n\n## **Context & Assumptions:**\n- The context: WhatsApp/Telegram group\n- \"Illegal\" includes: drugs, real weapons, financial fraud, money laundering, incitement to violence, selling prescription drugs without a license\n- \"Sexual\" includes: pornography, sexual harassment, sharing inappropriate images, explicit sexual requests\n- \"Links\" includes: any URL (http://, https://, www., or URL of any kind)\n- **Looking for legitimate consumer products** (including imitations/fakes of brands) **Allowed** - This is a normal buying activity\n- Borderline content (e.g. light jokes) will **not** be considered problematic unless explicitly stated\n- Language: Hebrew\n\n---\n\n## **Input Format:**\n```\nUser message: [free text]\n```\n\n---\n\n## **Output Format:**\nIf the content is **correct:**\n```json\n{\n  \"status\": \"approved\",\n  \"message\": null\n}\n```\n\nIf the content is **problematic:**\n```json\n{\n  \"status\": \"rejected\",\n  \"reason\": \"[short reason]\",\n  \"message\": \"Your message is not appropriate for the group. We do not allow [topic]. Thank you for understanding.\"\n}\n```\n\n---\n\n## **Rules:**\n1. **Output language:** Hebrew only\n2. **Tone:** Polite, non-judgmental, but firm\n3. **It is forbidden:** to invent reasons, to label normal content as problematic (false positive), to extend transition beyond the need\n4. **Accuracy:** If there is any doubt – **Affirm** (a good lock from a bad engine)\n5. **No explanations beyond what is required** - a short and to the point message\n6. **Any link of any kind = automatic rejection**\n7. **Searching/buying consumer products (also imitations) = approved** - only actual criminal activity is rejected\n\n---\n\n## **Success Criteria:**\n✅ Accurate identification of real problematic content only  \n✅ Identification and blocking of each link  \n✅ **Legitimate product search confirmation** (including replica/fakes)  \n✅ A clear and polite message to the user  \n✅ There are no false positives (correct content is not rejected)  \n✅ The JSON output is correct and ready for use in n8n\n\n---\n\nOutput: {\"status\": \"approved\", \"message\": null}"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIALS_ID",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "3cbbfb07-44a8-4f9a-a6a8-c86dae9a12f1",
      "name": "Code in JavaScript1",
      "type": "n8n-nodes-base.code",
      "position": [
        -384,
        1920
      ],
      "parameters": {
        "jsCode": "// Extract the text from the structure\nconst rawText = $input.first().json.output[0].content[0].text;\n\n// Remove markdown and JSON compression\nconst cleanText = rawText.replace(/```json\\n?/g, '').replace(/```\\n?/g, '').trim();\nconst result = JSON.parse(cleanText);\n\n// return the result\nreturn result;"
      },
      "typeVersion": 2
    },
    {
      "id": "c9f1839f-b180-491a-9f51-26228bc95f80",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -960,
        2304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "111deefc-310e-4300-8317-7f5432fe3ad3",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.callback_query.data }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "8011d518-88bb-433a-95ab-43573974da5e",
      "name": "If3",
      "type": "n8n-nodes-base.if",
      "position": [
        -160,
        2496
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c8246e95-f69d-41be-98d2-76249ef79ed2",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.result.status }}",
              "rightValue": "left"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d8fe0d8b-7ff0-4c77-a314-6e0c850d4a4d",
      "name": "If5",
      "type": "n8n-nodes-base.if",
      "position": [
        64,
        2400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "14a0a153-4f9c-4928-9406-6c773f1d2c95",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.text }}",
              "rightValue": "תמצא לי"
            },
            {
              "id": "cdc7381c-24de-441f-8552-b357cd36db70",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.text }}",
              "rightValue": "תחפש לי"
            },
            {
              "id": "048e53dc-bcba-476f-a650-93c27fa155ce",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.text }}",
              "rightValue": "חפש לי"
            },
            {
              "id": "b0e935a4-0e71-4a1e-9a38-58e799172b9a",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.text }}",
              "rightValue": "מצא לי"
            },
            {
              "id": "a47a4cf9-3ffc-4445-87cd-604359ff6f94",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.text }}",
              "rightValue": "תשלח לי"
            },
            {
              "id": "22cb197b-b0cf-45dc-a07b-63727181c85f",
              "operator": {
                "type": "string",
                "operation": "startsWith"
              },
              "leftValue": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.text }}",
              "rightValue": "שלח לי"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f4dbed57-121b-4463-a09b-0d83f03cd37a",
      "name": "Code in JavaScript2",
      "type": "n8n-nodes-base.code",
      "position": [
        2336,
        2016
      ],
      "parameters": {
        "jsCode": "const data = $input.all();\n// בדיקה אם יש לפחות אייטם אחד עם קוד 200\nconst hasSuccess = data.some(item => \n  item.json.aliexpress_affiliate_link_generate_response?.resp_result?.resp_code === 200\n);\nif (hasSuccess) {\n  return data;\n} else {\n  return [{ json: { result: 2 } }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "d1e2148e-9ab9-4ffc-a3e5-bb467ef9945c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        -160,
        2784
      ],
      "webhookId": "40368714-5f47-4f1e-8fef-bbcf94f4d1b4",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "82046f73-87a9-4da1-8832-b0617aa4f573",
      "name": "Bot start filtering",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1184,
        2304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e6c0a529-58ad-4063-912f-1af3678a33b1",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.message.text }}",
              "rightValue": "/start"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "3f3c75e7-ad7a-4145-89e7-cf5916d81a8f",
      "name": "Only if the person who asked for more is the one who sent the original message",
      "type": "n8n-nodes-base.if",
      "position": [
        -672,
        2592
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "0362ba6f-f9a9-4959-832a-456c0b4ae8f1",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"reply_to_message\"][\"from\"][\"id\"] }}",
              "rightValue": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"from\"][\"id\"] }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "c7376207-9f53-45ef-9edd-2a2740a47d02",
      "name": "Checking if we are in a certain group ",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -384,
        2496
      ],
      "webhookId": "605e4eea-a60f-448e-bc54-6e8e7ea7d9dd",
      "parameters": {
        "chatId": "@your group",
        "userId": "={{ $('Telegram Trigger').item.json.callback_query.from.id }}",
        "resource": "chat",
        "operation": "member"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "75ccd5b9-417c-421b-88d5-7be5cd1b5ca5",
      "name": "A message that only those who sent an original message can request more",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -384,
        2784
      ],
      "webhookId": "95eaeb34-4028-47af-997a-c84940233323",
      "parameters": {
        "text": "=Only the person who sent the original message can click this button 🔒\n\nSubmit your own message to search for products!  😊",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.message_id }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "37a48993-9c0e-4095-84b6-3c36cf219a07",
      "name": "Deleting a message 5",
      "type": "n8n-nodes-base.telegram",
      "position": [
        64,
        2784
      ],
      "webhookId": "bdc2e079-fddb-467a-8a45-4ddd22ca78c1",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"chat\"][\"id\"] }}",
        "messageId": "={{ $item(\"0\").$node[\"A message that only those who sent an original message can request more\"].json[\"result\"][\"message_id\"] }}",
        "operation": "deleteMessage"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "01b27dcf-804c-4aab-bba2-c4c12fcbc6d3",
      "name": "Request to join the group 1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        64,
        2592
      ],
      "webhookId": "026a7d90-823a-4f5d-aac9-3f07480d9170",
      "parameters": {
        "text": "=Hello 😊\n\nTo use the bot, you must first join the \"cheap deals before everyone\" channel on Telegram 🏆\n\nAfter joining, just write: \"Find me...\" and what you are looking for 🔍",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "🔗 מעבר לערוץ הדילים",
                    "additionalFields": {
                      "url": "https://t.me/aliexpressdils"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c6d082da-c47b-4c0c-9ac4-83e7b14e1798",
      "name": "Opening message 2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        288,
        2304
      ],
      "webhookId": "44500458-6751-44b0-af8b-6cfb5f0b6c78",
      "parameters": {
        "text": "⏳ Just a moment...|You will find a team that searches in depth - checks reviews, compares prices, and does everything to find the most suitable product just for you!",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.message_id }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "24431c33-dfa4-456a-89c4-81b3a2e392ca",
      "name": "Request for correct wording 1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        288,
        2496
      ],
      "webhookId": "f610639f-9fc9-4160-8c8e-71ed93fcd4df",
      "parameters": {
        "text": "=💡 So that the bot can help properly, simply write the message in one of the following forms:\nFind me, look for me, look for me, find me, send me, send me\n\n🔍 For example:\nFind me {{ $('Telegram Trigger').item.json.message.text }}\n\n✅ Use one of these starters - and the bot already takes care of the rest!",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "834b00e0-dbb4-4d01-8c86-3e77a904acd7",
      "name": "Start typing 1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        512,
        2304
      ],
      "webhookId": "5572fe42-aede-4426-9225-f988ac656dd6",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"Opening message 2\"].json[\"result\"][\"chat\"][\"id\"] }}",
        "operation": "sendChatAction"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "431ed356-fc49-477f-a389-057f32a1fe67",
      "name": "Creating a professional search term 1",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        736,
        2304
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "GPT-5.2"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You validate and optimize search queries for AliExpress.\nYour task: get a search term and verify/optimize it for search on AliExpress.\n\nInput: {{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"text\"].split(' ').slice(2).join(' ') }}\n\nRules:\n1. Extract only the product name/description from the search term\n2. Remove all non-product information:\n   - Price mentions (for example, \"up to NIS 150\", \"under 100\", \"under 100\")\n   - Quantity references (eg, \"5 units\", \"pack of 3\")\n   - Color/size specifications (e.g., \"in size L\", \"in black color\")\n   - time constraints (for example, \"fast delivery\", \"by Sunday\")\n   - Any filter criteria other than the main product name\n3. Clear the remaining product name:\n   - Remove special characters: # @ $ % ^ & * ( ) = + [ ] { } |   : ;   \"'<>?\n   - Keep hyphens (-) and underscores (_) as they are valid in product searches\n   - Remove excessive spaces (several spaces in a row)\n4. Save the language of the original product name (Hebrew/English/etc.)\n5. Do not translate, do not add words, do not change the core meaning of the product\n6. Return only the cleaned product name, nothing else - no explanations, no quotes, no extra text\n\nExamples:\nInput: \"iPhone cover\"\nOutput: iPhone cover\n\nInput: \"Shoes up to NIS 150\"\nOutput: shoes\n\nInput: \"Wireless headphones under $50\"\nOutput: wireless headphones\n\nInput: \"iPhone charger fast delivery\"\nOutput: iPhone charger\n\nInput: \"Large number speakers 5 units\"\nOutput: Speakers\n\nInput: \"Game mouse!!!   cheap price\"\nOutput: Gaming mouse"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIALS_ID",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e9b00b13-53c6-4e5b-a9a4-dfe0e78137b5",
      "name": "Data scraping1",
      "type": "@decodo/n8n-nodes-decodo.decodo",
      "maxTries": 5,
      "position": [
        1088,
        2304
      ],
      "parameters": {
        "geo": "Israel",
        "url": "=https://aliexpress.com/w/wholesale-{{ $json.output[0].content[0].text.replaceAll(' ', '-') }}.html"
      },
      "credentials": {
        "decodoApi": {
          "id": "YOUR_SCRAPING_CREDENTIALS_ID",
          "name": "Decodo Credentials account 2"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1,
      "waitBetweenTries": 5000
    },
    {
      "id": "658b00e2-f47b-43cc-b41d-22502ef6562f",
      "name": "Follow-up message 1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1376,
        2304
      ],
      "webhookId": "210fddc8-94b2-43bc-8149-46b979151d63",
      "parameters": {
        "text": "🔥 Wow!  I have everything!  |  All the details are here with me, now I'm just arranging and comparing the most winning product for you!  A moment and I'll be back with a bomb...",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $('Telegram Trigger').item.json.callback_query.message.reply_to_message.message_id }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "074ad2a5-755a-41a0-bcd1-96fd62de9ad5",
      "name": "Extracting all items 1",
      "type": "n8n-nodes-base.code",
      "position": [
        1664,
        2304
      ],
      "parameters": {
        "jsCode": "const html = $('Data scraping1').first().json.results[0].content;\n\nconst scripts = html.match(/<script[^>]*>([\\s\\S]*?)<\\/script>/g) ||  [];\n\nתן מוצרים = null;\n\n// ניסיון 1: חיפוש ב-window._dida_config_._init_data_\nעבור (תן סקריפט של סקריפטים) {\n  const content = script.replace(/<script[^>]*>/, '').replace(/<\\/script>/, '');\n \n  if (content.includes('window._dida_config_._init_data_') && content.includes('productId')) {\n    const dataMatch = content.match(/window\\._dida_config_\\._init_data_\\s*=\\s*(\\{[\\s\\S]+?\\});/);\n    if (dataMatch) {\n      נסה {\n        const dataObj = JSON.parse(dataMatch[1]);\n        products = dataObj?.data?.data?.root?.fields?.mods?.itemList?.content;\n        if (products && Array.isArray(products) && products.length > 0) break;\n      } תפוס (ה) {}\n    }\n  }\n}\n\n// ניסיון 2: חיפוש ישיר של \"itemList\":{\"content\":[\nif (!products || !Array.isArray(products) || products.length === 0) {\n  עבור (תן סקריפט של סקריפטים) {\n    const content = script.replace(/<script[^>]*>/, '').replace(/<\\/script>/, '');\n   \n    if (content.includes('\"itemList\"') && content.includes('\"productId\"')) {\n      const searchPattern = '\"itemList\":{\"content\":[';\n      const contentStart = content.indexOf(searchPattern);\n     \n      if (contentStart !== -1) {\n        const arrayStart = content.indexOf('[', contentStart);\n        תן עומק = 0;\n        let inString = false;\n        תן לברוח = שקר;\n        let arrayEnd = arrayStart;\n       \n        for (let i = arrayStart; i < content.length; i++) {\n          const char = content[i];\n         \n          if (escape) {\nreturn extractedData.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "6938c765-3340-4956-8e87-53a51b8449b6",
      "name": "Creating an affiliate link",
      "type": "n8n-nodes-aliexpress-affiliate.aliExpressAffiliate",
      "position": [
        2112,
        2016
      ],
      "parameters": {
        "tracking_id": "YOUR_AFFILIATE_TRACKING_ID",
        "source_values": "={{ $json.productUrl }}",
        "promotion_link_type": 2
      },
      "credentials": {
        "aliExpressAffiliateApi": {
          "id": "YOUR_ALIEXPRESS_CREDENTIALS_ID",
          "name": "AliExpress Affiliate account 3"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1
    },
    {
      "id": "addbff58-332b-4c08-ade4-df0dabc350b7",
      "name": "If there is an error or not 1",
      "type": "n8n-nodes-base.if",
      "position": [
        2560,
        2304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c133323a-3b54-4afe-afe3-ed9dcf96c5ab",
              "operator": {
                "type": "number",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.result }}",
              "rightValue": 2
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d705d739-bdb7-46d6-b568-a292cdeebffb",
      "name": "Wording for message",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2784,
        2304
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "GPT-5.2"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a professional and convincing sales agent in Hebrew.  It's your job to create a cool Telegram message that will make the customer want to buy right away!\n\nYou received the following details:\n- What the client searched for: {{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"reply_to_message\"][\"text\"].replace(/^(find me|search me|search me|find me|send me|send me)\\s*/g, '').trim() }}\n- Product name: {{ $('Extraction of 2 products from the first 7').item.json.title }}\n- Original price: {{ $('Extraction of 2 products from the first 7').item.json.originalPrice }}\n- Sale price: {{ $('Extraction of 2 products from the first 7').item.json.salePrice }}\n- Discount percentage: {{ $('Extraction of 2 products from the first 7').item.json.discount }}\n- Rating: {{ $('Extraction of 2 products from the first 7').item.json.rating }}\n- Quantity sold: {{ $('Extraction of 2 products from the first 7').item.json.soldCount }}\nMaximum 7-8 lines, short and precise!"
            }
          ]
        },
        "simplify": false
      },
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIALS_ID",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "12e0b047-b8df-4186-a962-29125ac5e8af",
      "name": "Sending a message 1",
      "type": "n8n-nodes-base.telegram",
      "onError": "continueRegularOutput",
      "position": [
        3136,
        2304
      ],
      "webhookId": "ede60b7f-86ab-4ab5-a5a0-4b231df5b71f",
      "parameters": {
        "file": "={{ $('Extraction of 2 products from the first 7').item.json.mainImage }}",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"chat\"][\"id\"] }}",
        "operation": "sendPhoto",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "🔍 You will find more",
                    "additionalFields": {
                      "callback_data": "more_results"
                    }
                  },
                  {
                    "text": "🛒 for purchase",
                    "additionalFields": {
                      "url": "={{ $('Creating an affiliate link').item.json.aliexpress_affiliate_link_generate_response.resp_result.result.promotion_links.promotion_link[0].promotion_link }}"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "caption": "={{ $('Wording for message').item.json.choices[0].message.content }}",
          "parse_mode": "HTML",
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"reply_to_message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2,
      "alwaysOutputData": true
    },
    {
      "id": "9267fb15-8614-49b2-8a91-4c6e63dd0072",
      "name": "Deleting a message 3",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3424,
        2304
      ],
      "webhookId": "890837aa-c654-4815-a7a2-674c2ef1815e",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"chat\"][\"id\"] }}",
        "messageId": "={{ $item(\"0\").$node[\"Opening message 2\"].json[\"result\"][\"message_id\"] }}",
        "operation": "deleteMessage"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "723e38f4-2f62-4a8b-bf4d-b11db13e3ded",
      "name": "Deleting a message4",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3712,
        2304
      ],
      "webhookId": "7d486b39-6ca5-4e08-8fd0-71f399fc9ff3",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"callback_query\"][\"message\"][\"chat\"][\"id\"] }}",
        "messageId": "={{ $item(\"0\").$node[\"Follow-up message 1\"].json[\"result\"][\"message_id\"] }}",
        "operation": "deleteMessage"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "b9fa5bab-d9f3-4a2d-8409-8de510da428a",
      "name": "If there is problematic content",
      "type": "n8n-nodes-base.if",
      "position": [
        -160,
        1920
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "da0e80cb-9f79-4ece-af8c-3f188ac7e8f7",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "rejected"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c16fc16a-21a5-4b60-98bc-24137be6edf6",
      "name": "Checking if we are in a certain group",
      "type": "n8n-nodes-base.telegram",
      "position": [
        64,
        1824
      ],
      "webhookId": "c9b67bcb-4597-46fa-83ff-cab24eb04971",
      "parameters": {
        "chatId": "@your group",
        "userId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "resource": "chat",
        "operation": "member"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a5bd1973-89ba-4efa-8c44-e9b6c1120a35",
      "name": "Request to join the group",
      "type": "n8n-nodes-base.telegram",
      "position": [
        512,
        1920
      ],
      "webhookId": "bc2614d0-f562-4f1f-8b99-b3e691e0592b",
      "parameters": {
        "text": "=Hello 😊\n\nTo use the bot, you must first join the \"cheap deals before everyone\" channel on Telegram 🏆\n\nAfter joining, just write: \"Find me...\" and what you are looking for 🔍",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "🔗 מעבר לערוץ הדילים",
                    "additionalFields": {
                      "url": "https://t.me/aliexpressdils"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5f066203-bc0d-47ff-9a39-1ed9018d8803",
      "name": "opening message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        800,
        1632
      ],
      "webhookId": "bd79c412-fab6-431b-be04-ece47178d1aa",
      "parameters": {
        "text": "⏳ Just a moment...|You will find a team that searches in depth - checks reviews, compares prices, and does everything to find the most suitable product just for you!",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7031bd59-85d7-41e0-b9b9-08c2cf425f84",
      "name": "Start typing",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1088,
        1632
      ],
      "webhookId": "d4afa6db-eae5-4905-a4ea-595a78a658ed",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"opening message\"].json[\"result\"][\"chat\"][\"id\"] }}",
        "operation": "sendChatAction"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "106782f8-fc58-4b5c-8db0-9587b2f1d95b",
      "name": "Request for correct wording",
      "type": "n8n-nodes-base.telegram",
      "position": [
        800,
        1920
      ],
      "webhookId": "b7142055-1128-4ebf-a551-35bce9691fa5",
      "parameters": {
        "text": "=💡 So that the bot can help properly, simply write the message in one of the following forms:\nFind me, look for me, look for me, find me, send me, send me\n\n🔍 For example:\nFind me {{ $('Telegram Trigger').item.json.message.text }}\n\n✅ Use one of these starters - and the bot already takes care of the rest!",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b6ba7019-d442-4e49-a736-236b4d1526b2",
      "name": "Creating a professional search term",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1312,
        1632
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "GPT-5.2"
        },
        "options": {},
        "responses": {
          "values": [
            {
              "content": "=אתה מאמת ומייעל שאילתות חיפוש עבור AliExpress.\nהמשימה שלך: לקבל מונח חיפוש ולאמת/ לבצע אופטימיזציה שלו לחיפוש באליאקספרס.\n\nקלט: {{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"text\"].split(' ').slice(2).join(' ') }}\n\nכללים:\n1. חלץ רק את שם המוצר/תיאור ממונח החיפוש\n2. הסר את כל המידע שאינו מוצר:\n   - אזכורי מחירים (למשל, \"עד 150 שח\", \"מתחת ל-100\", \"מתחת ל-100\")\n   - אזכורים בכמות (למשל, \"5 יחידות\", \"חבילה של 3\")\n   - מפרטי צבע/גודל (למשל, \"במידה L\", \"בצבע שחור\")\n   - אילוצי זמן (לדוגמה, \"משלוח מהיר\", \"עד יום ראשון\")\n   - כל קריטריון סינון שאינו שם המוצר המרכזי\n3. נקה את שם המוצר הנותר:\n   - הסר תווים מיוחדים: # @ $ % ^ & * ( ) = + [ ] { } |  \\ : ;  \"'<>?\nפלט: עכבר גיימינג"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIALS_ID",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f5251536-43e5-4089-b676-fcc5207dc82c",
      "name": "data scraping",
      "type": "@decodo/n8n-nodes-decodo.decodo",
      "maxTries": 5,
      "position": [
        1664,
        1632
      ],
      "parameters": {
        "geo": "Israel",
        "url": "=https://aliexpress.com/w/wholesale-{{ $json.output[0].content[0].text.replaceAll(' ', '-') }}.html"
      },
      "credentials": {
        "decodoApi": {
          "id": "YOUR_SCRAPING_CREDENTIALS_ID",
          "name": "Decodo Credentials account 2"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1,
      "waitBetweenTries": 5000
    },
    {
      "id": "089d8ed5-b24b-4e83-805d-c2ec92c25435",
      "name": "Follow up message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1888,
        1632
      ],
      "webhookId": "9cd3b55f-4f75-498f-ad20-51cf28e13a3d",
      "parameters": {
        "text": "🔥 Wow!  I have everything!  |  All the details are here with me, now I'm just arranging and comparing the most winning product for you!  A moment and I'll be back with a bomb...",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false,
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "820651a3-f443-4493-8663-456b1ce0a8f9",
      "name": "Extract all items",
      "type": "n8n-nodes-base.code",
      "position": [
        2112,
        1632
      ],
      "parameters": {
        "jsCode": "const html = $('data scraping').first().json.results[0].content;\n// Attempt 1: Search window._dida_config_._init_data_\nfor (let script of scripts) {\n  const content = script.replace(/<script[^>]*>/, '').replace(/<\\/script>/, '');\n\n  if (content.includes('window._dida_config_._init_data_') && content.includes('productId')) {\n    const dataMatch = content.match(/window\\._dida_config_\\._init_data_\\s*=\\s*(\\{[\\s\\S]+?\\});/);\n    if (dataMatch) {\n      try {\n        const dataObj = JSON.parse(dataMatch[1]);\n        products = dataObj?.data?.data?.root?.fields?.mods?.itemList?.content;\n        if (products && Array.isArray(products) && products.length > 0) break;\n      } catch (e) {}\n    }\n  }\n}\n\n// Attempt 2: Direct search of \"itemList\":{\"content\":[\nif (!products || !Array.isArray(products) || products.length === 0) {\n  for (let script of scripts) {\n    const content = script.replace(/<script[^>]*>/, '').replace(/<\\/script>/, '');\n  \n    if (content.includes('\"itemList\"') && content.includes('\"productId\"')) {\n      const searchPattern = '\"itemList\":{\"content\":[';\n      const contentStart = content.indexOf(searchPattern);\n    \n      if (contentStart !== -1) {\n        const arrayStart = content.indexOf('[', contentStart);\n        let depth = 0;\n        let inString = false;\n        let escape = false;\n        let arrayEnd = arrayStart;\n      \n        for (let i = arrayStart; i < content.length; i++) {\n          const char = content[i];\n        \n          if (escape) {\n            escape = false;\n            continue;\n          }\n        \n          if (char === '\\\\') {\n            escape = true;\n            continue;\n          }\n        \n          if (char === '\"') {\n            inString = !inString;\n            to continue;\n          }\n        \n          if (!inString) {\n            if (char === '[' || char === '{') depth++;\n            if (char === ']' || char === '}') depth--;\n          \n            if (depth === 0 && char === ']') {\n              arrayEnd = i + 1;\n              break;\n            }\n          }\n        }\n      \n        if (arrayEnd > arrayStart) {\n          const jsonArray = content.substring(arrayStart, arrayEnd);\n          try {\n            products = JSON.parse(jsonArray);\n            if (products && Array.isArray(products) && products.length > 0) break;\nreturn extractedData.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "ae1b3a0f-d25c-4bb4-8885-b27fc4886629",
      "name": "Extraction of 2 products from the first 10",
      "type": "n8n-nodes-base.code",
      "position": [
        2336,
        1552
      ],
      "parameters": {
        "jsCode": "// Getting all the products\nconst items = $input.all();\nlet products;\nif (items.length === 1 && Array.isArray(items[0].json)) {\n  products = items[0].json;\n} else {\n  products = items.map(item => item.json);\n}\n\n// taking the first 2\nconst top2 = products.slice(0, 2);\n\n// Returning the products with valid links\nreturn top2.map(product => {\n  const cleanUrl = `https://www.aliexpress.com/item/${product.productId}.html`;\n \n  return {\n    json: {\n      ...product,\n      productUrl: cleanUrl\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "96daa4fa-4c06-427c-bd6a-5fb3bf9c43c5",
      "name": "Extraction of 2 products from the first 7",
      "type": "n8n-nodes-base.code",
      "position": [
        1888,
        2016
      ],
      "parameters": {
        "jsCode": "// Getting all the products\nconst items = $input.all();\nlet products;\nif (items.length === 1 && Array.isArray(items[0].json)) {\n  products = items[0].json;\n} else {\n  products = items.map(item => item.json);\n}\n// skipping the first 2, taking the next 5 (from the third to the seventh)\nconst top5 = products.slice(2, 7);\n// Pick 2 random out of 5\nfunction getRandomProducts(arr, count) {\n  const copy = [...arr];\n  const result = [];\n \n  for (let i = 0; i < count && copy.length > 0; i++) {\n    const randomIndex = Math.floor(Math.random() * copy.length);\n    result.push(copy[randomIndex]);\n    copy.splice(randomIndex, 1);\n  }\n \n  return result;\n}\nconst randomProducts = getRandomProducts(top5, 2);\n// Returning the products with valid links\nreturn randomProducts.map(product => {\n  const cleanUrl = `https://www.aliexpress.com/item/${product.productId}.html`;\n \n  return {\n    json: {\n      ...product,\n      productUrl: cleanUrl\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "c7d97f05-445e-41ae-bc1d-4a7937cf0780",
      "name": "Opening message 1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        64,
        2112
      ],
      "webhookId": "951256c5-dd0a-42b5-b072-2d8c92acc476",
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "בוט אלי אקספרס - נהוראי מרדכי"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a38f5fb9-50f8-404e-b12b-37c9652f46be",
      "name": "Deleting a message 2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        288,
        2112
      ],
      "webhookId": "a02a2aa3-5ed6-40fe-bcf3-8e2032de7d62",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "messageId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}",
        "operation": "deleteMessage"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "בוט אלי אקספרס - נהוראי מרדכי"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "169222c2-5cb7-4967-9a0a-b73d19862518",
      "name": "Automatic removal of the user from the group",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        512,
        2112
      ],
      "parameters": {
        "url": "=https://api.telegram.org/YOUR_TELEGRAM_BOT_TOKE/banChatMember",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "chat_id",
              "value": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}"
            },
            {
              "name": "user_id",
              "value": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"from\"][\"id\"] }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "350e8e76-441e-4d66-acd5-9ddd0da50817",
      "name": "Creating an affiliate link3",
      "type": "n8n-nodes-aliexpress-affiliate.aliExpressAffiliate",
      "position": [
        2560,
        1552
      ],
      "parameters": {
        "tracking_id": "YOUR_AFFILIATE_TRACKING_ID",
        "source_values": "={{ $json.productUrl }}",
        "promotion_link_type": 2
      },
      "credentials": {
        "aliExpressAffiliateApi": {
          "id": "YOUR_ALIEXPRESS_CREDENTIALS_ID",
          "name": "AliExpress Affiliate account 3"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1
    },
    {
      "id": "d9b68d3c-78d6-43f7-b314-0788ab3a37ce",
      "name": "whether there is an error or not",
      "type": "n8n-nodes-base.if",
      "position": [
        3136,
        1632
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c133323a-3b54-4afe-afe3-ed9dcf96c5ab",
              "operator": {
                "type": "number",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.result }}",
              "rightValue": 2
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b48378b9-6993-4bbd-b4da-5173e8c9f823",
      "name": "Wording for message 3",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        3360,
        1632
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "GPT-5.2"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a professional and convincing sales agent in Hebrew.  It's your job to create a cool Telegram message that will make the customer want to buy right away!\n\nYou received the following details:\n- What the customer searched for: {{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"text\"].replace(/^(find me|search me|search me|find me|send me|send me)\\s*/g, '').trim() }}\n- Product name: {{ $('Extraction of 2 products from the first 10').item.json.title }}\n- Original price: {{ $('Extraction of 2 products from the first 10').item.json.originalPrice }}\n- Sale price: {{ $('Extraction of 2 products from the first 10').item.json.salePrice }}\n- Discount percentage: {{ $('Extraction of 2 products from the first 10').item.json.discount }}\n- Rating: {{ $('Extraction of 2 products from the first 10').item.json.rating }}\n- Quantity sold: {{ $('Extraction of 2 products from the first 10').item.json.soldCount }}\n- Special tags: {{ $('Extraction of 2 products from the first 10').item.json.tags }}\nMaximum 7-8 lines, short and precise!"
            }
          ]
        },
        "simplify": false
      },
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIALS_ID",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "4af3fdcc-99bc-41ed-98ff-90aeae52633a",
      "name": "sending a message",
      "type": "n8n-nodes-base.telegram",
      "onError": "continueRegularOutput",
      "position": [
        3712,
        1632
      ],
      "webhookId": "a73c07c1-6275-486a-b887-b99751a1c614",
      "parameters": {
        "file": "={{ $('Extraction of 2 products from the first 10').item.json.mainImage }}",
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "operation": "sendPhoto",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "🔍 You will find more",
                    "additionalFields": {
                      "callback_data": "more_results"
                    }
                  },
                  {
                    "text": "🛒 for purchase",
                    "additionalFields": {
                      "url": "={{ $('Creating an affiliate link3').item.json.aliexpress_affiliate_link_generate_response.resp_result.result.promotion_links.promotion_link[0].promotion_link }}"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "caption": "={{ $('Wording for message 3').item.json.choices[0].message.content }}",
          "parse_mode": "HTML",
          "reply_to_message_id": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"message_id\"] }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2,
      "alwaysOutputData": true
    },
    {
      "id": "a35465aa-56a1-450d-98c1-2b5f320180c7",
      "name": "Deleting a message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3936,
        1632
      ],
      "webhookId": "b556080d-c352-479d-be99-fab49c3cde80",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "messageId": "={{ $item(\"0\").$node[\"opening message\"].json[\"result\"][\"message_id\"] }}",
        "operation": "deleteMessage"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "ecfadf5e-db27-469a-9845-51750d01ad2a",
      "name": "Deleting a message 1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        4160,
        1632
      ],
      "webhookId": "f2257ee8-5c85-4e06-bbf0-c7c3870cadcd",
      "parameters": {
        "chatId": "={{ $item(\"0\").$node[\"Telegram Trigger\"].json[\"message\"][\"chat\"][\"id\"] }}",
        "messageId": "={{ $item(\"0\").$node[\"Follow up message\"].json[\"result\"][\"message_id\"] }}",
        "operation": "deleteMessage"
      },
      "credentials": {
        "telegramApi": {
          "id": "YOUR_TELEGRAM_CREDENTIALS_ID",
          "name": "Telegram account"
        }
      },
      "executeOnce": true,
      "typeVersion": 1.2
    },
    {
      "id": "5088b848-be9b-40d3-b219-728b8fec9a6e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        1440
      ],
      "parameters": {
        "width": 528,
        "height": 608,
        "content": "# AliExpress Affiliate Bot for Telegram\n\nAutomatically find and share AliExpress products with affiliate links in your Telegram group.\n\n## How it works\n1. Bot receives messages and callback queries from Telegram group\n2. AI moderator checks content for spam, links, and inappropriate requests\n3. Valid product requests trigger an AliExpress search\n4. System generates affiliate tracking links for top matching products\n5. Formatted product cards are sent back to the Telegram group\n6. Users can request additional options via inline buttons\n\n## Setup steps\n1. Create a Telegram Bot via @BotFather and obtain API token\n2. Register for AliExpress Affiliate Program and get App Key & Secret\n3. Create OpenAI API account and generate API key\n4. Add all three credentials in n8n (Telegram, AliExpress, OpenAI)\n5. Replace placeholder credential IDs with your own\n6. Add the bot to your Telegram group with admin permissions\n7. Activate the workflow and test with a sample product request"
      },
      "typeVersion": 1
    },
    {
      "id": "613c5d55-a79e-40c3-9a74-2eb25845ffda",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1472,
        2176
      ],
      "parameters": {
        "color": 7,
        "height": 112,
        "content": "📥 Input Handler\nReceives incoming messages and callback queries from Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "538075c1-6781-4171-bc8e-0b94848ecaae",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        1792
      ],
      "parameters": {
        "color": 7,
        "height": 112,
        "content": "🛡️ Content Moderation\nAI validates message content. Blocks spam, links, and inappropriate requests."
      },
      "typeVersion": 1
    },
    {
      "id": "74e555fb-230c-4d5e-bd39-17f42b19c803",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1296,
        1504
      ],
      "parameters": {
        "color": 7,
        "height": 112,
        "content": "🔍 Product Search\nTranslates request to search query and scrapes AliExpress for products."
      },
      "typeVersion": 1
    },
    {
      "id": "03bf3077-af92-44e2-9b71-1670b4104f60",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2496,
        1424
      ],
      "parameters": {
        "color": 7,
        "height": 112,
        "content": "🔗 Affiliate Link Generation\nCreates tracking links via AliExpress API. Handles errors gracefully."
      },
      "typeVersion": 1
    },
    {
      "id": "6513c4da-8e00-48fc-90d1-424c82b2ab1a",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3360,
        1504
      ],
      "parameters": {
        "color": 7,
        "height": 112,
        "content": "📤 Response Handler\nSends product cards to Telegram and cleans up temporary messages."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "Telegram Trigger": [
      {
        "json": {
          "message": {
            "chat": {
              "id": -1002530739399,
              "type": "supergroup",
              "title": "מצא-לי הבוט שמוצא לך הכל באליאקספרס!",
              "username": "findmebot12"
            },
            "date": 1766996725,
            "from": {
              "id": 8010603533,
              "is_bot": false,
              "first_name": "אליהו",
              "language_code": "he"
            },
            "text": "תמצא לי קיטור עד 150 שקל בערך",
            "message_id": 7519
          },
          "update_id": 983144894
        },
        "pairedItem": {
          "item": 0
        }
      }
    ]
  },
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "aaae7be9-43fd-447e-980f-0c85df3dd65b",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Only if the person who asked for more is the one who sent the original message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "If4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Request to join the group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "If5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Request to join the group 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If4": {
      "main": [
        [
          {
            "node": "opening message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Request for correct wording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If5": {
      "main": [
        [
          {
            "node": "Opening message 2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Request for correct wording 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Deleting a message 5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start typing": {
      "main": [
        [
          {
            "node": "Creating a professional search term",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "data scraping": {
      "main": [
        [
          {
            "node": "Follow up message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data scraping1": {
      "main": [
        [
          {
            "node": "Follow-up message 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start typing 1": {
      "main": [
        [
          {
            "node": "Creating a professional search term 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "opening message": {
      "main": [
        [
          {
            "node": "Start typing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Bot start filtering",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract all items": {
      "main": [
        [
          {
            "node": "Extraction of 2 products from the first 10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Follow up message": {
      "main": [
        [
          {
            "node": "Extract all items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Opening message 1": {
      "main": [
        [
          {
            "node": "Deleting a message 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Opening message 2": {
      "main": [
        [
          {
            "node": "Start typing 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "sending a message": {
      "main": [
        [
          {
            "node": "Deleting a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "whether there is an error or not",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deleting a message": {
      "main": [
        [
          {
            "node": "Deleting a message 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bot start filtering": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "If there is problematic content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript2": {
      "main": [
        [
          {
            "node": "If there is an error or not 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Follow-up message 1": {
      "main": [
        [
          {
            "node": "Extracting all items 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sending a message 1": {
      "main": [
        [
          {
            "node": "Deleting a message 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wording for message": {
      "main": [
        [
          {
            "node": "Sending a message 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deleting a message 2": {
      "main": [
        [
          {
            "node": "Automatic removal of the user from the group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deleting a message 3": {
      "main": [
        [
          {
            "node": "Deleting a message4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wording for message 3": {
      "main": [
        [
          {
            "node": "sending a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extracting all items 1": {
      "main": [
        [
          {
            "node": "Extraction of 2 products from the first 7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Creating an affiliate link": {
      "main": [
        [
          {
            "node": "Code in JavaScript2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Creating an affiliate link3": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If there is an error or not 1": {
      "main": [
        [
          {
            "node": "Wording for message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extracting all items 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If there is problematic content": {
      "main": [
        [
          {
            "node": "Checking if we are in a certain group",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Opening message 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "whether there is an error or not": {
      "main": [
        [
          {
            "node": "Wording for message 3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract all items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Creating a professional search term": {
      "main": [
        [
          {
            "node": "data scraping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Checking if we are in a certain group": {
      "main": [
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Creating a professional search term 1": {
      "main": [
        [
          {
            "node": "Data scraping1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Checking if we are in a certain group ": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extraction of 2 products from the first 7": {
      "main": [
        [
          {
            "node": "Creating an affiliate link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extraction of 2 products from the first 10": {
      "main": [
        [
          {
            "node": "Creating an affiliate link3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "A message that only those who sent an original message can request more": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only if the person who asked for more is the one who sent the original message": {
      "main": [
        [
          {
            "node": "Checking if we are in a certain group ",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "A message that only those who sent an original message can request more",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}