{
    "name": "Whatsapp POST Method",
    "nodes": [
        {
            "parameters": {
                "httpMethod": "POST",
                "path": "whatsapp-incoming",
                "responseMode": "responseNode",
                "options": []
            },
            "type": "n8n-nodes-base.webhook",
            "typeVersion": 2.1,
            "position": [
                -496,
                0
            ],
            "id": "0571b362-c328-430e-bf52-4215c9232a7a",
            "name": "Webhook",
            "webhookId": "e7ce095d-aaa4-4d5b-b9c7-aee9492c980f"
        },
        {
            "parameters": {
                "respondWith": "text",
                "responseBody": "EVENT_RECEIVED",
                "options": {
                    "responseCode": 200
                }
            },
            "type": "n8n-nodes-base.respondToWebhook",
            "typeVersion": 1.4,
            "position": [
                -240,
                0
            ],
            "id": "ba093562-e834-4e1a-9a60-12fafe167c4f",
            "name": "Respond to Webhook"
        },
        {
            "parameters": {
                "jsCode": "const v = $json.body?.entry?.[0]?.changes?.[0]?.value ?? {};\nconst m = v.messages?.[0] ?? {};\nreturn [{\n  from: m.from || \"\",\n  text: m.text?.body || \"\",\n  type: m.type || \"\",\n  name: v.contacts?.[0]?.profile?.name || \"\",\n  phoneNumberId: v.metadata?.phone_number_id,\n  msgId: m.id || \"\",\n  timestamp: Number(m.timestamp || 0),\n  raw: $json.body\n}];\n"
            },
            "type": "n8n-nodes-base.code",
            "typeVersion": 2,
            "position": [
                -32,
                0
            ],
            "id": "f18c650b-01ee-443b-a9f6-245a7d859a69",
            "name": "Code"
        },
        {
            "parameters": {
                "method": "POST",
                "url": "=https:\/\/graph.facebook.com\/v20.0\/{{$json.phoneNumberId}}\/messages",
                "sendHeaders": true,
                "headerParameters": {
                    "parameters": [
                        {
                            "name": "=Authorization",
                            "value": "Bearer EAAIrlBapNGABPDEePXTgI9EoSw9m1n5rUWpCZBnrg85FA3X4iyYnOWuwgZAYykLEN3IgyjnipWjsdK17AlEzNw8KAFXpWsZASyfOkjPriVwmzYTnv4UhY4NO1nLVZAgn7A7XkvQZC9TjobUawaFQuuDXPekuiIwqkZBmpZCttJQp4bkxJZCZARaG8cOMHcLAPC8twZBQZDZD"
                        },
                        {
                            "name": "Content-Type",
                            "value": "application\/json"
                        }
                    ]
                },
                "sendBody": true,
                "specifyBody": "json",
                "jsonBody": "={\n  \"messaging_product\": \"whatsapp\",\n  \"to\": \"={{$json.from}}\",\n  \"context\": { \"message_id\": \"={{$json.msgId}}\" },\n  \"text\": { \"body\": \"تم الاستلام ✅\\nرسالتك: {{$json.text}}\" }\n}",
                "options": []
            },
            "type": "n8n-nodes-base.httpRequest",
            "typeVersion": 4.2,
            "position": [
                176,
                0
            ],
            "id": "005924df-7fef-4c6d-a52f-90117c07cb76",
            "name": "HTTP Request"
        }
    ],
    "pinData": {
        "Webhook": [
            {
                "json": {
                    "headers": {
                        "host": "n8n.srv942514.hstgr.cloud",
                        "user-agent": "facebookexternalua",
                        "content-length": "758",
                        "accept": "*\/*",
                        "accept-encoding": "deflate, gzip",
                        "content-type": "application\/json",
                        "x-forwarded-for": "172.18.0.1",
                        "x-forwarded-host": "n8n.srv942514.hstgr.cloud",
                        "x-forwarded-port": "443",
                        "x-forwarded-proto": "https",
                        "x-forwarded-server": "28d2f7c62b9b",
                        "x-hub-signature": "sha1=0672647725917fdb63f0b158b57e9b0d261fee2e",
                        "x-hub-signature-256": "sha256=4d34a7e5e03d4e6598f1cc5ab41802555915f1261c3382c58cbf3c5da2c80db0",
                        "x-real-ip": "172.18.0.1"
                    },
                    "params": [],
                    "query": [],
                    "body": {
                        "object": "whatsapp_business_account",
                        "entry": [
                            {
                                "id": "747329171557457",
                                "changes": [
                                    {
                                        "value": {
                                            "messaging_product": "whatsapp",
                                            "metadata": {
                                                "display_phone_number": "15076726092",
                                                "phone_number_id": "731974480005551"
                                            },
                                            "contacts": [
                                                {
                                                    "profile": {
                                                        "name": "شركة دروب أيديا للتجارة الرقمية والالكترونية ذ.م.م"
                                                    },
                                                    "wa_id": "962798402930"
                                                }
                                            ],
                                            "messages": [
                                                {
                                                    "from": "962798402930",
                                                    "id": "wamid.HBgMOTYyNzk4NDAyOTMwFQIAEhggMEJEMkVFMzY1ODk1NkY1MDYxNTU1OTNFQUNDRkQxQTIA",
                                                    "timestamp": "1755535210",
                                                    "text": {
                                                        "body": "تااا"
                                                    },
                                                    "type": "text"
                                                }
                                            ]
                                        },
                                        "field": "messages"
                                    }
                                ]
                            }
                        ]
                    },
                    "webhookUrl": "https:\/\/n8n.srv942514.hstgr.cloud\/webhook\/whatsapp-incoming",
                    "executionMode": "production"
                }
            }
        ]
    },
    "connections": {
        "Webhook": {
            "main": [
                [
                    {
                        "node": "Respond to Webhook",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Respond to Webhook": {
            "main": [
                [
                    {
                        "node": "Code",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        },
        "Code": {
            "main": [
                [
                    {
                        "node": "HTTP Request",
                        "type": "main",
                        "index": 0
                    }
                ]
            ]
        }
    },
    "active": false,
    "settings": {
        "executionOrder": "v1"
    },
    "versionId": "0a86c762-7bb6-4e6a-91d8-69ba97092a73",
    "meta": {
        "instanceId": "a85fc6519b374e86e01063acbb733de8f006266ec78aa34c0f3dbebd8434a16e"
    },
    "id": "qHFtH0Tf3kQQ5ItC",
    "tags": []
}