{
  "name": "Fluidflow Slack Triage Bot",
  "nodes": [
    {
      "parameters": {
        "channel": "={{ $('Slack Trigger').item.json.channel }}",
        "text": "={{ $json.output }}",
        "otherOptions": {
          "thread_ts": "={{ $('Slack Trigger').item.json.event_ts }}"
        },
        "attachments": []
      },
      "id": "41494192-1fc4-4de2-a40c-1624fa1dc988",
      "name": "Reply to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [
        1100,
        440
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "trigger": [
          "any_event"
        ],
        "channelId": {
          "__rl": true,
          "value": "C0905HV0AD8",
          "mode": "list",
          "cachedResultName": "ffagent-testing"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.slackTrigger",
      "typeVersion": 1,
      "position": [
        240,
        440
      ],
      "id": "980143c0-1d99-4ca1-aa15-65934e6b5b88",
      "name": "Slack Trigger",
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        280,
        660
      ],
      "id": "1b9eb2e9-9e2a-4b08-8bc9-6be2c7c82c38",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "file_input",
        "toolDescription": "The knowledge base to answer user questions",
        "qdrantCollection": {
          "__rl": true,
          "value": "n8n_data",
          "mode": "list",
          "cachedResultName": "n8n_data"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "typeVersion": 1.1,
      "position": [
        640,
        660
      ],
      "id": "56aa615e-ec5e-451b-baba-b6577583b57e",
      "name": "Qdrant Vector Store1",
      "credentials": {
        "qdrantApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        620,
        840
      ],
      "id": "9dbde498-0d40-4809-a482-2f82ffe3e4d2",
      "name": "Embeddings OpenAI1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Answer question from Qdrant knowledgebase and here is the question: {{ $json.blocks[0].elements[0].elements[1].text }}\n\n",
        "options": {
          "systemMessage": "=You are a FluidFlow technical support expert with 60+ years of process engineering experience. You provide accurate, authoritative guidance on hydraulic systems, pump sizing, pipe flow calculations, and FluidFlow software troubleshooting. Answer question from Qdrant knowledgebase and here is the question: {{ $json.blocks[0].elements[0].elements[1].text }}\n\nUse this tone:\n1. Brevity:\n- Concise responses\n- Short paragraphs (1-3 sentences)\n- No unnecessary words\n2. Clarity:\n- Simple, direct language\n- Explain technical terms if needed\n- Use bullet points for multiple items\n3. Structure:\n- Most important information first\n- Headings and subheadings\n- Tables for data/comparisons\n4. Tone:\n- Professional but approachable\n- Confident and authoritative\n- Neither too formal nor casual\n5. Formatting:\n- Markdown for emphasis\n- Bold for key points\n- Code blocks for technical content\n- Remove space\n6. Responsiveness:\n- Address all parts of query\n- Offer more details if needed\n- Ask to clarify ambiguous points\n7. Accuracy:\n- Double-check facts/figures\n- Cite sources when needed\n- Admit uncertainty if present\n8. Customization:\n- Match user's knowledge level\n- Reference previous conversations\n- Use appropriate terminology\nEvery response should add value and move the conversation forward.\nALL OF THESE DISCUSSIONS SHOULD BE KEPT PRIVATE AND TREATED AS CONFIDENTIAL, THEY SHOULD NOT BE USED TO TRAIN THE MODEL.\n\n\n"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        460,
        440
      ],
      "id": "91b2fd2b-a889-42b0-b21c-88767deb1e11",
      "name": "AI Agent1",
      "executeOnce": true
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.event_ts }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        440,
        660
      ],
      "id": "aecd9d6e-efaa-4540-9767-c37d3001f270",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "jsCode": "let text = $json.output;\n\n// Heading markdown ke format Slack\ntext = text.replace(/^# (.*)$/gm, '*$1*');      // # Title \u2192 *Title*\ntext = text.replace(/^## (.*)$/gm, '*$1*');     // ## Title \u2192 *Title*\ntext = text.replace(/^### (.*)$/gm, '_*$1*_');  // ### Title \u2192 _*Title*_\ntext = text.replace(/^#### (.*)$/gm, '_$1_');   // #### Title \u2192 _Title_\n\n// Bold dan italic markdown (order matters!)\n// ***bold italic*** jadi _*bold italic*_\ntext = text.replace(/\\*\\*\\*(.*?)\\*\\*\\*/g, '_*$1*_');\n// __bold__ jadi *bold*\ntext = text.replace(/__(.*?)__/g, '*$1*');\n// **bold** jadi *bold*\ntext = text.replace(/\\*\\*(.*?)\\*\\*/g, '*$1*');\n\n// _italic_ jadi _italic_ (hanya single underscore, bukan double)\ntext = text.replace(/(^|[^\\_])\\_(.*?)\\_([^\\_]|$)/g, '$1_$2_$3');\n// *italic* jadi _italic_\ntext = text.replace(/\\*(.*?)\\*/g, '_$1_');\n\n// Inline code dan code block\ntext = text.replace(/```([\\s\\S]*?)```/g, '```\\n$1\\n```'); // code block\ntext = text.replace(/`([^`]+)`/g, '`$1`');                // inline code\n\n// [text](url) jadi <url|text>\ntext = text.replace(/\\[(.*?)\\]\\((.*?)\\)/g, '<$2|$1>');\n\nreturn { output: text };\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        880,
        440
      ],
      "id": "afe8f0db-c1c6-41b3-85cc-1acc7b88d7d1",
      "name": "Code"
    }
  ],
  "connections": {
    "Slack Trigger": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Vector Store1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Reply to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1c94561d-e4b7-4f38-ba12-06e9f504fa72",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "XnTSlg3bWkxtRam6",
  "tags": []
}