Configuring the Slack service
Nov 17, 2025

# Ag Slack Integration - Setup & Deployment Guide
This detailed guide explains how to configure the AppGrid Slack integration for subscriber orgs.
If you wish to use the AppGrid Slack integration, you will need to create a new Slack app in your Slack workspace. This is true even if you have installed Slack for Sales or any other Salesforce Slack app. The new Slack app will point to the same customer org so the data sharing is seamless. In order for the AppGrid Slack integration to work, the Slack ClientId and Secret are required and these are not visible for customers using any of the Salesforce Slack apps. Customers must create a new Slack App, Auth Provider, and Named Credential.
Step 1: Create Slack App in Slack Workspace
1. Go to https://api.slack.com/apps and create a new app.
2. Add the following OAuth scopes to the Bot Token Scopes (recommended):
- `chat:write`
- `chat:write.public`
- `channels:read` or `conversations:read`
- `channels:history` or `conversations.history`
- `users:read`
- `users:read.email`
- `reactions:read`
- `reactions:write`
- `files:write`
- `search:read`
- `pins:write`, `pins:read`
- (Add more as required by your use-case)
3. Install the app to the workspace and capture the Client ID/Secret if you will use OAuth.
Step 2: Create an Auth Provider in Salesforce
1. Setup → Auth. Providers → New
2. Provider Type: OpenID Connect or Custom (Slack is OAuth2)
3. Fill in the Client ID, Client Secret, Authorize Endpoint, Token Endpoint as per Slack docs.
4. Save.
Step 3 : Create a Named Credential
1. Setup → Named Credentials → New
2. Label/Name: e.g., `AgSlack_NC` (API name will be `AgSlack_NC`)
3. URL: `https://slack.com/api` (or leave base; the callout path includes the API path)
4. Identity Type: Named Principal (or Per User depending on app)
5. Authentication Protocol: OAuth 2.0
6. Select the Auth. Provider created earlier
7. Click Save and Authenticate (click the Authenticate button to complete OAuth flow)
Step 4: Create Custom Metadata Record
1. Setup → Custom Metadata Types → AppGridAg AppGrid Slack Config → Manage Records → New
2. Label: `Default`
3. DeveloperName: `Default` (this is what AgSlackConfigUtil expects)
4. AppGridAg__Named_Credential_Name__c: set to the Named Credential API name (e.g., `AgSlack_NC`)
5. AppGridAg__Default_Channel__c: optional
6. AppGridAg__Is_Active__c: true
7. Save
Step 5: Deploy Apex & LWC
- Ensure all classes (`AgSlackConfigUtil`, `AgSlackService`, `AgSlackController`, `AgSlackSetupController`, etc.) are deployed.
Step 6: Validate
1. Install the Setup LWC page (slackSetup) or invoke `AgSlackController.authTest()` from the dev console.
2. If auth is successful, Slack will return `{"ok": true, ...}`.
// Troubleshooting
- If you get `HTTP 401` or `invalid_auth`, re-authenticate the Named Credential.
- Ensure scopes in Slack app match what your integration needs.
- Ensure CMDT record `Default` is present and points to the correct Named Credential.