Einen Slack-KI-Chatbot mit Threads und Denk-Interface erstellen (OpenRouter und Postgres)

Fortgeschritten

Dies ist ein Support Chatbot, AI Chatbot-Bereich Automatisierungsworkflow mit 12 Nodes. Hauptsächlich werden If, Slack, HttpRequest, SlackTrigger, Agent und andere Nodes verwendet. Erstellen Sie einen Slack-KI-Chatbot mit Threads und Thought-Interface mit OpenRouter und Postgres

Voraussetzungen
  • Slack Bot Token oder Webhook URL
  • Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
  • PostgreSQL-Datenbankverbindungsdaten
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "meta": {
    "instanceId": "9192ad8880fb52b25f18408be81eae9d996a6784a1da3c68d52d3b7ef01d482b",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "7436eb20-9360-4219-8c2b-8b56eb3843ec",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -80,
        160
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "muXopBcyQsze8BOD",
          "name": "OpenRouter | Paper Jam"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9601c9d7-41c0-44da-8a9c-97956711bd07",
      "name": "KI-Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -80,
        -20
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "You are a helpful, friendly, assistant. \n\nYou always respond only nicely formatted markdown where appropriate."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "23df5bee-5095-4c8d-9f78-c62119734332",
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -60,
        440
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0442b3d9-2149-49b6-9cc8-af92d1ed036c",
      "name": "On Message Received",
      "type": "n8n-nodes-base.slackTrigger",
      "position": [
        -860,
        80
      ],
      "webhookId": "cf67c1e1-f3db-401e-9439-c0f315c05baf",
      "parameters": {
        "options": {
          "resolveIds": false
        },
        "trigger": [
          "message"
        ],
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_APPS_CHANNEL_ID"
        }
      },
      "credentials": {
        "slackApi": {
          "id": "awboaOk6Kh1kQZ7N",
          "name": "Slack | Paper Jam"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d9efc43e-b1c1-48c0-8c68-42304c752645",
      "name": "Check If User",
      "type": "n8n-nodes-base.if",
      "position": [
        -480,
        80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ab6c4d27-4daf-4c6f-9ad5-866f6cb62758",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.bot_id }}",
              "rightValue": ""
            },
            {
              "id": "211e32ac-a544-46f4-8ce9-9a41674c4184",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.text }}",
              "rightValue": ""
            },
            {
              "id": "6160af99-6beb-4858-95e6-16e808c22581",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.type }}",
              "rightValue": "message"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "99ccfdff-4fd1-4cff-99e0-7a2620735ff8",
      "name": "Setzen Thinking Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        0,
        -400
      ],
      "parameters": {
        "url": "https://slack.com/api/assistant.threads.setStatus",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "channel_id",
              "value": "={{ $json.channel }}"
            },
            {
              "name": "status",
              "value": "is thinking..."
            },
            {
              "name": "thread_ts",
              "value": "={{ $json.thread_ts }}"
            }
          ]
        },
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "id": "Pp3oG0nadbpd6DqZ",
          "name": "Jina Bearer Token | Paper Jam"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f1bbe14d-9274-4e7a-804a-dd65b6efca24",
      "name": "Send Reply",
      "type": "n8n-nodes-base.slack",
      "position": [
        560,
        60
      ],
      "webhookId": "f23b3a3c-b618-4d39-a5f0-4d85c65519af",
      "parameters": {
        "text": "={{ $json.output }}",
        "select": "channel",
        "blocksUi": "={\n \"blocks\": [\n   { \n    \"type\": \"markdown\", \n    \"text\": {{ JSON.stringify($json.output) }}\n    }\n ]\n}\n\n",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('On Message Received').item.json.channel }}"
        },
        "messageType": "block",
        "otherOptions": {
          "mrkdwn": true,
          "thread_ts": {
            "replyValues": {
              "thread_ts": "={{ $('On Message Received').item.json.ts }}"
            }
          },
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "id": "awboaOk6Kh1kQZ7N",
          "name": "Slack | Paper Jam"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "484b674d-be92-49a9-9a0d-a4f9747dc5bb",
      "name": "Haftnotiz",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -40
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 280,
        "content": "## Listen for a DM\n\n**IMPORTANT**: Enter your Slack app's ID in the \"Channel to Watch\" field."
      },
      "typeVersion": 1
    },
    {
      "id": "fdd9665d-b7c1-4a1d-b84d-6113ffb88a55",
      "name": "Haftnotiz1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -580,
        -40
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 280,
        "content": "## Filter out noise\n\nWe only care about user messages."
      },
      "typeVersion": 1
    },
    {
      "id": "c7cc385d-189f-4fb0-9901-8acbd4696e0c",
      "name": "Haftnotiz2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 360,
        "height": 360,
        "content": "## Activate loading UI\n\nThis HTTP POST request will trigger the \"three dots\" thinking UI in the message thread. Slack automatically removes this UI when our app responds."
      },
      "typeVersion": 1
    },
    {
      "id": "07c2ebc0-bc20-4584-bf87-31788aa1646d",
      "name": "Haftnotiz3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -140
      ],
      "parameters": {
        "color": 7,
        "width": 440,
        "height": 460,
        "content": "## Customize your agent here\n\nThe agent is the brains of your chatbot. Customize the prompts and tooling however you need."
      },
      "typeVersion": 1
    },
    {
      "id": "242fa108-e421-4428-814d-b4ebf967f12d",
      "name": "Postgres Chat Speicher",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        60,
        160
      ],
      "parameters": {
        "tableName": "chat_histories",
        "sessionKey": "={{ $('On Message Received').item.json.thread_ts }}",
        "sessionIdType": "customKey"
      },
      "credentials": {
        "postgres": {
          "id": "td26YI5S9ozNu8dq",
          "name": "Postgres | Paper Jam n8n"
        }
      },
      "typeVersion": 1.3
    }
  ],
  "pinData": {},
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "f1bbe14d-9274-4e7a-804a-dd65b6efca24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d9efc43e-b1c1-48c0-8c68-42304c752645": {
      "main": [
        [
          {
            "node": "Set Thinking Status",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "23df5bee-5095-4c8d-9f78-c62119734332",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0442b3d9-2149-49b6-9cc8-af92d1ed036c": {
      "main": [
        [
          {
            "node": "d9efc43e-b1c1-48c0-8c68-42304c752645",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "7436eb20-9360-4219-8c2b-8b56eb3843ec": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Fortgeschritten - Support-Chatbot, KI-Chatbot

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes12
Kategorie2
Node-Typen9
Schwierigkeitsbeschreibung

Für erfahrene Benutzer, mittelkomplexe Workflows mit 6-15 Nodes

Autor
James Francis

James Francis

@paperjam

👋 Hi, I'm James. I run an AI automation agency focused on building small, focused workflows that have a direct and measurable impact on business growth or optimization.

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34