{
  "name": "Create an AI chatbot for WhatsApp with Whapi.Cloud and OpenAI GPT-3.5",
  "nodes": [
    {
      "id": "221ce7c6-3987-4463-9693-5959ab475597",
      "name": "1️⃣ Receive WhatsApp Message",
      "type": "n8n-nodes-base.webhook",
      "position": [
        1232,
        896
      ]
    },
    {
      "id": "ec04f539-2ca5-4a7b-bc58-0c985160daca",
      "name": "2️⃣ Get Message Info",
      "type": "n8n-nodes-base.set",
      "position": [
        1456,
        896
      ]
    },
    {
      "id": "89f18156-b6a7-46ad-b8fd-25c608d77160",
      "name": "3️⃣ Ignore Bot's Own Messages",
      "type": "n8n-nodes-base.if",
      "position": [
        1664,
        896
      ]
    },
    {
      "id": "1db9f48c-b079-43df-afe2-3051242d682b",
      "name": "4️⃣ What Type of Command?",
      "type": "n8n-nodes-base.switch",
      "position": [
        2400,
        816
      ]
    },
    {
      "id": "9bf2270e-cc18-4fbd-853d-b57fd992c739",
      "name": "Extract AI Question",
      "type": "n8n-nodes-base.set",
      "position": [
        2928,
        496
      ]
    },
    {
      "id": "8c497783-23ea-4e3b-8a59-d05291a39290",
      "name": "Format AI Answer",
      "type": "n8n-nodes-base.set",
      "position": [
        3472,
        496
      ]
    },
    {
      "id": "9dbbb18d-ff8a-4243-84ab-c51a9267fe18",
      "name": "5️⃣ Which Number Command? (1-9)",
      "type": "n8n-nodes-base.switch",
      "position": [
        2928,
        1680
      ]
    },
    {
      "id": "02d4a23b-fef4-410c-806b-e879b91a97aa",
      "name": "Show Help Menu",
      "type": "n8n-nodes-base.set",
      "position": [
        3424,
        880
      ]
    },
    {
      "id": "804f60e8-2ea4-47e0-808b-d605af8511b2",
      "name": "Prepare: Simple Text",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        1328
      ]
    },
    {
      "id": "fd1d87b2-9f9a-4b54-99ce-a3445e986146",
      "name": "📤 Send Text Message",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4672,
        624
      ]
    },
    {
      "id": "71c4bbf6-f7e1-4056-99f9-c785d917809c",
      "name": "Prepare: Image (Command 2)",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        1488
      ]
    },
    {
      "id": "d90091d7-4757-4191-9a01-99db453d906e",
      "name": "📤 Send Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3776,
        1488
      ]
    },
    {
      "id": "b5a42cc5-ceae-4885-90a8-e1611cf69147",
      "name": "Prepare: Document (Command 3)",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        1696
      ]
    },
    {
      "id": "014a5025-5bfa-4c0d-8960-426d2356a17b",
      "name": "📤 Send Document",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3776,
        1696
      ]
    },
    {
      "id": "d67733e9-b334-42f8-a9d5-76aaf06e36b6",
      "name": "Prepare: Video (Command 4)",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        1904
      ]
    },
    {
      "id": "f70c5397-aecf-40e1-8011-2648aa59f7ff",
      "name": "📤 Send Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3776,
        1904
      ]
    },
    {
      "id": "8590f37f-dd6d-411d-8ee8-0a6fab3466f2",
      "name": "📤 Send Contact",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3776,
        2112
      ]
    },
    {
      "id": "ed7e0644-590b-4764-b16b-639d46469c6f",
      "name": "Create WhatsApp Group",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3776,
        2512
      ]
    },
    {
      "id": "2643fb43-1ee7-4e9a-91da-05b83371b241",
      "name": "Format Group Creation Result",
      "type": "n8n-nodes-base.set",
      "position": [
        4016,
        2512
      ]
    },
    {
      "id": "c61c2d5d-0d9d-4d21-a739-72c13c2368fb",
      "name": "Prepare: Group Message (Command 8)",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        2720
      ]
    },
    {
      "id": "5e34de2e-7f0e-44a1-8bd5-5ee7d9d563fc",
      "name": "Get Groups List (Command 9)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3536,
        2944
      ]
    },
    {
      "id": "883de69f-e840-4107-bb90-702c487dc485",
      "name": "Format Groups List",
      "type": "n8n-nodes-base.set",
      "position": [
        3760,
        2944
      ]
    },
    {
      "id": "df93303e-38b6-42fe-ae07-b0ce23c914bd",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        704
      ],
      "parameters": {
        "width": 624,
        "height": 608,
        "content": "## How it works\n\nThis workflow is a WhatsApp bot built with the Whapi.Cloud API. Messages arrive through a webhook. The workflow reads each message and routes it. If the text starts with /AI, the rest"
      }
    },
    {
      "id": "9a30719d-2737-4ef7-9da0-c33f2946dc20",
      "name": "Webhook Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        1072
      ],
      "parameters": {
        "width": 336,
        "height": null,
        "content": "## Webhook Trigger\n\nReceives incoming WhatsApp messages from Whapi.Cloud. Configure the webhook URL in [Whapi.Cloud Channel settings](https://panel.whapi.cloud/dashboard) to point to this endpoint."
      }
    },
    {
      "id": "259ae736-a30c-4943-935d-988cfef54585",
      "name": "Route Command Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2256,
        1024
      ],
      "parameters": {
        "width": 352,
        "height": 192,
        "content": "Routes incoming messages to appropriate handlers:\n- **AI output:** Messages starting with `/AI ` → OpenAI integration\n- **Numeric output:** Messages with digits (1-9) → Command routing\n- **Default out"
      }
    },
    {
      "id": "5bbb02b8-1a4f-4211-9503-b9e2db5178a0",
      "name": "AI Integration Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2960,
        368
      ],
      "parameters": {
        "width": 576,
        "height": 96,
        "content": "Uses OpenAI ChatGPT for AI-powered responses. Requires `OPENAI_API_KEY` environment variable.\n\n**Usage:** Send `/AI <your message>` to chat with ChatGPT."
      }
    },
    {
      "id": "b6d0d848-10a8-4c70-b844-a3c9fc536c2e",
      "name": "Switch Node Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2832,
        2112
      ],
      "parameters": {
        "width": 288,
        "height": 256,
        "content": "Routes numeric commands (1-9) to specific handlers:\n- **1:** Text message\n- **2:** Image\n- **3:** Document\n- **4:** Video\n- **5:** Contact\n- **6:** Product\n- **7:** Create group\n- **8:** Group text\n- "
      }
    },
    {
      "id": "49001bc0-deec-4099-b903-33b3c2696a64",
      "name": "Command 1 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4544,
        1360
      ],
      "parameters": {
        "width": 544,
        "height": 240,
        "content": "## Command 1: Simple Text\n\n**User sends:** `1`\n\n**What happens:**\n1. Prepares text message\n2. Sends via Whapi.Cloud\n\n**To customize:** Edit \"Prepare: Simple Text\" node → Change `body` field"
      }
    },
    {
      "id": "56479bba-fb63-4e73-bd9a-7f0398660a7d",
      "name": "Command 2 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5120,
        1360
      ],
      "parameters": {
        "width": 560,
        "height": 240,
        "content": "## Command 2: Send Image\n\n**User sends:** `2`\n\n**What happens:**\n1. Prepares image data (URL path, caption)\n2. Sends via Whapi.Cloud\n\n**To customize:** Edit \"Prepare: Image\" node → Change `mediaPath` "
      }
    },
    {
      "id": "ab320567-1d57-4a65-8056-504ee61ee1c7",
      "name": "Command 3 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4544,
        1632
      ],
      "parameters": {
        "width": 544,
        "height": 256,
        "content": "## Command 3: Send Document\n\n**User sends:** `3`\n\n**What happens:**\n1. Prepares PDF document data (URL path, caption, filename)\n2. Sends via Whapi.Cloud\n\n**To customize:** Edit \"Prepare: Document\" nod"
      }
    },
    {
      "id": "d20b859e-1073-4f6c-9254-1a8ec4e7d413",
      "name": "Command 4 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5120,
        1632
      ],
      "parameters": {
        "width": 560,
        "height": 256,
        "content": "## Command 4: Send Video\n\n**User sends:** `4`\n\n**What happens:**\n1. Prepares video data (URL path, caption)\n2. Sends via Whapi.Cloud\n\n**To customize:** Edit \"Prepare: Video\" node → Change `mediaPath` "
      }
    },
    {
      "id": "9ae9c2a9-065f-49a7-83b5-78e022cfe129",
      "name": "Command 5 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4544,
        1920
      ],
      "parameters": {
        "width": 544,
        "height": 256,
        "content": "## Command 5: Send Contact\n\n**User sends:** `5`\n\n**What happens:**\n1. Prepares contact data (name, vCard). You can use [the vCard generator in the dashboard](https://panel.whapi.cloud/tools/vcard-crea"
      }
    },
    {
      "id": "b26c453a-5122-4d20-871e-390363954543",
      "name": "Command 6 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5120,
        1920
      ],
      "parameters": {
        "width": 560,
        "height": 256,
        "content": "## Command 6: Get Product\n\n**User sends:** `6`\n\nYou need [to find out your ProductID](https://whapi.readme.io/reference/getproducts) before you use this command. \n\n**To customize:**  Edit \"Prepare: Pr"
      }
    },
    {
      "id": "cce74f62-ba4d-47c1-969b-d1b3a210849b",
      "name": "Command 7 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4544,
        2208
      ],
      "parameters": {
        "width": 544,
        "height": 288,
        "content": "## Command 7: Create Group\n\n**User sends:** `7`\n\n**What happens:**\n1. Extracts sender phone number\n2. Creates new WhatsApp group\n3. Adds the sender and several other numbers as participants\n4. Returns"
      }
    },
    {
      "id": "46e36acc-cb02-4aaa-9763-2b01962e947e",
      "name": "Command 8 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5120,
        2208
      ],
      "parameters": {
        "width": 560,
        "height": 288,
        "content": "## Command 8: Group Message\n\n**User sends:** `8`\n\n**What happens:**\n1. Prepares message for group\n2. Uses GROUP_ID from environment or provide a specific identifier \n3. Sends message to group\n\n**Requi"
      }
    },
    {
      "id": "7cb3653b-f3e6-4b80-9d06-0ef86c779bfa",
      "name": "Command 9 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4544,
        2528
      ],
      "parameters": {
        "width": 544,
        "height": 256,
        "content": "## Command 9: List Groups\n\n**User sends:** `9`\n\n**What happens:**\n1. Gets list of up to 3 groups\n2. Formats group IDs and names\n3. Sends list to user\n\n**Use this:** To get GROUP_ID for Command 8"
      }
    },
    {
      "id": "8e1e8fcc-3c71-4f99-a49b-d7e7c286f62c",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        3136,
        496
      ]
    },
    {
      "id": "4a9b587a-7edc-426a-80b3-8d258a286e42",
      "name": "📤 Send Product",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3776,
        2304
      ]
    },
    {
      "id": "2dec4c9f-4068-48e8-a5ce-fd7aa280a0e9",
      "name": "Prepare: Contact (Command 5)",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        2112
      ]
    },
    {
      "id": "405823af-b8ba-48d9-a86f-52b9aa0612f1",
      "name": "Prepare: Product (Command 6)",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        2304
      ]
    },
    {
      "id": "53ff7c93-3dac-4319-acb4-d0a716bbc759",
      "name": "Prepare: Create Group (Command 7)",
      "type": "n8n-nodes-base.set",
      "position": [
        3536,
        2512
      ]
    },
    {
      "id": "98040a79-78ed-407b-9a10-65c38a3fb898",
      "name": "✔✔ Mark message as read",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2016,
        832
      ]
    }
  ],
  "connections": {
    "Show Help Menu": {
      "main": [
        [
          {
            "node": "📤 Send Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Format AI Answer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Answer": {
      "main": [
        [
          {
            "node": "📤 Send Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Groups List": {
      "main": [
        [
          {
            "node": "📤 Send Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract AI Question": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Simple Text": {
      "main": [
        [
          {
            "node": "📤 Send Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create WhatsApp Group": {
      "main": [
        [
          {
            "node": "Format Group Creation Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2️⃣ Get Message Info": {
      "main": [
        [
          {
            "node": "3️⃣ Ignore Bot's Own Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Image (Command 2)": {
      "main": [
        [
          {
            "node": "📤 Send Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Video (Command 4)": {
      "main": [
        [
          {
            "node": "📤 Send Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Groups List (Command 9)": {
      "main": [
        [
          {
            "node": "Format Groups List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "✔✔ Mark message as read": {
      "main": [
        [
          {
            "node": "4️⃣ What Type of Command?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Group Creation Result": {
      "main": [
        [
          {
            "node": "📤 Send Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Contact (Command 5)": {
      "main": [
        [
          {
            "node": "📤 Send Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Product (Command 6)": {
      "main": [
        [
          {
            "node": "📤 Send Product",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4️⃣ What Type of Command?": {
      "main": [
        [
          {
            "node": "Extract AI Question",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "5️⃣ Which Number Command? (1-9)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Show Help Menu",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Document (Command 3)": {
      "main": [
        [
          {
            "node": "📤 Send Document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1️⃣ Receive WhatsApp Message": {
      "main": [
        [
          {
            "node": "2️⃣ Get Message Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3️⃣ Ignore Bot's Own Messages": {
      "main": [
        [
          {
            "node": "✔✔ Mark message as read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Create Group (Command 7)": {
      "main": [
        [
          {
            "node": "Create WhatsApp Group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare: Group Message (Command 8)": {
      "main": [
        [
          {
            "node": "📤 Send Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5️⃣ Which Number Command? (1-9)": {
      "main": [
        [
          {
            "node": "Prepare: Simple Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare: Image (Command 2)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare: Document (Command 3)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare: Video (Command 4)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare: Contact (Command 5)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare: Product (Command 6)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare: Create Group (Command 7)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare: Group Message (Command 8)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Groups List (Command 9)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}