IT Ops AI SlackBot Workflow Chat with your knowledge base n8n Workflow Template

n8n workflow template · 10 nodes · OpenAI

IT Ops AI SlackBot Workflow Chat with your knowledge base is a free n8n workflow template that starts when its webhook receives an HTTP request and works with OpenAI and Slack. It has 10 nodes, 4 of them AI nodes (OpenAI Chat Model, Window Buffer Memory, Call n8n Workflow Tool and AI Agent). The notes inside the workflow say: “The first node receives all messages from Slack API via Subscription Events API. You can find more information about setting up the subscription events API by clicking here.” To run it, you add your own credentials for OpenAI API and Slack API.

At a glance

Trigger
Webhook (Receive DMs)
Nodes
10
Apps
OpenAI and Slack
AI nodes
4
Credentials
2 types
Category
Chatbots and messaging

Apps and integrations

  • OpenAI
  • Slack

Node types used

  • Respond to Webhook
  • OpenAI Chat Model
  • Window Buffer Memory
  • If
  • Slack
  • Webhook
  • Call n8n Workflow Tool
  • AI Agent

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Webhook Trigger

The first node receives all messages from Slack API via Subscription Events API. You can find more information about setting up the subscription events API by clicking here. The second node responds to the periodic security challenges that Slack sends to ensure the N8n webhook is still active.

Check for Bot Responses

If the message received is from a Bot instead of a real user, it will ignore the message.

Response Received

Once N8n sees that the messaged received is from a user, it will respond right away to acknowledge a message was received. You can edit the message by opening the node below.

Remembers the last 5 messages that a user sent

Because we are passing the channel ID of the user to the memory module, n8n is storing the last 5 slack messages sent to it per slack channel. This means that it will remember all your users conversations separately from one another and not get confused by different requests from different users. You can increase the memory storage by using a different storage medium and increase the number of prompts and responses it should remember.

Parse Response with AI Model

This workflow currently uses OpenAI to power it's responses, but you can open the AI Agent node below and set your own AI LLM using the n8n options offered.

Delete Receipt and Send Response

Once the AI response is generated in response to the slack message, n8n delete's it's original Message Received message to avoid cluttering up the user's DMs, and then sends the final Slack message back to the user.

Build n8n workflow to query Knowledge Base

Building your own tools for an AI Agent to use is simple and straightforward, but requires that you build a second workflow and then connect it to this one by inputting the workflow ID from the workflow URL in the Custom n8n KB Tool sub node.

This gives you the freedom to work with any tool, whether n8n has support for it or not. In this sample build, we have connected the AI agent to Confluence, which does not have a native built in n8n node. For this we use the HTTP request node and pointed it to Confluence's search api. It then returns a response that the AI agent uses to generate a final slack message response to the user.

Setup notes

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Streamline IT Inquiries with n8n & AI!

Introducing the IT Ops AI SlackBot Workflow---a sophisticated solution designed to automate and optimize the management of IT-related inquiries via Slack.

When an employee messages the IT department slack app, the workflow kicks off with the "Receive DMs" node, which captures incoming messages and ensures a secure and active communication line by responding to Slack's webhook challenges.

How It Works

  • Verify Webhook: Responds to slacks challenge and respond requests to ensure is still active.
  • Check if bot: Checks whether the message sender is a bot to prevent unnecessary processing.
  • Send Initial Message: Sends a quick confirmation, like "On it!", to let the user know their query is being handled.
  • AI-Driven Responses: Employs the "AI Agent" node with OpenAI to craft relevant replies based on the conversation history maintained by the "Window Buffer Memory" node.
  • Knowledge Integration tool: Uses a custom Knowledge Base tool to fetch pertinent information from confluence, enhancing the quality of responses.
  • Cleanup and Reply: Deletes the initial acknowledgment to tidy up before sending the final detailed response back to the user.
  • Ensure your Slack and OpenAI integrations are properly set up.
  • Customize the workflow to align with your IT department's protocols.
  • Join the discussion on our Forum or check out resources on Discord!

Deploy this workflow to improve response times and enhance the efficiency of your IT support services.

Change the AI Agents LLM

To change the model used, simply delete the ChatGPT model and replace with a different supported model by hitting the plus sign under model in the AI Agent.

Nodes in this workflow

The 10 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. Verify Webhook (Respond to Webhook)
  2. OpenAI Chat Model (OpenAI Chat Model)
  3. Window Buffer Memory (Window Buffer Memory)
  4. Check if Bot (If)
  5. Send Initial Message (Slack)
  6. Delete Initial Message (Slack)
  7. Send Message (Slack)
  8. Receive DMs (Webhook)
  9. Call Confluence Workflow Tool (Call n8n Workflow Tool)
  10. AI Agent (AI Agent)

Credentials you need

  • OpenAI API – used by OpenAI Chat Model
  • Slack API – used by Delete Initial Message, Send Initial Message and Send Message

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us