Create a Slack App that can be installed to multiple workspaces

Hi !

I am trying to build a Slack app that does simple automation like syncing your Slack status to your calendar events for example.
My goal is that this app can be installed in multiple workspaces and then published to the Slack app directory.

I am using the Slack node and have installed it in my personal workspace, but when I enable “public distribution” in my app (in Slack), I have an error message when I try to connect to a new workspace. It seems that my Slack workflow is tied to a specific user and a specific workspace.

Do you have any idea how can I manage this and allow multiple users/workspaces to be connected to my app?

What I have in mind is that I have to manage the authentification part (maybe with webhooks & a database to store tokens) in a specific n8n workflow, and then the interaction part (post messages, sync calendars…) can be managed thanks to another n8n workflow with an HTTP request for example.

Would love to have some help, thank you!

Hey @clac,

Welcome to the community :sparkling_heart:

You’re correct. The Slack node in your workflow gets tied to your workspace. A quick question: How are you using n8n - n8n.cloud or self-hosting it on your server?

I am not much familiar with Slack apps. Can you please help me understand the process of adding the app to a workspace? I am mainly interested to know if the user has to undergo an authentication flow after they install the app. If they do, then you would have to handle the authentication differently.
Right now, one can authenticate for a node within n8n itself, hence this needs to be handled.

Hey @harshil1712!

Thank you very much :pray:

Right now, I am using n8n self-hosted.

Then, regarding the authentication with Slack, it works the following way if you want to do this outside n8n :

  • You have a public link which is your app install link that you can share with the users who wants to use your app

  • They have a consent screen where the scopes you are asking are showed to users and they grant access to your app (basic OAuth 2 flow) → at this step your app is added to the user workspace

  • You receive from Slack in response an access token that you will use to interact with the workspace

  • You do an API call to either collect data from the users (eg channels_ids, users_ids…) which are args that you will send in another call to send messages to a specific channel for example, or to retrieve more specific info

Here you have the flow explained by Slack (source : Installing with OAuth | Slack)

So what I had in mind was to handle the authentication part (to store tokens especially) with a specific n8n workflow, and then the interaction part (API calls to collect data or to interact with the users in Slack) with other n8n workflows.

But I am a bit lost to configure properly these workflows. You especially need to have a server to interact with Slack and to collect the user token once the user has granted access to your app for example. I have no idea how to do such a thing in n8n…

Hey @clac,

Thank you for sharing the detailed explanation, I now have a much better understanding of the flow.

This is what I can think of:
Store the token of the workspace in a database. Each time the workflow get’s triggered (your Slack app runs), check for the workspace and get its’ token from the db. In the next step use that token to interact with the Slack API.
I would heavily rely on the Webhook node and the HTTP Request node to achieve this.

Hey @harshil1712 ! Thank you very much for your answer.

Yes, I think this workflow with tokens in DB & HTTP Request to interact with the users is the right thing. And when the user wants to interact with my app (still need to dig a bit more the Slack doc), I think this can be done with webhooks.

Thank you !
Basic nodes are really the ones that allow you to do so interesting things :hugs:

1 Like