{
  "name": "An AI assistant that answers your WhatsApp 24/7 and hands over to a person when asked",
  "nodes": [
    {
      "parameters": {
        "content": "What you get: an AI agent that replies to WhatsApp messages using your own instructions (hours, services, what to escalate) and steps aside when the customer asks for a human.\nWhat it replaces: night-time and weekend messages that wait until Monday, and generic chatbot builders.\nSetup time: about 15 minutes (needs an OpenAI key).\n\nYour first line of support on WhatsApp, awake around the clock, with a clear way to reach a person.\n\nWorks with a normal WhatsApp number — no Meta Business account needed.\n\nSetup:\n1. Create an API key at https://developers.wasync.app/keys (scopes: whatsapp.send (add whatsapp.events too if you'll use the optional Register Webhook node)).\n2. In n8n, go to Credentials -> New -> Header Auth. Name the credential \"WASync API key\". Set its Name field to `Authorization` and its Value field to `Bearer wsk_live_<your key>`.\n3. Open the \"Settings\" node at the top of this workflow and fill in your own values. Never commit real portal URLs, tokens, connection ids, or phone numbers.\n\nPoint WASync at this workflow's Webhook node: copy its Production URL (Webhook node -> double-click -> \"Production URL\"), then either paste it at developers.wasync.app (Webhooks section) for event `message.received`, or call `PUT https://developers.wasync.app/api/v1/webhook` with `{\"url\": \"<that URL>\"}` using your API key. The disabled \"Register WASync Webhook (one-time)\" HTTP Request node below does the same call -- fill in the URL, enable it, execute it once, then disable it again (PUT is idempotent, so running it again just moves the endpoint).\n\nYou also need an OpenAI API key and credential in n8n for the Chat Model node. Edit the system prompt in the AI Agent node's \"Settings\" input to describe escalation rules for your own business -- refunds, complaints, anything outside what the bot should handle.\n\nThis template uses only built-in n8n nodes, so it works on n8n Cloud; if you self-host, you can also use our community node n8n-nodes-wasync.\n\nDocs: https://docs.wasync.app/docs/guides/n8n?utm_source=n8n&utm_medium=template&utm_campaign=t4-http",
        "height": 600,
        "width": 520
      },
      "name": "Read Me First",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -160
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "wasync-inbound",
        "responseMode": "onReceived",
        "options": {}
      },
      "name": "WhatsApp Inbound Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        200
      ]
    },
    {
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "Settings-0",
              "name": "companyName",
              "value": "Your Company",
              "type": "string"
            },
            {
              "id": "Settings-1",
              "name": "openingHours",
              "value": "Mon-Fri 9:00-18:00 (Europe/Bucharest)",
              "type": "string"
            },
            {
              "id": "Settings-2",
              "name": "escalationInstructions",
              "value": "Escalate (do not answer yourself) for: refund requests, complaints, anything you are not confident about, or if the customer explicitly asks for a human.",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        0,
        460
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "Wants Human?-cond0",
              "leftValue": "={{ $('WhatsApp Inbound Webhook').item.json.body.message.text.toLowerCase() }}",
              "rightValue": "human",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            },
            {
              "id": "Wants Human?-cond1",
              "leftValue": "={{ $('WhatsApp Inbound Webhook').item.json.body.message.text.toLowerCase() }}",
              "rightValue": "agent",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "name": "Wants Human?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        260,
        460
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://developers.wasync.app/api/v1/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "options": {},
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ connectionId: $('WhatsApp Inbound Webhook').item.json.body.connection_id, to: $('WhatsApp Inbound Webhook').item.json.body.message.from, text: 'A colleague will reply shortly.' }) }}"
      },
      "name": "Send Human Handover Notice",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        520,
        300
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "WASync API key"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('WhatsApp Inbound Webhook').item.json.body.message.text }}",
        "options": {
          "systemMessage": "=You are a helpful WhatsApp assistant for {{ $('Settings').item.json.companyName }}.\nOpening hours: {{ $('Settings').item.json.openingHours }}.\n{{ $('Settings').item.json.escalationInstructions }}\nKeep replies short, friendly, and suitable for WhatsApp (a few sentences at most)."
        }
      },
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        520,
        560
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {}
      },
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        520,
        760
      ],
      "credentials": {
        "openAiApi": {
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://developers.wasync.app/api/v1/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "options": {},
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ connectionId: $('WhatsApp Inbound Webhook').item.json.body.connection_id, to: $('WhatsApp Inbound Webhook').item.json.body.message.from, text: $json.output }) }}"
      },
      "name": "Send AI Reply",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        780,
        560
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "WASync API key"
        }
      }
    },
    {
      "parameters": {
        "method": "PUT",
        "url": "https://developers.wasync.app/api/v1/webhook",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "options": {},
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ url: 'https://YOUR-N8N-INSTANCE/webhook/wasync-inbound' }) }}"
      },
      "name": "Register WASync Webhook (one-time)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        -320
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "WASync API key"
        }
      },
      "disabled": true
    }
  ],
  "connections": {
    "WhatsApp Inbound Webhook": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Wants Human?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wants Human?": {
      "main": [
        [
          {
            "node": "Send Human Handover Notice",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send AI Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
