Access a Slack Client
Use these Apex classes to get access to a Slack client.
The following methods are deprecated on the App.apex class: getConnectedSalesforceUserId
, getConnectedSalesforceUserIdMap
,getConnectedSlackUserId
,
getConnectedSlackUserIdMap
. The Slack.App
class required that you access the listed methods within the context of an Apex Slack app. In the Summer ’23 release,
the UserMappingService class exposes these methods without requiring app context. Use the UserMappingService methods instead for an accurate picture of your org mappings.
The Slack.App
class represents a Slack app that enables interacting with a user or bot.
Usage
Use the Slack.RunnableHandler Interface
to create an instance of the Slack client.
Create an instance of a Slack client depending on the permission scopes you're using.
The following are methods for Slack.App
.
Gets the Slack app key, also known as the Slack app ID.
Signature
Return Value
Type: String
Reserved for future use. Returns a client to invoke Slack API methods as the Slack app in this context.
Signature
Return Value
Type: Slack.AppClient
Returns a client to invoke Slack API methods as a Slack bot user for the app in the given team.
Signature
Parameters
teamId
Type: String
The Slack workspace ID used to retrieve the client
Return Value
Type: Slack.BotClient
Returns a client to invoke Slack API methods as a Slack user for the app in the given team.
Signature
Parameters
teamId
Type: String
The Slack workspace ID used to retrieve the client.
slackUserId
Type: String
The Slack user ID used to retrieve the client.
Return Value
Type: Slack.UserClient
Gets the Salesforce user ID for a given Slack user ID within a Slack workspace.
Signature
Parameters
teamId
Type: String
The team ID used to retrieve the Salesforce user ID.
slackUserId
Type: String
The Slack user ID used to retrieve the Salesforce user ID.
Return Value
Type: String
Gets the Salesforce user IDs given a list of Slack user IDs in a Slack workspace for a specific Slack app. If at least one successful mapping is possible, then the returned map contains an entry for each supplied Slack user ID.
Signature
Parameters
teamId
Type: String
The Slack team ID associated with the Salesforce user IDs.
slackUserIds
Type: List<String>
Map of Slack user ID and Salesforce user ID.
Return Value
Type: Map<String, String>
Gets the Slack user ID for a given Salesforce ID within a Slack workspace.
Signature
Parameters
teamId
Type: String
The Slack team ID associated with the Slack user ID.
salesforceUserId
Type: String
The Salesforce user ID associated with the Slack user ID.
Return Value
Type: String
Gets the Slack user mappings given a list of Salesforce User IDs in a Slack workspace for a specific Slack app. If at least one successful mapping is possible, then the returned map contains an entry for each supplied Salesforce user ID.
Signature
Parameters
teamId
Type: String
The Slack team ID associated with the Slack user ID.
salesforceUserIds
Type: List<String>
The Salesforce user IDs associated with the Slack user ID.