Documentation

N8N Integration with WhatsApp in EasySocial

Last updated on November 14, 2025

EasySocial → n8n WhatsApp Integration 

Purpose: Connect EasySocial's WhatsApp chatbot builder to n8n so incoming WhatsApp messages are sent to n8n for AI processing and a structured response is returned to EasySocial (and delivered to the user on WhatsApp).

Prerequisites

  • An EasySocial account with chatbot builder access and ability to add an n8n node.
  • An n8n instance reachable from the internet (cloud-hosted n8n or an exposed tunnel such as ngrok).
  • Access to n8n editor to create nodes: Webhook, AI Agent, Simple Memory, Structured Output Parser, Respond to Webhook.
  • Basic understanding of JSON and webhook testing (cURL or Postman).

Overview of the workflow

The n8n workflow will follow this order:

EasySocial (chatbot) → n8n Webhook → AI Agent → Simple Memory → Structured Output Parser → Respond to Webhook → EasySocial → WhatsApp

Expected response format from n8n to EasySocial

n8n must return valid JSON that exactly follows this schema. Lead attribute names must match EasySocial Lead Data Field names exactly.

{
  "type": "object",
  "properties": {
    "message": { "type": "string" },
    "lead_attributes": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "phone": { "type": "string" },
        "email": { "type": "string" },
        "city": { "type": "string" },
        "dob": { "type": "date" },
        "website": { "type": "string" },
        "property": { "type": "string" }
      }
    },
    "last_response": { "type": "boolean" }
  }
}
Important: Even when a field is not provided, include it in lead_attributes as an empty string (or null if your setup supports it). The names must match exactly with EasySocial lead fields.
 
n8n setup.jpg

Step 1 — Create the webhook node in n8n

webhook.jpg
  1. Open n8n editor and click Create node → n8n Webhook.
  2. Set HTTP Method to POST (recommended).
  3. Copy the generated Webhook URL. It will look like https://your-n8n-host/webhook/webhook-name.
  4. Set Respond option to When Last Node Finishes.
  5. Set Response Data to First Entry JSON.

Step 2 — Paste the n8n Webhook URL into EasySocial

 

Screenshot 2025-11-14 at 9.36.47 AM.png
  1. Open EasySocial chatbot builder.
  2. Add or edit the n8n node in your chatbot flow.
  3. Paste the n8n Webhook URL in the node configuration.
  4. Save the chatbot flow and publish if required.

EasySocial will forward incoming WhatsApp messages to n8n with a payload similar to:

{
      "query": {
        "message": "User's text here",
        "leadId": "unique-lead-id"
      }
    }

Use {{ $json.query.message }} and {{ $json.query.leadId }} inside n8n nodes.

Step 3 — Add & configure AI Agent node in n8n

AI_agent.jpg
  1. Create a node: AI Agent.
  2. Set Source for Prompt (User Message) to Define below.
  3. Paste the prompt below into the prompt box. Turn ON Require Specific Output Format.

AI Agent prompt (sample)

You are an AI assistant helping collect lead information on WhatsApp.
Your goals:
1. Understand the user's message.
2. Ask only one question at a time.
3. Collect the following details step-by-step:
   * name
   * phone
   * email
   * city
   * dob
   * website
   * property
Lead attributes are optional. Only include attributes that the user has provided.
When all required information is collected then set:
"last_response": true.
If incomplete, set:
"last_response": false.
Your JSON response MUST follow exactly this format:
{
"message": "Your reply message to the user here",
"lead_attributes": {
"name": "",
"phone": "",
"email": "",
"city": "",
"dob": "",
"website": "",
"property": ""
},
"last_response": false
}
Always include ALL keys inside lead_attributes, even if empty.
Never send text outside of JSON.
User message: {{ $json.query.message }} 
Do not let the AI send raw text — the Structured Output Parser will validate a JSON payload. If the AI returns invalid JSON, Structured Output Parser will catch it.

Step 4 — Add Simple Memory node

simple_memory.jpg
  1. Add the Simple Memory node and connect it to the AI Agent node as input (so the agent can read/write memory).
  2. Set Session ID to Define below and set Key to: 
    {{ $json.query.leadId }}
  3. Set Context Window Length to 5 (recommended).

