{
  "name": "An AI assistant that answers your WhatsApp 24/7 and hands over to a person when asked",
  "nodes": [
    {
      "parameters": {
        "content": "## An AI assistant that answers your WhatsApp 24/7 and hands over to a person when asked\n\nWhat 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. Install the community node: n8n Settings -> Community Nodes -> npm package `n8n-nodes-wasync`.\n2. Create a free WASync account at https://developers.wasync.app/register, connect a WhatsApp number, then create an API key at https://developers.wasync.app/keys.\n3. In n8n, add a new \"WASync API\" credential using that key.\n4. Open the \"Settings\" node at the top of this workflow and fill in your own values. Never commit real portal URLs, tokens, or phone numbers.\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\nDocs: https://docs.wasync.app/docs/guides/n8n?utm_source=n8n&utm_medium=template&utm_campaign=t4",
        "height": 620,
        "width": 1240
      },
      "name": "Read Me First",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        -700
      ]
    },
    {
      "parameters": {
        "content": "**① Trigger**\nFires on every inbound WhatsApp message.",
        "height": 720,
        "width": 280,
        "color": 7
      },
      "name": "① Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        404
      ]
    },
    {
      "parameters": {
        "content": "**② Route the message**\nMessages asking for a person never reach the AI.",
        "height": 720,
        "width": 280,
        "color": 7
      },
      "name": "② Route the message",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        180,
        404
      ]
    },
    {
      "parameters": {
        "content": "**③ Answer on WhatsApp**\nEither a short handover notice, or the AI agent's reply.\nThe chat model hangs under the agent, as n8n draws it.",
        "height": 720,
        "width": 600,
        "color": 7
      },
      "name": "③ Answer on WhatsApp",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        500,
        404
      ]
    },
    {
      "parameters": {
        "content": "**Settings — fill these in**\nPlaceholders only — replace every value here before you activate the\nworkflow. Nothing else in the workflow needs editing.\nFields: companyName, openingHours, escalationInstructions.",
        "height": 344,
        "width": 600,
        "color": 7
      },
      "name": "Settings — fill these in",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -140,
        0
      ]
    },
    {
      "parameters": {
        "events": [
          "message.received"
        ]
      },
      "name": "Receive WhatsApp Message",
      "type": "n8n-nodes-wasync.wasyncTrigger",
      "typeVersion": 1,
      "position": [
        0,
        584
      ],
      "credentials": {
        "wasyncApi": {
          "name": "WASync account"
        }
      }
    },
    {
      "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,
        224
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "Wants Human?-cond0",
              "leftValue": "={{ $('Receive WhatsApp Message').item.json.message.text.toLowerCase() }}",
              "rightValue": "human",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            },
            {
              "id": "Wants Human?-cond1",
              "leftValue": "={{ $('Receive WhatsApp Message').item.json.message.text.toLowerCase() }}",
              "rightValue": "agent",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "name": "Asks for a Human?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        320,
        584
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "connectionId": "={{ $('Receive WhatsApp Message').item.json.connection_id }}",
        "to": "={{ $('Receive WhatsApp Message').item.json.message.from }}",
        "text": "=A colleague will reply shortly.",
        "additionalFields": {}
      },
      "name": "Send Handover Notice on WhatsApp",
      "type": "n8n-nodes-wasync.wasync",
      "typeVersion": 1,
      "position": [
        640,
        584
      ],
      "credentials": {
        "wasyncApi": {
          "name": "WASync account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $('Receive WhatsApp Message').item.json.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": [
        640,
        784
      ]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {}
      },
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        640,
        1004
      ],
      "credentials": {
        "openAiApi": {
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "connectionId": "={{ $('Receive WhatsApp Message').item.json.connection_id }}",
        "to": "={{ $('Receive WhatsApp Message').item.json.message.from }}",
        "text": "={{ $json.output }}",
        "additionalFields": {}
      },
      "name": "Send AI Reply on WhatsApp",
      "type": "n8n-nodes-wasync.wasync",
      "typeVersion": 1,
      "position": [
        960,
        784
      ],
      "credentials": {
        "wasyncApi": {
          "name": "WASync account"
        }
      }
    }
  ],
  "connections": {
    "Receive WhatsApp Message": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Asks for a Human?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Asks for a Human?": {
      "main": [
        [
          {
            "node": "Send Handover Notice on WhatsApp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send AI Reply on WhatsApp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
