Slack credentials#
You can use these credentials to authenticate the following nodes:
Supported authentication methods#
- API access token:
- Required for the Slack Trigger node.
- Works with the Slack node, but not recommended.
- OAuth2:
- Recommended method for the Slack node.
- Doesn't work with the Slack Trigger node.
Related resources#
Refer to Slack's API documentation for more information about the service.
Using API access token#
To configure this credential, you'll need a Slack account and:
- An Access Token
To generate an access token, create a Slack app:
- Open your Slack API Apps page.
- Select Create New App > From scratch.
- Enter an App Name.
- Select the Workspace where you'll be developing your app.
- Select Create App. The app details open.
- In the left menu under Features, select OAuth & Permissions.
- In the Scopes section, select appropriate scopes for your app. Refer to Scopes for a list of recommended scopes.
- After you've added scopes, go up to the OAuth Tokens section and select Install to Workspace. You must be a Slack workspace admin to complete this action.
- Select Allow.
- Copy the Bot User OAuth Token and enter it as the Access Token in your n8n credential.
- If you're using this credential for the Slack Trigger, follow the steps in Slack Trigger configuration to finish setting up your app.
Refer to the Slack API Quickstart for more information.
Slack Trigger configuration#
To use your Slack app with the Slack Trigger node:
- Go to Features > Event Subscriptions.
- Turn on the Enable Events control.
-
In n8n, copy the Webhook URL and enter it as the Request URL in your Slack app.
Request URL
Slack only allows one request URL per app. If you want to test your workflow, you'll need to do one of the following:
- Test with your Test URL first, then change your Slack app to use the Production URL once you've verified everything's working
- Use the Production URL with execution logging.
-
Once verified, select the bot events to subscribe to. Use the Trigger on field in n8n to filter these requests.
- To use an event not in the list, add it as a bot event and select Any Event in the n8n node.
Refer to Quickstart | Configuring the app for event listening for more information.
Using OAuth2#
n8n 云服务用户注意事项
云服务用户无需提供连接详细信息。选择连接我的账户通过浏览器进行连接。
If you're self-hosting n8n and need to configure OAuth2 from scratch, you'll need a Slack account and:
- A Client ID
- A Client Secret
To get both, create a Slack app:
- Open your Slack API Apps page.
- Select Create New App > From scratch.
- Enter an App Name.
- Select the Workspace where you'll be developing your app.
- Select Create App. The app details open.
- In Settings > Basic Information, open the App Credentials section.
- Copy the Client ID and Client Secret. Paste these into the corresponding fields in n8n.
- In the left menu under Features, select OAuth & Permissions.
- In the Redirect URLs section, select Add New Redirect URL.
- Copy the OAuth Callback URL from n8n and enter it as the new Redirect URL in Slack.
- Select Add.
- Select Save URLs.
- In the Scopes section, select appropriate scopes for your app. Refer to Scopes for a list of scopes.
- After you've added scopes, go up to the OAuth Tokens section and select Install to Workspace. You must be a Slack workspace admin to complete this action.
- Select Allow.
- At this point, you should be able to select the OAuth button in your n8n credential to connect.
Refer to the Slack API Quickstart for more information. Refer to the Slack Installing with OAuth documentation for more details on the OAuth flow itself.
Scopes#
Scopes determine what permissions an app has.
- If you want your app to act on behalf of users who authorize the app, add the required scopes under the User Token Scopes section.
- If you're building a bot, add the required scopes under the Bot Token Scopes section.
Here's the list of scopes the OAuth credential requires, which are a good starting point:
Scope name | Notes |
---|---|
channels:read |
|
channels:write |
Not available as a bot token scope |
chat:write |
|
files:read |
|
files:write |
|
groups:read |
|
im:read |
|
mpim:read |
|
reactions:read |
|
reactions:write |
|
stars:read |
Not available as a bot token scope |
stars:write |
Not available as a bot token scope |
usergroups:read |
|
usergroups:write |
|
users.profile:read |
|
users.profile:write |
Not available as a bot token scope |
users:read |
Common issues#
Token expired#
Slack 提供令牌轮换功能,您可以为机器人和用户令牌启用此功能。这会使所有令牌在 12 小时后过期。虽然这对测试可能有用,但启用此功能的令牌在过期后,使用这些令牌的 n8n 凭据将失败。如果您想在生产环境中使用 Slack 凭据,此功能必须关闭。
要检查您的 Slack 应用是否启用了令牌轮换,请参阅 Slack API 文档 | 令牌轮换。
如果您的应用使用令牌轮换
请注意,如果您的 Slack 应用使用令牌轮换,您无法再次关闭它。您需要创建一个禁用令牌轮换的新 Slack 应用。