{
  "name": "WAHA LID AND HOLD",
  "nodes": [
    {
      "parameters": {},
      "type": "@devlikeapro/n8n-nodes-waha.wahaTrigger",
      "typeVersion": 202502,
      "position": [
        -2240,
        16
      ],
      "id": "92fbcbf6-7e19-4683-9b8f-115b3d7daf9b",
      "name": "WAHA Trigger"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.payload.from.split('@')[1] }}",
                    "rightValue": "c.us",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "320c757a-0999-411e-8950-5342b4a2bf00"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "C.US"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "6ab35530-cc96-4fa6-b36c-a89469ecd122",
                    "leftValue": "={{ $json.payload.from.split('@')[1] }}",
                    "rightValue": "lid",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "LID"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        -1536,
        128
      ],
      "id": "eeae69fc-a207-4f3b-9f11-95dfb33e4959",
      "name": "Switch From"
    },
    {
      "parameters": {
        "url": "=https://<waha-url>/api/{{ $json.session }}/lids/{{ $json.payload.from }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "wahaApi",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -1152,
        384
      ],
      "id": "2d0625f3-9dbc-42f8-987a-18adb978c8b4",
      "name": "Convert LID",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1792,
        128
      ],
      "id": "23fba00c-b4cd-41f3-bb81-d12331170a00",
      "name": "Data Forwarder"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6d389cd3-58f1-413b-949e-466f181c7b0d",
              "name": "fromPhone",
              "value": "={{ $json.payload.from }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -976,
        112
      ],
      "id": "4ce50ba0-f30b-4aba-9905-9cc149d4310d",
      "name": "Payload Mapper C.US"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6d389cd3-58f1-413b-949e-466f181c7b0d",
              "name": "fromPhone",
              "value": "={{ $json.pn }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -944,
        384
      ],
      "id": "900e69d1-b794-4f51-9094-bacb6000f40f",
      "name": "Payload Mapper LID"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        -624,
        128
      ],
      "id": "c82706c3-0f2e-419a-aaec-e2f376b8be4d",
      "name": "Merge From"
    },
    {
      "parameters": {
        "operation": "rowExists",
        "dataTableId": {
          "__rl": true,
          "value": "62XZZWrfKDTQ8KXo",
          "mode": "list",
          "cachedResultName": "chatbot_ignore_phone",
          "cachedResultUrl": "/projects/XjRDWEVSMVwyviNg/datatables/62XZZWrfKDTQ8KXo"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "phone",
              "keyValue": "={{ $json.fromPhone }}"
            },
            {
              "keyName": "is_ignored",
              "keyValue": "true"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        960,
        128
      ],
      "id": "31fbcf12-c0ac-47ad-8b59-fdc2d152cccc",
      "name": "Ignored Phone Data",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "d304160e-aff0-4f27-beaa-f73c13ca72cc",
              "leftValue": "={{ $json.fromPhone }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        1200,
        128
      ],
      "id": "79f58faf-bafa-4b70-92f0-017cecf0e1d0",
      "name": "If Phone Ignored"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Merge Inbound Chat').item.json.inboundChat }}",
        "options": {
          "systemMessage": "=\n\nKamu adalah AI Customer Care resmi untuk toko pakaian bernama JIMS SIGNATURE.\nKamu melayani customer via WhatsApp dengan tujuan utama:\nMENCATAT PESANAN \u2192 MEMINTA TRANSFER \u2192 MEMVALIDASI BUKTI TRANSFER \u2192 UPDATE STATUS PESANAN.\n\n=== ATURAN AWAL PERCAKAPAN (SANGAT PENTING) ===\n\n- Jika customer hanya menyapa (contoh: \"halo\", \"h\", \"p\", \"assalamualaikum\" dan lain sebagainya):\n  JANGAN langsung menawarkan produk.\n  JANGAN langsung menampilkan katalog.\n  JANGAN memanggil GetProducts.\n\n- Pada kondisi tersebut, kamu WAJIB:\n  1. Membalas sapaan dengan sopan\n  2. Menanyakan maksud customer terlebih dahulu\n\n- GetProducts HANYA BOLEH digunakan jika:\n  - Customer menyatakan ingin melihat produk\n  - Customer bertanya harga / katalog / produk\n  - Customer menyebutkan niat membeli\n\nMelanggar aturan ini dianggap kesalahan fatal.\n\n\n================================================\nINFORMASI TOKO\n================================================\nNama Toko   : JIMS SIGNATURE\nAlamat      : Jalan Raya Serang Nomor 123, Tangerang, Banten\nJam Operasi : Setiap hari, 10:00 \u2013 21:00 WIB\n\n================================================\nINFORMASI PEMBAYARAN (WAJIB PERSIS)\n================================================\nMetode Pembayaran:\nTransfer Bank BCA\n\nNo Rekening:\n8833883388\n\nAtas Nama:\nAJI PRAKOSO\n\nJumlah transfer HARUS SAMA PERSIS dengan total pesanan.\nTidak boleh dibulatkan, dikurangi, atau dilebihkan.\n\n================================================\nSUMBER DATA & TOOLS (WAJIB DIPATUHI)\n================================================\n- Produk \u2192 GetProducts\n- Buat Order \u2192 CreateOrder\n- Ambil Order Customer \u2192 GetOrders\n- Update Order ke PAID \u2192 UpdateOrderPaid\n- Kirim Gambar Produk \u2192 SendImage\n- Abaikan Customer \u2192 IgnoreCustomer\n\nDILARANG mengarang data di luar hasil tools.\n\n================================================\nALUR ORDER\n================================================\n1. Jika customer bertanya produk / harga:\n   \u2192 Gunakan GetProducts\n   \u2192 Tampilkan list produk secara rapi\n\n2. Jika customer memilih produk:\n   \u2192 Pastikan kamu mendapatkan:\n     - SKU / nama produk\n     - Jumlah (qty)\n     - Nama lengkap customer\n\n3. Jika data belum lengkap:\n   \u2192 TANYAKAN, JANGAN BUAT ORDER\n\n4. Jika customer sudah final & tidak menambah barang:\n   \u2192 Hitung total\n   \u2192 Gunakan CreateOrder\n   \u2192 Simpan status = \"NEW\"\n\n5. Setelah order dibuat:\n   \u2192 Kirim instruksi transfer BCA\n   \u2192 Minta customer mengirim BUKTI TRANSFER\n\n================================================\nFORMAT INSTRUKSI TRANSFER (WAJIB)\n================================================\nSilakan lakukan pembayaran dengan detail berikut:\n\nBank        : BCA\nNo Rekening : 8833883388\nAtas Nama   : AJI PRAKOSO\nNominal     : <TOTAL PESANAN>\n\nSetelah transfer, mohon kirimkan bukti transfer di chat ini.\n\n================================================\nALUR VALIDASI BUKTI TRANSFER (KRITIKAL)\n================================================\nKetika customer mengirim bukti transfer:\n- Bukti akan dianalisis dan dikirim ke kamu dalam bentuk TEKS (hasil OCR / image analysis)\n\nLangkah yang HARUS kamu lakukan:\n\n1. Ambil SEMUA pesanan customer menggunakan GetOrders\n2. Filter pesanan dengan kondisi:\n   - status = \"NEW\"\n   - total == nominal transfer di bukti pembayaran\n\n3. Jika:\n   - TIDAK ADA pesanan yang cocok:\n     \u2192 Jangan update apa pun\n     \u2192 Minta customer klarifikasi nominal / order\n\n4. Jika:\n   - ADA TEPAT SATU pesanan yang cocok:\n     \u2192 Gunakan UpdateOrderPaid\n     \u2192 Update status menjadi \"PAID\"\n\n5. Jika:\n   - ADA LEBIH DARI SATU pesanan dengan nominal sama:\n     \u2192 Jangan update\n     \u2192 Minta customer konfirmasi order mana yang dibayar\n\n================================================\nPESAN KONFIRMASI SETELAH PAID\n================================================\nJika berhasil update ke PAID, kirim pesan konfirmasi:\n\n\"Terima kasih, pembayaran Anda sudah kami terima dan pesanan telah kami konfirmasi.\nPesanan akan segera kami proses. \ud83d\ude4f\"\n\n================================================\nLARANGAN KERAS (INI PENTING)\n================================================\n- DILARANG update status PAID tanpa mencocokkan nominal\n- DILARANG update jika status bukan \"NEW\"\n- DILARANG mengasumsikan bukti transfer valid tanpa data\n- DILARANG update lebih dari satu order sekaligus\n- DILARANG menyebut kata AI, sistem, database, atau tool\n\n================================================\nIGNORE CUSTOMER\n================================================\nGunakan IgnoreCustomer jika:\n- Customer spam / toxic\n- Mengirim pesan tidak relevan berulang\n- Permintaan di luar konteks toko\n\nSetelah IgnoreCustomer, HENTIKAN interaksi.\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        1792,
        144
      ],
      "id": "2fb5f929-564a-4c0f-882b-f1fc20b27b52",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5.2",
          "mode": "list",
          "cachedResultName": "gpt-5.2"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        1600,
        464
      ],
      "id": "156d5e10-6476-4ff5-96e1-a834f810d000",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Gunakan tools ini untuk memasukkan pelanggan ke daftar ignore, tool ini digunakan saat kamu sudah tidak sanggup lagi menjawab pertanyaan yang diluar konteks dan pengetahuanmu",
        "dataTableId": {
          "__rl": true,
          "value": "62XZZWrfKDTQ8KXo",
          "mode": "list",
          "cachedResultName": "chatbot_ignore_phone",
          "cachedResultUrl": "/projects/XjRDWEVSMVwyviNg/datatables/62XZZWrfKDTQ8KXo"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "is_ignored": true,
            "phone": "={{ $('Merge From').item.json.fromPhone }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "phone",
              "displayName": "phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "is_ignored",
              "displayName": "is_ignored",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "boolean",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTableTool",
      "typeVersion": 1,
      "position": [
        2192,
        512
      ],
      "id": "231f02dd-a32d-405e-aae7-6d596f71de5d",
      "name": "IgnoreCustomer"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Merge From').item.json.fromPhone }}A"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        1792,
        464
      ],
      "id": "f5e7e030-0eca-43f7-b515-e864b7093d43",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Start Typing",
        "session": "={{ $('Data Forwarder').item.json.session }}",
        "chatId": "={{ $('Data Forwarder').item.json.payload.id }}",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        2112,
        144
      ],
      "id": "efa5a351-98db-4c62-900d-6d2fd61f3801",
      "name": "Start Typing",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 3
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2448,
        144
      ],
      "id": "f122c71b-00e9-48dd-bcc6-de22d2b1cdb7",
      "name": "Wait"
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Send Seen",
        "session": "={{ $('Data Forwarder').item.json.session }}",
        "chatId": "={{ $('Data Forwarder').item.json.payload.from }}",
        "messageId": "={{ $('Data Forwarder').item.json.payload.id }}",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        1504,
        144
      ],
      "id": "38c1475f-1413-413d-841e-1533a15c5777",
      "name": "Send Seen",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Stop Typing",
        "session": "={{ $('Data Forwarder').item.json.session }}",
        "chatId": "={{ $('Data Forwarder').item.json.payload.id }}",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        2704,
        144
      ],
      "id": "0b6c12a9-5a89-4e3e-a999-d4ced3e3ddce",
      "name": "Stop Typing",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Send Text",
        "session": "={{ $('Data Forwarder').item.json.session }}",
        "chatId": "={{ $('Merge From').item.json.fromPhone }}",
        "text": "={{ $('AI Agent').item.json.output }}",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        3072,
        144
      ],
      "id": "7afba6a0-61d0-4b1b-b770-bbcd57efe8c7",
      "name": "Send a text message",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## Data Forwarder\nSolusi untuk WAHA Trigger no field. Penjelasannya bisa lihat di https://youtu.be/ydF8VX8PoyU",
        "height": 320,
        "width": 336,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1936,
        0
      ],
      "typeVersion": 1,
      "id": "186097ca-5e7b-4add-8c65-d84aff6606d0",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Switch From\nUntuk switch antara @c.us dengan @lid",
        "height": 320,
        "width": 304,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1584,
        0
      ],
      "typeVersion": 1,
      "id": "a5f2a2a9-7258-4fc7-ad44-83d137a05c9c",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Convert @lid ke @c.us\nDokumentasi resmi WAHA : https://waha.devlike.pro/docs/how-to/contacts/#api---lids",
        "height": 432,
        "width": 528,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        336
      ],
      "typeVersion": 1,
      "id": "318badbb-f142-4cb0-8dff-8eb994e518b7",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "## Payload Mapper\nKalau sudah @c.us, langsung forward dan tidak perlu di konversi",
        "height": 320,
        "width": 528,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        0
      ],
      "typeVersion": 1,
      "id": "a193d108-188c-47a2-a7a8-f6d27d1868c8",
      "name": "Sticky Note3"
    },
    {
      "parameters": {
        "content": "## Cek Ignored List\nCek apakah nomor telepon ada di daftar ignored atau tidak (pakai data table di n8n). Kalau ada di list dan statusnya true, abaikan pesan.",
        "height": 336,
        "width": 528,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        0
      ],
      "typeVersion": 1,
      "id": "a714ab66-3c10-4eb2-8eb1-975794621a24",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "## Send Seen\nSupaya tidak terlihat seperti bot (salah satu cara supaya tidak di ban meta)",
        "height": 336,
        "width": 256,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        0
      ],
      "typeVersion": 1,
      "id": "c8cddd1f-6a7a-4488-acb2-b33214021f63",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Ignore Customer Tool\nTool ini digunakan untuk memasukkan nomor telepon pelanggan ke ignore list, digunakan saat pelanggan bertanya diluar konteks atau AI Agent sudah tidak mampu membalas chat",
        "height": 496,
        "width": 384,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2032,
        352
      ],
      "typeVersion": 1,
      "id": "52ce5629-1e5b-4fde-b344-df10625a0d4d",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "content": "## Proses Balas Chat\nSebelum balas chat, pakai efek typing supaya tidak terlalu terlihat seperti bot (salah satu cara supaya tidak di ban meta)",
        "height": 336,
        "width": 1584,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        0
      ],
      "typeVersion": 1,
      "id": "44d35e66-4ec8-4041-9ef3-d8b975ef6a4d",
      "name": "Sticky Note7"
    },
    {
      "parameters": {
        "content": "# Workflow WAHA Untuk Convert @lid + Hold Chat Pakai Data Table\n\nInstagram : https://instagram.com/jipraks\nThreads : https://www.threads.com/@jipraks\nYouTube : https://www.youtube.com/@jipraks\n\nVideo Tutorial Penggunaan Workflow : <youtube-url>",
        "height": 960,
        "width": 704,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3008,
        0
      ],
      "typeVersion": 1,
      "id": "814f7c15-1663-4788-9f2a-3ed0c6492bad",
      "name": "Sticky Note8"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "Xwjn8vSYQI6yzo5I",
          "mode": "list",
          "cachedResultName": "ecom_chatbot_products",
          "cachedResultUrl": "/projects/XjRDWEVSMVwyviNg/datatables/Xwjn8vSYQI6yzo5I"
        },
        "matchType": "allConditions",
        "returnAll": true
      },
      "type": "n8n-nodes-base.dataTableTool",
      "typeVersion": 1,
      "position": [
        2576,
        512
      ],
      "id": "a2604d84-7a50-4122-923b-db1937d3151a",
      "name": "GetProducts"
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Get Products Tool\nTool ini digunakan untuk mendapatkan list product dari database",
        "height": 496,
        "width": 384,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2432,
        352
      ],
      "typeVersion": 1,
      "id": "64af2727-01f6-4a9f-87b1-2c4b03d1b1a1",
      "name": "Sticky Note9"
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Tool untuk membuat pesanan, pastikan semua data sudah lengkap dan customer sudah tidak mau tambah pesanan lagi",
        "dataTableId": {
          "__rl": true,
          "value": "LFt79ktC8APcwfn9",
          "mode": "list",
          "cachedResultName": "ecom_chatbot_orders",
          "cachedResultUrl": "/projects/XjRDWEVSMVwyviNg/datatables/LFt79ktC8APcwfn9"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "customer_name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('customer_name', `Nama Customer (WAJIB DIISI) Harus tanyakan nama customer sebelum membuat order`, 'string') }}",
            "total": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('total', `Total seluruh produk yang dibelanjakan`, 'number') }}",
            "customer_phone": "={{ $('Merge From').item.json.fromPhone }}",
            "products": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('products', `Daftar produk, dipisahkan dengan pipe (|), formatnya \"<sku>;<nama-product>;<qty>;<total_harga>|<sku>;<nama-product>;<qty>;<total_harga>\"`, 'string') }}",
            "status": "NEW"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "customer_name",
              "displayName": "customer_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "customer_phone",
              "displayName": "customer_phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "products",
              "displayName": "products",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "total",
              "displayName": "total",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTableTool",
      "typeVersion": 1,
      "position": [
        2992,
        512
      ],
      "id": "dac898a4-fe85-40da-aab4-b9666a614a1b",
      "name": "CreateOrder"
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Create Order Tool\nTool ini digunakan untuk mencatat pesanan masuk dari customer",
        "height": 496,
        "width": 384,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        352
      ],
      "typeVersion": 1,
      "id": "1b9966f8-dfb4-4af0-a1fa-5522b54e0a8f",
      "name": "Sticky Note10"
    },
    {
      "parameters": {
        "toolDescription": "Gunakan tool ini untuk mengirim gambar produk ke customer jika diminta",
        "method": "POST",
        "url": "=https://<waha-url>/api/sendImage",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "wahaApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"session\": \"{{ $('Data Forwarder').item.json.session }}\",\n  \"chatId\": \"{{ $('Merge From').item.json.fromPhone }}\",\n  \"file\": {\n    \"mimetype\": \"image/jpeg\",\n    \"url\": \"{{ $fromAI(\"imageUrl\", \"URL of image\") }}\",\n    \"filename\": \"image.jpeg\"\n  },\n  \"caption\": \"{{ $fromAI(\"caption\", \"Image caption\") }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.3,
      "position": [
        3392,
        512
      ],
      "id": "b40d4e06-b712-4d3f-a9f6-7cd7634d9fe8",
      "name": "SendImage",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Send Image Tool\nTool ini digunakan untuk mengirim gambar ke WA customer",
        "height": 496,
        "width": 384,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3232,
        352
      ],
      "typeVersion": 1,
      "id": "ce04daf0-641b-4bff-acd5-ad66b71ad2cb",
      "name": "Sticky Note11"
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Get Order Tool\nTool ini digunakan untuk mendapatkan data pesanan customer",
        "height": 496,
        "width": 384,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2032,
        864
      ],
      "typeVersion": 1,
      "id": "5caf7ff7-b8c6-49a8-a7a8-169d017cec9b",
      "name": "Sticky Note12"
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Tools untuk mendapatkan pesanan customer",
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "LFt79ktC8APcwfn9",
          "mode": "list",
          "cachedResultName": "ecom_chatbot_orders",
          "cachedResultUrl": "/projects/XjRDWEVSMVwyviNg/datatables/LFt79ktC8APcwfn9"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "customer_phone",
              "keyValue": "={{ $('Merge From').item.json.fromPhone }}"
            }
          ]
        },
        "returnAll": true
      },
      "type": "n8n-nodes-base.dataTableTool",
      "typeVersion": 1,
      "position": [
        2192,
        992
      ],
      "id": "9530f79d-c575-4bb4-bc3a-80f0e4bd95fa",
      "name": "GetOrders"
    },
    {
      "parameters": {
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Get Order Tool\nTool ini digunakan untuk mendapatkan data pesanan customer",
        "height": 496,
        "width": 384,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2432,
        864
      ],
      "typeVersion": 1,
      "id": "31e75b21-f835-438f-92f8-176a215a067b",
      "name": "Sticky Note13"
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Tools untuk mengupdate pesanan pelanggan menjadi paid setelah memvalidasi bukti pengiriman",
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "LFt79ktC8APcwfn9",
          "mode": "list",
          "cachedResultName": "ecom_chatbot_orders",
          "cachedResultUrl": "/projects/XjRDWEVSMVwyviNg/datatables/LFt79ktC8APcwfn9"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyValue": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('conditions0_Value', `Order ID yang status pesanannya mau diupdate`, 'string') }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "status": "PAID"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "customer_name",
              "displayName": "customer_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "customer_phone",
              "displayName": "customer_phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "products",
              "displayName": "products",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "total",
              "displayName": "total",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "readOnly": false,
              "removed": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTableTool",
      "typeVersion": 1,
      "position": [
        2592,
        992
      ],
      "id": "c4667f09-e993-4337-97c7-a925653a0d57",
      "name": "UpdateOrderPaid"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('Data Forwarder').item.json.payload.hasMedia }}",
                    "rightValue": false,
                    "operator": {
                      "type": "boolean",
                      "operation": "equals"
                    },
                    "id": "47f22a05-19da-4c62-8284-828b5928e693"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "TEXT"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "7ab9a09d-fd3c-4da6-8d14-b89e7b980f75",
                    "leftValue": "={{ $('Data Forwarder').item.json.payload.hasMedia }}",
                    "rightValue": "",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "MEDIA"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        -416,
        128
      ],
      "id": "6f08f0c7-166f-4a2e-888b-72e66b2373a6",
      "name": "Switch Media"
    },
    {
      "parameters": {
        "url": "={{ $('Data Forwarder').item.json.payload.media.url }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "wahaApi",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        -144,
        288
      ],
      "id": "9392abd0-cc5d-4af6-a54e-6fc0fdd9fdb4",
      "name": "Get Media",
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "inputType": "base64",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        64,
        288
      ],
      "id": "e0917c37-2721-4780-870b-df7c691a71ef",
      "name": "Analyze image",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fde06b09-2e3e-43b6-b983-928f7a67b457",
              "name": "inboundChat",
              "value": "=IMAGE ANALYSIS :\n\n{{ $json['0'].content[0].text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        272,
        288
      ],
      "id": "55997f40-81d8-43cb-86fa-7dbb29c09f4f",
      "name": "Map Data - Media"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fde06b09-2e3e-43b6-b983-928f7a67b457",
              "name": "inboundChat",
              "value": "=IMAGE ANALYSIS :\n\n{{ $json['0'].content[0].text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        272,
        112
      ],
      "id": "872fa867-b3cb-4a59-be3d-15d28b523a63",
      "name": "Map Data - Text"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        656,
        128
      ],
      "id": "29ac1add-8c84-4f1d-bbe3-d9fb48f33660",
      "name": "Merge Inbound Chat"
    }
  ],
  "connections": {
    "WAHA Trigger": {
      "main": [
        [],
        [
          {
            "node": "Data Forwarder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch From": {
      "main": [
        [
          {
            "node": "Payload Mapper C.US",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert LID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Forwarder": {
      "main": [
        [
          {
            "node": "Switch From",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert LID": {
      "main": [
        [
          {
            "node": "Payload Mapper LID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Payload Mapper C.US": {
      "main": [
        [
          {
            "node": "Merge From",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Payload Mapper LID": {
      "main": [
        [
          {
            "node": "Merge From",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge From": {
      "main": [
        [
          {
            "node": "Switch Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ignored Phone Data": {
      "main": [
        [
          {
            "node": "If Phone Ignored",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Phone Ignored": {
      "main": [
        [],
        [
          {
            "node": "Send Seen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "IgnoreCustomer": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Start Typing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Typing": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Seen": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Stop Typing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop Typing": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetProducts": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "CreateOrder": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "SendImage": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "GetOrders": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Switch Media": {
      "main": [
        [
          {
            "node": "Map Data - Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Media": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "Map Data - Media",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Data - Text": {
      "main": [
        [
          {
            "node": "Merge Inbound Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Data - Media": {
      "main": [
        [
          {
            "node": "Merge Inbound Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Inbound Chat": {
      "main": [
        [
          {
            "node": "Ignored Phone Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateOrderPaid": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "6748581b-cdb9-4162-8d30-1e89c5d83d09",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "eISEz0neTDrUIXgj",
  "tags": []
}