This preserves the last few interactions for the same leadId so the AI can use conversation context on follow-up messages.

Step 5 — Add Structured Output Parser

structured_output_parser.jpg
  1. Add Structured Output Parser node and connect it to the AI Agent (or to the chain where the AI output arrives).
  2. Set Schema Type to Define using JSON Schema.
  3. Paste this Input Schema exactly:
{
  "type": "object",
  "properties": {
    "message": { "type": "string" },
    "lead_attributes": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "phone": { "type": "string" },
        "email": { "type": "string" },
        "city": { "type": "string" },
        "dob": { "type": "string" },
        "website": { "type": "string" },
        "property": { "type": "string" }
      }
    },
    "last_response": { "type": "boolean" }
  }
}

Leave Auto-Fix Format OFF if you want strict validation. If you enable auto-fix, the parser will attempt to coerce/clean minor errors.

Step 6 — Add Respond to Webhook node

responsed_to_webhook.jpg
  1. Add the Respond to Webhook node and connect it as the last node in the flow.
  2. Set Respond With to All Incoming Items.
  3. No additional properties are required; this node will send the parser-validated JSON back to EasySocial.

When n8n finishes, EasySocial will receive the JSON response and act as follows:

  • Send the text in message back to WhatsApp user.
  • Map fields in lead_attributes to EasySocial Lead Data Fields (exact name match required).
  • When last_response is true, EasySocial treats the flow as completed and proceeds to the next step in the chatbot (if any).

Sample full n8n payload exchange

Incoming from EasySocial to n8n (example):

{
  "query": {
    "message": "Hi, I want details about the property listed on your site.",
    "leadId": "lead-abc-001"
  }
}

n8n processed response (example):

{
  "message": "Thanks for your interest. May I know your name?",
  "lead_attributes": {
    "name": "",
    "phone": "",
    "email": "",
    "city": "",
    "dob": "",
    "website": "",
    "property": "Plot #23, Sector 9"
  },
  "last_response": false
}

Testing the flow locally

  1. Start n8n editor and make sure the webhook node is active.
  2. Use cURL or Postman to POST a test message to the webhook (see earlier cURL example).
  3. Verify n8n nodes execute without errors and the Respond to Webhook node returns the JSON above.
  4. Check EasySocial if the message appears in the conversation and lead fields were updated.

Troubleshooting & common issues

ProblemCheck / Fix
Webhook not reachableEnsure n8n is public or use a tunnel (ngrok). Verify the webhook URL in EasySocial exactly matches n8n webhook URL.
AI returns non-JSON or malformed JSONEnable Structured Output Parser & Auto-Fix (optional). Improve the AI prompt to enforce strict JSON. Require Specific Output Format in AI Agent.
Lead data not saved in EasySocialConfirm field names in lead_attributes exactly match EasySocial Lead Data Field names (case-sensitive). Send empty strings for missing fields.
Memory not working across messagesConfirm session key uses {{ $json.query.leadId }}. Ensure EasySocial sends the same leadId in every message for the same user.
Flow times outUse asynchronous operations in n8n where possible. Keep AI prompts concise. Ensure EasySocial webhook timeout is sufficient for the AI response time.

Best practices

  • Always validate AI output with the Structured Output Parser before responding to EasySocial.
  • Keep the AI prompt deterministic (explicit JSON format required).
  • Use memory session IDs derived from EasySocial leadId so conversation state is preserved properly.
  • Log raw payloads in n8n (temporarily) while testing to inspect incoming messages and mapping.
  • Implement retry logic in n8n if external calls fail (for example, to AI service or DB writes).

Conclusion

By connecting EasySocial with n8n, you can build powerful AI-driven WhatsApp automations with full flexibility over data collection, lead qualification, workflows, and custom logic. Once the integration is configured, every WhatsApp conversation can flow through n8n for advanced processing and return structured responses directly back into EasySocial.

Need Assistance?

If you need help setting up your workflow, troubleshooting an issue, or customizing your n8n integration, please contact EasySocial Support. Our team will be happy to assist you.