{
  "name": "WaAPI nice Support Assistant",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "c69421b4-5c5b-442c-bdaf-49c1afe61ac0",
        "options": {
          "responseData": ""
        }
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -140,
        -100
      ],
      "id": "4650f722-00e2-4b22-8253-47b4840821c6",
      "name": "Webhook",
      "webhookId": "c69421b4-5c5b-442c-bdaf-49c1afe61ac0"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.body.data.message._data.id.remote }}",
        "contextWindowLength": 100
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        1040,
        460
      ],
      "id": "d7fb7812-1a5b-4e3a-b6f9-bee9f3cd7b48",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        880,
        460
      ],
      "id": "fe74df5c-3197-4d30-8662-2e559bebe788",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "iALhUgGDdJ9bnbQx",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "amount": 3
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        360,
        -260
      ],
      "id": "7acefbb6-69a8-423e-a615-c8669f3fdbb7",
      "name": "Wait 3s",
      "webhookId": "322157cc-002b-4cc6-ac0f-20bbbae52cdd"
    },
    {
      "parameters": {
        "resource": "Chat",
        "operation": "Send Seen",
        "id": "={{ $json.body.instanceId }}",
        "chatId": "={{ $json.body.data.message._data.id.remote }}",
        "requestOptions": {}
      },
      "type": "@waapiapp/n8n-nodes-waapi.waapi",
      "typeVersion": 1,
      "position": [
        660,
        -260
      ],
      "id": "101d8719-4bf3-4d77-8f66-efbcdbf4b9b6",
      "name": "Send seen",
      "credentials": {
        "waapiApi": {
          "id": "Y6MUdRoCPaFg5NFK",
          "name": "WaAPI account"
        }
      }
    },
    {
      "parameters": {
        "amount": 1
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        940,
        -260
      ],
      "id": "0fa6425e-4ddc-4b67-8aa2-ab2b1043a884",
      "name": "Wait 1s",
      "webhookId": "425cbac5-0671-4a87-9a4a-21a6e40b08f2"
    },
    {
      "parameters": {
        "resource": "Chat",
        "operation": "Send Typing",
        "id": "={{ $('Webhook').item.json.body.instanceId }}",
        "chatId": "={{ $('Webhook').item.json.body.data.message._data.id.remote }}",
        "requestOptions": {}
      },
      "type": "@waapiapp/n8n-nodes-waapi.waapi",
      "typeVersion": 1,
      "position": [
        1160,
        -260
      ],
      "id": "3bb0a9ce-4548-4804-b0e5-1b2b7a36bba1",
      "name": "Send typing",
      "credentials": {
        "waapiApi": {
          "id": "Y6MUdRoCPaFg5NFK",
          "name": "WaAPI account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        360,
        0
      ],
      "id": "c7d18c20-66c7-4c5b-b21a-a8cbe31990b1",
      "name": "wait 5s",
      "webhookId": "fc06678a-fa7a-4688-a7c0-460d1dd88651"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "337a1e8f-5f12-4a19-a72d-29c7e08d153b",
              "leftValue": "={{ $json.body.data.message._data.body }}",
              "rightValue": "ping",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        600,
        0
      ],
      "id": "a5635950-3aca-4de5-97fd-8ee385ddbed4",
      "name": "check if ping message"
    },
    {
      "parameters": {
        "resource": "Message",
        "operation": "Send Text Message To Chat",
        "id": "={{ $('Webhook').item.json.body.instanceId }}",
        "chatId": "={{ $('Webhook').item.json.body.data.message._data.id.remote }}",
        "message": "=pong",
        "mentions": "[]",
        "replyToMessageId": "",
        "previewLink": false,
        "requestOptions": {}
      },
      "type": "@waapiapp/n8n-nodes-waapi.waapi",
      "typeVersion": 1,
      "position": [
        880,
        -20
      ],
      "id": "14266628-77a1-4e19-8ec8-9b7cc7196380",
      "name": "send pong message",
      "credentials": {
        "waapiApi": {
          "id": "Y6MUdRoCPaFg5NFK",
          "name": "WaAPI account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.data.message._data.body }}",
        "options": {
          "systemMessage": "=You are a helpful assistant which answers to messages in the language the messages were sent in. Answer very short and be nice. "
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        880,
        240
      ],
      "id": "70fe21e7-1266-4f27-b0c2-e54d33863a23",
      "name": "Helpful assistant",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "resource": "Chat",
        "operation": "Send Stop Typing",
        "id": "={{ $('Webhook').item.json.body.instanceId }}",
        "chatId": "={{ $('Webhook').item.json.body.data.message._data.id.remote }}",
        "requestOptions": {}
      },
      "type": "@waapiapp/n8n-nodes-waapi.waapi",
      "typeVersion": 1,
      "position": [
        1260,
        240
      ],
      "id": "8194460a-1237-45f5-9597-3fc548b115d7",
      "name": "stop typing",
      "credentials": {
        "waapiApi": {
          "id": "Y6MUdRoCPaFg5NFK",
          "name": "WaAPI account"
        }
      }
    },
    {
      "parameters": {
        "amount": 0.5
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1440,
        240
      ],
      "id": "3285aae2-9bce-4185-8974-60623e61849b",
      "name": "wait 0.5s",
      "webhookId": "5111043f-ee7c-42f3-b59e-28620d57072f"
    },
    {
      "parameters": {
        "resource": "Message",
        "operation": "Send Text Message To Chat",
        "id": "={{ $('Webhook').item.json.body.instanceId }}",
        "chatId": "={{ $('Webhook').item.json.body.data.message._data.id.remote }}",
        "message": "={{ $('Helpful assistant').item.json.output }}",
        "mentions": "[]",
        "replyToMessageId": "",
        "previewLink": false,
        "requestOptions": {}
      },
      "type": "@waapiapp/n8n-nodes-waapi.waapi",
      "typeVersion": 1,
      "position": [
        1620,
        240
      ],
      "id": "84a26f7c-380c-47b6-809f-064d61ab991b",
      "name": "answer message",
      "credentials": {
        "waapiApi": {
          "id": "Y6MUdRoCPaFg5NFK",
          "name": "WaAPI account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "a2e20556-cf08-4648-9f1b-0c5df31e40b8",
              "leftValue": "={{ $json.body.event }}",
              "rightValue": "message",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        60,
        -100
      ],
      "id": "05faf441-9339-458b-94c8-b81e93903e1d",
      "name": "check if event is message"
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "check if event is message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Helpful assistant",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Helpful assistant",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Wait 3s": {
      "main": [
        [
          {
            "node": "Send seen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send seen": {
      "main": [
        [
          {
            "node": "Wait 1s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 1s": {
      "main": [
        [
          {
            "node": "Send typing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send typing": {
      "main": [
        []
      ]
    },
    "wait 5s": {
      "main": [
        [
          {
            "node": "check if ping message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check if ping message": {
      "main": [
        [
          {
            "node": "send pong message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Helpful assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Helpful assistant": {
      "main": [
        [
          {
            "node": "stop typing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "stop typing": {
      "main": [
        [
          {
            "node": "wait 0.5s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "wait 0.5s": {
      "main": [
        [
          {
            "node": "answer message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check if event is message": {
      "main": [
        [
          {
            "node": "Wait 3s",
            "type": "main",
            "index": 0
          },
          {
            "node": "wait 5s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "86b697c4-b468-4a44-b131-22d64483972a",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "3ed95a192f9acd247cf882ad5252b3e0fdfb9a2eb1ed8b669cf47ba25a0fbef0"
  },
  "id": "WzfbxsLa5n3WqZl2",
  "tags": []
}