{
  "name": "slack command simple",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "n8n",
        "options": {
          "responseCode": {
            "values": {
              "responseCode": 204
            }
          }
        }
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -192,
        -128
      ],
      "id": "850b1e3e-2c54-4a56-bc8b-effd0a532e65",
      "name": "Webhook"
    },
    {
      "parameters": {
        "content": "## Webhook",
        "height": 240,
        "width": 200,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -240,
        -208
      ],
      "id": "28d49038-0f5b-416e-afaf-edcf4ad85351",
      "name": "Sticky Note",
      "disabled": true
    },
    {
      "parameters": {
        "content": "# 1. Slack Command\n- https://api.slack.com/ \uc5d0\uc11c Slash Commands \ub97c \uc785\ub825\n- /n8n \uba85\ub839\uc5b4\ub97c \uc124\uc815\ud558\uae30.",
        "height": 144,
        "width": 580
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -240,
        -368
      ],
      "id": "33b5279c-3b8d-4a2c-91ed-03f25867d37c",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "trigger": [
          "app_mention"
        ],
        "watchWorkspace": true,
        "options": {}
      },
      "type": "n8n-nodes-base.slackTrigger",
      "typeVersion": 1,
      "position": [
        -240,
        448
      ],
      "id": "667d645f-9e26-4681-a036-b3ffa865397a",
      "name": "Slack Trigger",
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://slack.com/api/chat.postMessage",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "slackApi",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "channel",
              "value": "={{ $('Slack Trigger').first().json.channel }}"
            },
            {
              "name": "thread_ts",
              "value": "={{ $('Slack Trigger').first().json.ts }}"
            },
            {
              "name": "text",
              "value": "={{ $json.output }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        448
      ],
      "id": "f132c040-f347-464d-8db1-dae2a702f3e4",
      "name": "chat.postMessage",
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# 2. SlackBot\n\n- @n8n-agent-bot \ud0dc\uadf8\ud574\uc57c\ub9cc \uc0ac\uc6a9\uac00\ub2a5.\n- \ud604\uc7ac\ub294 RAG\uc5c6\uc774 \ubcf4\ud3b8\uc801\uc778 \ub2f5\ubcc0\ub9cc \uc8fc\ub294 \uae30\ub2a5.",
        "height": 140,
        "width": 420
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -256,
        272
      ],
      "id": "23f56bad-45c3-441c-b214-0aaeb97fccfd",
      "name": "Sticky Note5"
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "C435YGHAQ",
          "mode": "list",
          "cachedResultName": "general"
        },
        "text": "=prompt : {{ $('Webhook').item.json.body.text }}\noutput : {{ $json.output }}",
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        432,
        -128
      ],
      "id": "8772dc77-8543-4679-81de-81b61bd55544",
      "name": "Send a message",
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        128,
        96
      ],
      "id": "5213ba5f-776f-40c1-969b-7bd1055704be",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.text }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.1,
      "position": [
        32,
        -128
      ],
      "id": "8f1a1609-db97-48b0-a801-c2ce9e3b21ee",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "resource": "channel",
        "operation": "replies",
        "channelId": {
          "__rl": true,
          "value": "={{ $('Slack Trigger').item.json.channel }}",
          "mode": "id"
        },
        "ts": "={{ $('Slack Trigger').item.json.thread_ts ||  $('Slack Trigger').item.json.ts }}",
        "filters": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        208,
        448
      ],
      "id": "ac6a78da-2339-47fb-a37d-9f2abaa20165",
      "name": "Get a thread of messages posted to a channel",
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2750b75c-a097-4f58-b74b-b1a58ff65c75",
              "name": "bot_id",
              "value": "=A09938PN12R",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -16,
        448
      ],
      "id": "1274c75a-0314-456d-a42d-510c6a238fe2",
      "name": "BOT"
    },
    {
      "parameters": {
        "jsCode": "// \ubd07 ID \ucd94\ucd9c\nconst botId = $('BOT').first().json.bot_id;\n\n// \uba54\uc2dc\uc9c0 \ubcc0\ud658\nconst transformedMessages = $input.all().map(item => {\n  const msg = item.json;\n\n  return {\n    role: msg.user === botId ? \"assistant\" : \"user\",\n    content: msg.text?.replaceAll(`<@${botId}>`, '').trim() || ''\n  };\n}).filter(item => item.content); // \ube48 \uba54\uc2dc\uc9c0\ub294 \uc81c\uac70\n\nreturn {\n  messages: JSON.stringify(transformedMessages)\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        432,
        448
      ],
      "id": "4cf572a2-e913-4fa8-a9bf-b62cfce87257",
      "name": "Code"
    },
    {
      "parameters": {
        "operation": "search",
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Search_Text', ``, 'string') }}",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}",
        "simple": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Simplify', ``, 'boolean') }}",
        "options": {}
      },
      "type": "n8n-nodes-base.notionTool",
      "typeVersion": 2.2,
      "position": [
        720,
        672
      ],
      "id": "d5f8da52-1afa-40d9-8eba-370177e945d0",
      "name": "Notion",
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        544,
        656
      ],
      "id": "c39f6ea9-d1fb-4378-9b7b-d0f6848c0d6d",
      "name": "OpenAI Chat Model - 4.1 mini",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.messages }}",
        "options": {
          "systemMessage": "=\ub2f9\uc2e0\uc740 n8n \uc790\ub3d9\ud654 \uc804\ubb38 \ubd07\uc785\ub2c8\ub2e4. \n\uc0ac\uc6a9\uc790\uc758 \uc9c8\ubb38\uc5d0 \uce5c\uadfc\ud558\uace0 \ub3c4\uc6c0\uc774 \ub418\ub294 \ubc29\uc2dd\uc73c\ub85c \ub2f5\ubcc0\ud574\uc8fc\uc138\uc694.\n   \n   \uc0ac\uc6a9\uc790 \uc9c8\ubb38: {{ $json.event.text.replace(/<@.*?>/g, '').trim() }}\n   \uc0ac\uc6a9\uc790 \uc774\ub984: {{ $json.event.user }}\n   \ucc44\ub110: {{ $json.event.channel }}"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.1,
      "position": [
        688,
        448
      ],
      "id": "e757a20c-c182-40cd-9cc9-4b8ae5c58333",
      "name": "SlackBot AI Agent"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "14XvsktecN18XAOPV-kBf1cZVxlgnBkxUOVcnI1i2dR8",
          "mode": "list",
          "cachedResultName": "Yes24 BestSeller",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14XvsktecN18XAOPV-kBf1cZVxlgnBkxUOVcnI1i2dR8/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "bestSeller",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14XvsktecN18XAOPV-kBf1cZVxlgnBkxUOVcnI1i2dR8/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.6,
      "position": [
        880,
        672
      ],
      "id": "08a76e0d-c49b-4b38-ad8d-b59d65f251f8",
      "name": "Get BestSeller Sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "toolDescription": "Makes an HTTP request and returns the response data\n\nINPUT KEYWORD\uc5d0 \ub4e4\uc5b4\uac08 \ub0b4\uc6a9\uc73c\ub85c \uac80\uc0c9\ud574\uc918.\nURL : https://news.google.com/rss/search?q=<INPUT KEYWORD>&hl=ko&gl=KR&ceid=KR%3Ako",
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', ``, 'string') }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2,
      "position": [
        1024,
        672
      ],
      "id": "97ce6634-3feb-4fa3-87f2-6f2c3c6493ef",
      "name": "Google News"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Trigger": {
      "main": [
        [
          {
            "node": "BOT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a thread of messages posted to a channel": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "chat.postMessage": {
      "main": [
        []
      ]
    },
    "BOT": {
      "main": [
        [
          {
            "node": "Get a thread of messages posted to a channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "SlackBot AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion": {
      "ai_tool": [
        [
          {
            "node": "SlackBot AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model - 4.1 mini": {
      "ai_languageModel": [
        [
          {
            "node": "SlackBot AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "SlackBot AI Agent": {
      "main": [
        [
          {
            "node": "chat.postMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get BestSeller Sheet": {
      "ai_tool": [
        [
          {
            "node": "SlackBot AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google News": {
      "ai_tool": [
        [
          {
            "node": "SlackBot AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "339b9e05-45ce-4e78-bfd5-ff01f57c4936",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "yRh6IZhpIA0N5fbB",
  "tags": [
    {
      "createdAt": "2025-05-20T05:37:20.732Z",
      "updatedAt": "2025-05-20T05:37:20.732Z",
      "id": "tqx1yZajxcxP5kJn",
      "name": "\ud328\uc2a4\ud2b8\ucea0\ud37c\uc2a4"
    }
  ]
}