{
  "name": "Bengali Memoriz",
  "nodes": [
    {
      "parameters": {
        "multipleMethods": true,
        "path": "bengalimemoiz",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -464,
        64
      ],
      "id": "b62c988b-ae2a-4e65-b621-d9c7cc45b3b1",
      "name": "Webhook",
      "webhookId": "71e6806a-68a8-46c6-855e-dbec77d1cfb8"
    },
    {
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ $json.query['hub.challenge'] }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        -240,
        -32
      ],
      "id": "7be30e1c-f67d-4ea9-a477-4238099764de",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v25.0/{{ $('Switch').item.json.body.entry[0].id }}/messages",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "EAAb3una0zrsBQ97TkZA1xZCaf5Wtp1wewoiKnO6qlnOMTsuzk3C0rkVZA0ZALf1040ziFjqsnctgLtgKZB7dRQkMmefLMI07E1YSlrLaDrWxgkgXZAD0U56AeKBFgKW9VS6JhySkqQSQPsmy2xzpxKX6JONKoU8UPUvjqZC8u7nxeYR45TMZBtrEKFtCt4laozoZBHfJDB5hI9YDbRRufUBGqDbsGpwZDZD"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"recipient\": {\n    \"id\": \"{{ $('Switch').item.json.body.entry[0].messaging[0].sender.id }}\"\n  },\n  \"messaging_type\": \"RESPONSE\",\n  \"message\": {\n    \"text\": {{ JSON.stringify($json.output)}}\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        1376,
        240
      ],
      "id": "9005cf58-7b3a-42cf-a36b-b257c77a9a67",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=User Send massage: {{ $json.body.entry[0].messaging[0].message.text }}\nUser Audio massage: {{ $json.text }}\nUser Image massage: {{ $json['0'].content[0].text }}",
        "options": {
          "systemMessage": "You are an AI assistant for \"Bengali Memoriz\", a professional Photography & Videography service based in Dimla, Bangladesh.\n\n🎯 Your Main Goal:\n- Always reply in Bangla\n- Act like a friendly human admin (not robot)\n- Convert users into customers (booking or phone call)\n- Keep replies short, clear, and engaging\n\n📌 Business Information:\n- Services: Photography, Videography, Cinematic Video, Social Media Content\n- Location: Dimla, Bangladesh\n- Phone: +880 1736-412170\n- Email: bengalimemoiz@gmail.com\n\n🗣️ Language Rules:\n- Always reply in Bangla\n- Use simple natural Bangla (mix English words like booking, package if needed)\n- Use polite tone\n- Use emoji moderately (😊📸🎬)\n\n💬 Conversation Flow:\n1. Greet politely (if first message)\n2. Understand user intent (service / booking / price / location / etc.)\n3. Give short answer\n4. Always ask a follow-up question\n5. Guide user toward booking or call\n\n💰 Pricing Strategy (VERY IMPORTANT):\n- NEVER mention fixed price\n- ALWAYS say: \"দাম কাজের ধরন অনুযায়ী নির্ধারণ করা হয়\"\n- Ask for details:\n  • Date\n  • Time\n  • Location\n  • Service type\n- Encourage call for final discussion\n\n📞 Conversion Strategy:\n- If user is interested → collect booking details\n- If user asks too much → suggest call\n- If user seems serious → push call gently\n- If urgent → strongly suggest call\n\nExample:\n\"আপনি চাইলে সরাসরি কল করে বিস্তারিত জানতে পারেন 📞 +8801736412170\"\n\n🧾 Booking Flow (UPDATED - VERY IMPORTANT):\nIf user provides:\n- নাম\n- ফোন নাম্বার\n- তারিখ\n\nThen:\n\n1. Confirm booking:\n\"ধন্যবাদ 😊  \nআপনার বুকিং রিকোয়েস্ট গ্রহণ করা হয়েছে ✅  \n\nআমাদের টিম খুব দ্রুত আপনার সাথে যোগাযোগ করবে 📞  \nঅনুগ্রহ করে আপনার ফোনটি সচল রাখুন 👍\"\n\n2. STOP asking more questions\n\n3. Mark internally:\n👉 BOOKING_READY = TRUE\n\n4. Prepare data:\n(name, phone, date, time, location, service)\n\n5. This should trigger backend to save booking in Google Sheets with:\nStatus = Pending\n\n⚠️ Important:\n- Do NOT mention price after booking\n- Do NOT continue long conversation after booking\n- Keep response short\n\n⚡ Urgent Handling:\nIf message includes urgent/fast/asap:\n👉 Reply:\n\"আপনার কাজটি জরুরি হলে সরাসরি কল করুন 📞 +8801736412170\"\n\n🚫 Avoid:\n- Long paragraphs\n- Complex explanation\n- Giving fixed price\n- Continuing chat after booking confirmed\n\n✅ Example Style:\n\"ধন্যবাদ আমাদের সাথে যোগাযোগ করার জন্য 😊  \nআপনি কী ধরনের সার্ভিস নিতে চান?\"\n\nAlways behave like a smart sales-focused assistant who helps convert leads into real customers and triggers booking save when ready."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        624,
        240
      ],
      "id": "8d35cd40-abeb-404c-818f-0eaf64bd981f",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-nano",
          "mode": "list",
          "cachedResultName": "gpt-4.1-nano"
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        432,
        464
      ],
      "id": "e9407457-5933-48ed-8ba0-90db175a4c66",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "CEfIjTDmdi9KEQd5",
          "name": "MTiTBD.com"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "=User Send massage: {{ $json.body.entry[0].messaging[0].sender.id }}\nUser Audio massage: {{ $json.text }}\nUser Image massage:",
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        560,
        464
      ],
      "id": "afd5e112-24b0-4163-9aa7-e474cc78b8d9",
      "name": "Simple Memory"
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        688,
        464
      ],
      "id": "0c668c45-6a2e-402e-86e1-5c66496a0658",
      "name": "Calculator"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.body.entry[0].messaging[0].message.attachments[0].type }}",
                    "rightValue": "image",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "2a924352-da85-4f4e-9d95-cc58583476f9"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "image"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "35a3f3b2-d24a-4b0b-9559-ce8f1f048139",
                    "leftValue": "={{ $json.body.entry[0].messaging[0].message.attachments[0].type }}",
                    "rightValue": "=audio",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Audio"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "c5975770-aa64-4e5e-b270-b0f8840001f4",
                    "leftValue": "={{ $json.body.entry[0].messaging[0].message.text }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "text"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        -240,
        160
      ],
      "id": "73bbf648-63d5-45f6-8590-f277306b29c3",
      "name": "Switch"
    },
    {
      "parameters": {
        "url": "={{ $json.body.entry[0].messaging[0].message.attachments[0].payload.url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        -16,
        -32
      ],
      "id": "55a6bcf3-338c-4882-bec2-b0307e360b3b",
      "name": "images"
    },
    {
      "parameters": {
        "resource": "image",
        "operation": "analyze",
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "text": "=extract the product id from the image only respond in 5 words\nwithe product id. If you get product name you can also provide that.",
        "inputType": "base64",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        208,
        -32
      ],
      "id": "96e79145-d5ce-49c1-b0b9-03a812ed8346",
      "name": "Analyze image",
      "credentials": {
        "openAiApi": {
          "id": "CEfIjTDmdi9KEQd5",
          "name": "MTiTBD.com"
        }
      }
    },
    {
      "parameters": {
        "url": "={{ $('Webhook').item.json.body.entry[0].messaging[0].message.attachments[0].payload.url }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        -16,
        160
      ],
      "id": "e8bfd035-e96c-4842-83cc-2aae48edbc40",
      "name": "Audio"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "translate",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.1,
      "position": [
        208,
        160
      ],
      "id": "944ba16d-014b-458a-894d-5148a640a6fe",
      "name": "Translate a recording",
      "credentials": {
        "openAiApi": {
          "id": "CEfIjTDmdi9KEQd5",
          "name": "MTiTBD.com"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "for (const item of items) {\n  const field = 'output';\n\n  if (typeof item.json[field] === 'string') {\n\n    let msg = item.json[field];\n\n    // Fix escaped newline\n    msg = msg.replace(/\\\\n/g, \"\\n\");\n\n    // Optional cleanup\n    msg = msg.trim();\n\n    item.json[field] = msg;\n  }\n}\n\nreturn items;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1152,
        240
      ],
      "id": "6c388c9b-49d8-40f1-872c-b0fad00dda11",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "14WUw6q5vm_FPQSzQiOrioDx4e4Z-cBCeA39O5A7kn1w",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": 1670600797,
          "mode": "list",
          "cachedResultName": "Booking",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14WUw6q5vm_FPQSzQiOrioDx4e4Z-cBCeA39O5A7kn1w/edit#gid=1670600797"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Booking ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Booking_ID', ``, 'string') }}",
            "Client Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Client_Name', ``, 'string') }}",
            "Phone": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone', ``, 'string') }}",
            "Service Type": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Service_Type', ``, 'string') }}",
            "Date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Date', ``, 'string') }}",
            "Time": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Time', ``, 'string') }}",
            "Location": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Location', ``, 'string') }}",
            "Package": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Package', ``, 'string') }}",
            "Price": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Price', ``, 'string') }}",
            "Status": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Status', ``, 'string') }}",
            "Source": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Source', ``, 'string') }}",
            "Notes": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Notes', ``, 'string') }}",
            "Assigned To": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Assigned_To', ``, 'string') }}",
            "Created Date": "={{ $now.format('yyyy-MM-dd HH:mm') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Booking ID",
              "displayName": "Booking ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Client Name",
              "displayName": "Client Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Service Type",
              "displayName": "Service Type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Time",
              "displayName": "Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Location",
              "displayName": "Location",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Package",
              "displayName": "Package",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Price",
              "displayName": "Price",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "displayName": "Source",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Notes",
              "displayName": "Notes",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Assigned To",
              "displayName": "Assigned To",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Created Date",
              "displayName": "Created Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        944,
        464
      ],
      "id": "b4558d87-ce0f-485d-bc0b-b48883418b89",
      "name": "Booking",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "Jy5ZoEeX0GDv8Cdx",
          "name": "MTiTBD Ltd."
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "14WUw6q5vm_FPQSzQiOrioDx4e4Z-cBCeA39O5A7kn1w",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Customer Response",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14WUw6q5vm_FPQSzQiOrioDx4e4Z-cBCeA39O5A7kn1w/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.7,
      "position": [
        816,
        464
      ],
      "id": "b3ce3307-58d4-49b4-a4a6-662a05b19a20",
      "name": "Customer Response",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "Jy5ZoEeX0GDv8Cdx",
          "name": "MTiTBD Ltd."
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "images",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Audio",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "images": {
      "main": [
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Audio": {
      "main": [
        [
          {
            "node": "Translate a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translate a recording": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Booking": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Customer Response": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "5103c5ec-40aa-43a9-98a0-5e5cde656e99",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "32d395072c109fe5194065154dd525f8ed73153eeb11cf67f73f7f3e4a75f37b"
  },
  "id": "iAPEcTve2kZvzdt6",
  "tags": []
}