{
  "name": "RAG Whatsapp",
  "nodes": [
    {
      "parameters": {},
      "type": "@devlikeapro/n8n-nodes-waha.wahaTrigger",
      "typeVersion": 202502,
      "position": [
        420,
        20
      ],
      "id": "60abde40-fd24-4229-865d-05a21068c61e",
      "name": "WAHA Trigger",
      "notesInFlow": false
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Stop Typing",
        "session": "={{ $node[\"WAHA Trigger\"].json.session }}",
        "chatId": "={{ $node[\"WAHA Trigger\"].json.payload.from }}",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        1600,
        60
      ],
      "id": "82812115-35c3-4c1e-8ddf-dd7a5fe28121",
      "name": "Stop Typing",
      "alwaysOutputData": true,
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Send Text",
        "session": "={{ $node[\"WAHA Trigger\"].json.session }}",
        "chatId": "={{ $node[\"WAHA Trigger\"].json.payload.from }}",
        "text": "={{ $node[\"AI Agent\"].json.output }}",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        1800,
        60
      ],
      "id": "d4b84aa8-1b75-4a03-afe2-0267c28246a3",
      "name": "Send a text message",
      "alwaysOutputData": true,
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $node[\"WAHA Trigger\"].json.payload.body }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "> You are an intelligent and friendly **customer support chatbot** for **IGM Corps**, an innovative IT company specializing in **Digitalization with AI**.\n>\n> IGM Corps provides cutting-edge digital solutions and AI-powered technologies to help businesses optimize operations, enhance decision-making, and streamline workflows.\n>\n> Your responsibilities:\n>\n> * You are given relevant company knowledge in the [Answer Tool].\n> * Use this knowledge to answer as accurately as possible.\n> * You must not answer question not from [Answer Tool] tool.\n> * If you do not find an answer in the [Answer Tool] tool, respond politely that you will forward the message to human support.\n> * Respond to client inquiries with a professional, warm, and solution-oriented tone.\n>\n> Style and tone:\n>\n> * Professional, yet approachable\n> * Clear, concise, and helpful\n> * Focused on delivering accurate and relevant assistance from [Answer Tool] tool\n>\n> Additional instructions:\n>\n> * Ask clarifying or follow-up questions if needed to better understand the user's goals or challenges.\n> * If a question is **not relevant** to IGM Corps or outside your knowledge, do **not make up an answer**. Instead, respond that the query will be forwarded to support.\n> * Always answer from the [Answer Tool] tool."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        1260,
        60
      ],
      "id": "8bacf0fe-1890-4745-ac92-d3a1f23266e1",
      "name": "AI Agent",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1180,
        260
      ],
      "id": "b2462979-c785-4e01-b95f-34d594578037",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        1360,
        660
      ],
      "id": "d3c281e6-2b48-42dd-9d07-7f006553bc81",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Start Typing",
        "session": "={{ $node[\"WAHA Trigger\"].json.session }}",
        "chatId": "={{ $node[\"WAHA Trigger\"].json.payload.from }}",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        920,
        60
      ],
      "id": "2c8f17ca-b5b2-4f76-bbc4-8aeaaccc8224",
      "name": "Start Typing",
      "alwaysOutputData": true,
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.sessionId || \"Anonymous\" }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        1320,
        300
      ],
      "id": "63f8586d-1352-473e-9bb5-c85579c44657",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "Chatting",
        "operation": "Send Seen",
        "session": "={{ $node[\"WAHA Trigger\"].json.session }}",
        "chatId": "={{ $node[\"WAHA Trigger\"].json.payload.from }}",
        "messageId": "=",
        "participant": "null",
        "requestOptions": {}
      },
      "type": "@devlikeapro/n8n-nodes-waha.WAHA",
      "typeVersion": 202502,
      "position": [
        740,
        60
      ],
      "id": "194336a2-8f94-48d0-8f94-0428c86ef1d0",
      "name": "Send Seen",
      "alwaysOutputData": true,
      "credentials": {
        "wahaApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "for (const item of $(\"WAHA Trigger\").all()) {\n  item.json.sessionId = item.json.payload.from\n}\n\nreturn $(\"WAHA Trigger\").all();"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1080,
        60
      ],
      "id": "ed25ce6e-e159-4f79-870c-508d9c86c628",
      "name": "Code"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1640,
        500
      ],
      "id": "25e1a4bb-3ca8-485a-9b1f-486c6aaf49ff",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "qdrantCollection": {
          "__rl": true,
          "value": "qna",
          "mode": "list",
          "cachedResultName": "qna"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "typeVersion": 1.3,
      "position": [
        1360,
        500
      ],
      "id": "d11be56a-19f5-47db-93a5-e14ef4d3e55f",
      "name": "Qdrant Vector Store",
      "credentials": {
        "qdrantApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "description": "Use THIS TOOL to answer the user's question as accurately and clearly as possible.\nThe knowledge base contains curated information about IGM Corps, including services, company profile, solutions, and common client inquiries.\nAlways prioritize using this information when responding.\nIf the answer cannot be found in the provided knowledge base, politely inform the user that their query will be forwarded to a human support representative."
      },
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "typeVersion": 1.1,
      "position": [
        1440,
        320
      ],
      "id": "d8f1c06a-e8dc-4d67-85a8-331f6f67eff5",
      "name": "Answer Tool"
    }
  ],
  "connections": {
    "WAHA Trigger": {
      "main": [
        [],
        [
          {
            "node": "Send Seen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop Typing": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Stop Typing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Start Typing": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Send Seen": {
      "main": [
        [
          {
            "node": "Start Typing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Answer Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Vector Store": {
      "ai_vectorStore": [
        [
          {
            "node": "Answer Tool",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Answer Tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Asia/Jakarta",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "versionId": "6d21899a-c461-41da-8324-9b9d8dd76290",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "zSBPkdnmWC4AZODY",
  "tags": []
}