Slack Integration using Incoming Webhooks, Access Token, Web API slack methods and integration services.
- Requires Slack account and a workspace created in it. After that Sign into your Slack workspace or have the Slack desktop application open.
- If you sign in using the URL above, you’ll need your workspace Slack URL.
- Go to Your Apps and click the Create New App button (Enterprise account: Need’s admin permission for approval of your app).
- Enter your App Name, select the Development Slack Workspace and click the Create App button.
After you create your app, you’re taken to the Basic Information page. There are Different ways to authenticate.
1. Incoming webhooks (Unattended automation)
From features go to Incoming Webhooks and activate incoming webhooks.
- Incoming webhooks are a simple way to post messages from external sources into Slack. They make use of normal HTTP requests with a JSON payload, which includes the message and a few other optional details. You can include message attachments to display richly formatted messages.
- Adding incoming webhooks requires a bot user. If your app doesn’t have a bot user, we’ll add one for you.
- Each time your app is installed, a new Webhook URL will be generated.
- If you deactivate incoming webhooks, new Webhook URLs will not be generated when your app is installed to your team. If you’d like to remove access to existing Webhook URLs, you will need to Revoke All OAuth Tokens.
- To dispatch messages with your webhook URL, send your message in JSON as the body of an
- Next add the new webhook to workspace (you can select channel, direct message etc.) and copy that webhook URL.
- Before making use of that webhook URL download the Web API package from the marketplace into the studio and drag & drop http request in that paste the URL in the end point section.
2. Web API slack methods (Unattended automation)
Before using this, you should configure the OAuth & Permissions features by following the steps in the next section.
- Add Permissions: Adding permissions to your app is done using scopes. Scopes define the API methods this app can call and the information it can access in the workspace it’s installed on. Many scopes are restricted to specific resources like channels or files.
- In the left-hand navigation, click the OAuth & Permissions.
- In the Scopes section, add the permission scopes that you want to assign to your app and click the Save Changes button (Scopes to add)
- Based on HTTP request token used roles must be configured i.e. it can be bot or user OAuth token.
- After adding scope, click the Install App to Workspace button or Request to Install button.
- After the app is installed, an OAuth Access Token is generated. Make use of that token based on bot or user.
Note: To use admin scopes, you need paid version of slack.
Next After configuring all the scope, now you can make use of all the web API slack methods using this URL
Note: The same Web API methods can be implemented using UiPath.Slack.Activities (v1.1.0) package in UiPath studio with Invoke Slack Operation activity.
3. Access Token (Unattended automation)
- In the OAuth Tokens & Redirects URLs section, click the Install App to Workspace button or Request to Install button.
- After the app is installed, an OAuth Access Token is generated. The OAuth Access Token is used for authentication purposes.
- Make use of that token in the Slack Scope activity
4. Integration Service (Unattended automation)
- Select Integration Service from Automation Cloud.
- From the Connectors list, select Slack.
You can also use the search bar to narrow down the connector.
- Select the Add connection button.
- Select Connect.
- You are now redirected to Slack sign in page. Enter your workspace URL and select Continue.
- If you’re a member of the workspace, select Sign in with SSO. If you’re a guest, select I have a guest account and you are prompted to enter your email address and password.
For this example, we are choosing to sign in with SSO.
- Select Allow.
- Your connection has been added.
- Start Building your project by installing Slack package.
Build your project in the studio:
- Create a new automation project by clicking blank process and rename it and open.
- Install the UiPath.Slack.Activities v1.1.0 (not compatible with cross-platform) package (for working with Slack scope)
Preview versions of the Slack activity pack prior to 1.0.3 do not work alongside the Invoke Code activity pack and you are unable to run a process when they are both installed. This was fixed in Slack version 1.0.3 (released in 2021).
How to use Invoke Slack Operation activity?
Step 1: Use slack scope and configure, API token must be same for both Design and Robot connection.
Step 2: Now drag and drop Invoke Slack Operation activity , here you can make use of different methods (under category) and type of operation you need (Operation Name).
- Choose according to your requirements and provide the desired value in the value section (Editable) and click done after configured.
- You can even use other default activities present in the UiPath.Slack.Activities
- Install the Slack v3.5.3 (not compatible with windows legacy) package (for working with cloud integration service)
- Install UiPath.WebAPI.Activities package (for working with incoming webhooks and web API slack methods)
How to configure HTTP for web API slack methods?
Endpoint: provide the desired Endpoint URL, it changes depending on the requirements
- Request method: select the methods based on API key (GET, POST, UPDATE etc.,)
- Accept response: response from the API request it can be JSON, XML or anything. As of now slack API response is JSON.
- Parameters: If that desired method requires any mandatory parameters provide here
- Attachments: Used when you want to add any file attachments
- Authentication: authentication types are Simple HTTP, OAuth1 and OAuth2 (requires access token key)
- That’s all you can start building your automation.
Each and every method has its own advantages and disadvantages, choose accordingly based on requirement.
Comparison on Different Methods
|Slack scope Integration||Integration Service||Web APIs|
|Does not require URLs.||Does not require URLs.||URLs are required for every method.|
|A single slack scope has been configured and all the slack activities can be used inside.||All the activities are connected automatically once the connection has been made in the Integration service (Automation cloud).||The access token code must be provided for every HTTP request.|
|Consumes less time as we must only provide the values.||Consumes less time as we must only provide the values.||Consumes more time as we must manually add the parameters and the value.|
|Can create an output variable in the given activity and use it in other activities.||Can create an output variable in the given activity and use it in other activities.||Once the output variable is created, it is in JSON format, therefore it must be de-serialized to get the required details.|
|User friendly, as the activities itself tells the user what to do.||User friendly, as the activities itself tells the user what to do.||Requires programming knowledge and understanding about how request has been made and data is fetched/posted.|
|Built-in slack activities are present in the integrations tab in the activities panel.||Built-in slack activities are available in the integrations service tab in the activities panel.||There are no built-in activities, HTTP request is used to post/get data.|
|UiPath.Slack.Activities package must be installed.||UiPath.Slack.IntegrationService.Activities must be installed.||UiPath.WebAPI.Activities has to be installed.|
To be known
- You can Add users to channels using member ID only (this will happen once the user was added into that particular workspace)
How to get member ID of a person and channel ID in slack?
Go to user profile → view full profile → click on the 3 dots → scroll down you will find member ID.
Go to channel → click on the channel and scroll down you can find channel ID.
- User cannot be removed from #general channel.
- To schedule a message, you need to convert date time format to timestamp (click here).