{
  "id": "5yOJSx1X0M3Q2VFM",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "n8n__demo__WAMM_Assistent_Pinecode",
  "tags": [],
  "nodes": [
    {
      "id": "1e7bc1dc-d577-4a46-8cfb-ab3f7b918922",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        320,
        0
      ],
      "parameters": {
        "text": "={{ $json.body.data.message_text }}",
        "options": {
          "systemMessage": "=You are Alex, a warm and friendly assistant. Talk naturally like a good friend would - never mention searching or looking up information. Just remember and respond naturally.\n\nAlways respond in the user's language (note: \u201csalut\u201d is in Romanian.). Be conversational, not robotic.\n\nTalking to: {{ $json.body.data.source_number }}\nTime: {{ $now.toISO() }}"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "13fa7ec6-fdca-43ed-b5e7-5aae02b61fa6",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        100,
        -240
      ],
      "parameters": {
        "path": "1c9432a6-f982-4102-ad0e-39ec15876b0a",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "ed764250-105f-4a87-beb7-070c42473340",
      "name": "WAMM: Send Message",
      "type": "n8n-nodes-wamm.wammpro",
      "position": [
        880,
        -240
      ],
      "parameters": {
        "phone": "={{ $('Webhook').item.json.body.data.source_number }}",
        "message": "={{ $json.output }}",
        "instanceId": "68xxxxxxxxx3F"
      },
      "credentials": {
        "wammApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cb99b578-c02e-4469-b6b5-3ac95b9004f1",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        100,
        360
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "01bddfd1-4a4e-42b9-9d3c-fa2d1670bf94",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        960,
        640
      ],
      "parameters": {
        "model": "text-embedding-3-large",
        "options": {
          "dimensions": 3072
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "90ee2d53-da04-4105-b66d-7234ac13baac",
      "name": "Processing data for Pinecone",
      "type": "n8n-nodes-base.code",
      "position": [
        1320,
        0
      ],
      "parameters": {
        "jsCode": "// Preg\u0103te\u0219te datele pentru salvare \u00een memorie\nconst aiAgentOutput = $('AI Agent').first().json.output;\nconst webhookData = $('Webhook').first().json.body.data;\n\n// Creeaz\u0103 textul conversa\u021biei\nconst conversationText = `Utilizator (${webhookData.source_number}): ${webhookData.message_text}\nAsistent: ${aiAgentOutput}\nTimestamp: ${new Date().toISOString()}`;\n\n// Returneaz\u0103 documentul \u00een formatul cerut de Pinecone\nreturn {\n  json: {\n    pageContent: conversationText,\n    metadata: {\n      user_number: webhookData.source_number,\n      timestamp: new Date().toISOString()\n    }\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "94d3df7d-4680-46b7-9886-1439958a26c4",
      "name": "Reading from Pinecone (from knowledge)",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        260,
        360
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "toolName": "reading_knowledge",
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "knowledge",
          "cachedResultName": "knowledge"
        },
        "toolDescription": "Use this tool to search the general knowledge base and standard answers to frequently asked questions."
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f89342bf-eebc-40e5-8442-a228bc250a7d",
      "name": "Reading from Pinecone (at phone number)",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        580,
        360
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "toolName": "reading_historywa",
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "historywa",
          "cachedResultName": "historywa"
        },
        "toolDescription": "Use this tool to search past conversation history with this user ( {{ $('Webhook').item.json.body.data.source_number }} ) and find relevant information to answer the user\u2019s current question."
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b474ec47-e34b-4065-a83b-a9a55452346c",
      "name": "Pinecone Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1600,
        0
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "pineconeIndex": {
          "__rl": true,
          "mode": "list",
          "value": "historywa",
          "cachedResultName": "historywa"
        }
      },
      "credentials": {
        "pineconeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b0e4114e-9775-4cce-a151-4a558dc97733",
      "name": "Default Data Loader1",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1480,
        340
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "user_number",
                "value": "={{ $json.metadata.user_number }}"
              },
              {
                "name": "timestamp",
                "value": "={{ $json.metadata.timestamp }}"
              }
            ]
          }
        },
        "jsonData": "={{ $json.pageContent }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1
    },
    {
      "id": "affac18f-f2e6-42b2-8b75-f90a305935ce",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1560,
        600
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "cd0c6f62-2e7c-405c-84fe-204ddf4ba51e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -760,
        -760
      ],
      "parameters": {
        "width": 760,
        "height": 1640,
        "content": "# \ud83e\udd16 WAMM AI Assistant with Pinecone Memory - n8n Template\n\n## \ud83d\udccb Description\n\nThis template creates an intelligent AI assistant for WhatsApp that can:\n- **Respond naturally** to messages using Google Gemini AI\n- **Remember previous conversations** for each user\n- **Access a knowledge base** for answering frequently asked questions\n- **Automatically save** all conversations for long-term memory\n\n## \ud83d\udee0\ufe0f Requirements\n\n### 1. **WAMM.pro Account** (FREE tier available)\n- **What is WAMM.pro?** - A platform that enables WhatsApp automation using proprietary API technology\n- **Free tier:** 50 messages/month\n- **PRO tier:** Unlimited messages + advanced features\n- **Link:** [wamm.pro](https://wamm.pro)\n\n### 2. **Pinecone Account** (for AI memory)\n- For storing conversations and knowledge base\n- Free tier available\n\n### 3. **Google AI Account** (for Gemini)\n- For the conversational AI model\n\n### 4. **OpenAI Account** (for embeddings)\n- For generating memory vectors\n\n## \ud83d\ude80 Step-by-step Setup\n\n### **Step 1: WAMM.pro Configuration**\n### **Step 2: Webhook Configuration**\n### **Step 3: Pinecone Configuration**\n\n### **Step 4: n8n Configuration**\n\n1. **Configure credentials:**\n   - **WAMM:** Instance ID + Access Token\n   - **Pinecone:** API Key\n   - **Google Gemini:** API Key  \n   - **OpenAI:** API Key for embeddings\n\n### **Available AI Tools:**\n\n1. **Memory Tool** - Searches previous conversations with the user\n2. **Knowledge Tool** - Searches the general knowledge base\n\n### **Special Features:**\n\n- **Natural conversations** - AI doesn't mention \"searching history\"\n- **Persistent context** - Remembers names, preferences, previous conversations\n- **User language detection** - Automatically responds in user's language\n- **Organized memory** - Each user has their own memory space\n\n## \ud83d\udcca Benefits\n\n\u2705 **Zero maintenance** - Runs automatically  \n\u2705 **Scalable** - Supports multiple users simultaneously  \n\u2705 **Intelligent memory** - Uses similarity search for relevant context  \n\u2705 **Extensible** - Easy to add new features  \n\u2705 **Cost-effective** - Free tiers available for all services  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "6c179b6f-5a31-4a49-8a4a-933686892234",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -760
      ],
      "parameters": {
        "width": 540,
        "height": 720,
        "content": "# WAMM configuration\n\n### **Step 1: WAMM.pro Configuration**\n\n1. **Create account** at [wamm.pro](https://wamm.pro)\n2. **Account Manager** \u2192 **Add WhatsApp profile**\n3. **Scan QR code** with your WhatsApp\n4. **Note down:** `Instance ID` and `Access Token`\n\n### **Step 2: Webhook Configuration**\n\n1. **In WAMM.pro:** Integrations \u2192 Webhooks \u2192 Messages Webhooks\n2. **Add Webhook** with the n8n URL\n3. **Required configuration:**\n   - **From others:** \u2705 Relevant + \u2705 Without media + \u2705 Exclude no text\n   - **To others:** \u2705 Relevant + \u2705 Without media + \u2705 Exclude no text  \n   - **To myself:** \u2705 None (to avoid responding to own messages)"
      },
      "typeVersion": 1
    },
    {
      "id": "62a9577a-9cd6-49fa-ac36-f3a9b364569b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        320
      ],
      "parameters": {
        "width": 1560,
        "height": 560,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Pinecone configuration\n\n### **Step 3: Pinecone Configuration**\n\n1. **Create 2 indexes:**\n   - `historywa` - for conversation memory\n   - `knowledge` - for knowledge base\n2. **Index settings:**\n   - **Dimensions:** 3072\n   - **Metric:** cosine\n   - **Embedding model:** text-embedding-3-large"
      },
      "typeVersion": 1
    },
    {
      "id": "8ece35d4-654d-4167-aa95-020f8d23194d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        -760
      ],
      "parameters": {
        "width": 400,
        "height": 720,
        "content": "## \ud83c\udfaf Use Cases\n\n- **Automated customer support** with memory\n- **Personal assistant** for WhatsApp  \n- **Business chatbot** with specific knowledge\n- **Conversation automation** with persistent context\n\n## \ud83d\udd12 Security\n\n- **Data** stored in Pinecone as vector embeddings\n- **No plain text** message storage  \n- **Each user** has separate memory space\n- **API keys** secured in n8n credentials\n\n## \ud83d\udcc8 Possible Extensions\n\n- **CRM** integrations\n- **Scheduling** and reminders\n- **Advanced multi-language** support  \n- **Analytics** and conversation reports\n- **Custom knowledge bases** per user\n\n---\n\n**\ud83d\udca1 Tip:** For optimal results, populate the knowledge base with frequently asked questions specific to your business!"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "83064b5e-171e-4c8c-8fc5-378fc3eadd8b",
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "WAMM: Send Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Reading from Pinecone (from knowledge)",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Reading from Pinecone (at phone number)",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Pinecone Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "WAMM: Send Message": {
      "main": [
        [
          {
            "node": "Processing data for Pinecone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader1": {
      "ai_document": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Processing data for Pinecone": {
      "main": [
        [
          {
            "node": "Pinecone Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader1",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Reading from Pinecone (from knowledge)": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Reading from Pinecone (at phone number)": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}