workflows.fit
Back to n8n workflows
n8n templateFreeBy James Francis

Create a Slack AI chatbot with threads & thinking UI using OpenRouter & Postgres

Overview Slack quietly released an update to their API that allows developers to build "AI Apps & Agents", which is a special classification of apps that have access to several special capabilities including: - Multip...

DevelopmentCore NodesCommunicationHITLAILangchainLm Chat Open RouterAgent
Loading interactive preview...

Template notes

Overview

Slack quietly released an update to their API that allows developers to build "AI Apps & Agents", which is a special classification of apps that have access to several special capabilities including: - Multiple simultaneous chat threads with one user - Loading "three dots" UI while your agent is thinking - Option for users to pin your app to their top bar for quick chat access

This workflow demonstrates how to build a Slack agent that takes advantage of all of these features.

For a full video walkthrough of this workflow, watch [this YouTube tutorial](https://youtu.be/2DptBvZPKRs).

Setup Instructions

All of the below steps are required for this workflow to function properly unless otherwise noted.

Create a Slack App 1. Visit [api.slack.com](https://api.slack.com/) and click "Your Apps" 2. Create a new app from scratch and follow the setup instructions 3. In the Agents & AI Apps tab, enable the toggle and give your app a brief description 4. In the OAuth & Permissions tab, enable the following bot token scopes: 1. assistant:write 2. chat:write 3. channels:read 4. im:history 5. Install the app into your workspace and grant the requested permissions 6. In your Slack workspace, right click your app's name in the sidebar, click "View app details", and make note of your apps Channel ID - you'll need this later. 7. Copy your app's Bot User OAuth Token - you'll need that to create your n8n credentials 8. In the Event Subscriptions tab, enable events and paste the workflows PRODUCTION webhook url (from this workflow's trigger node) into the input. 9. In the same tab under "Susbcribe to bot events", select message.im

Create a Postgres database In order to save the chat history and give your agent a working memory, you'll need your own Postgres database. You can use Supabase, Neon, or any other Postgres database provider. Once you've added your database's credentials to n8n, you can select those credentials in the Postgres Chat Memory node. This worklow saves all chat history in a table called chathistories, but you name the table whatever you want.