Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Jan 22, 2024 9:35:30 PM
Oct 28, 2021 9:33:20 PM
At Talend we make a point of using our software wherever we can. It makes sense to use our own products: every different persona that uses our products in the real world is represented inside our organisation. Having these personas using the products internally enables us to really understand where the champagne elements of the product shine and where any dog food elements can be made a little more sparkly.
We needed to alert Talend technical staff of questions on Talend Community that had not been answered. However, the requirement was that this be made as simple as possible, as efficient as possible, and as tailorable as possible. We use Salesforce to host the Talend Community and we can send notifications out from the product. But we were limited as to how these notifications could be sent, what topics the notifications would be sent about, and how we would be able to monitor these notifications. We needed a way of allowing our technical experts to pick certain categories of questions to be notified about, to be able to send notifications to groups or individuals, and for these notifications to NOT go to email where they might be missed. Slack was overwhelmingly suggested as the delivery mechanism that people said they would like us to use.
The following article is part 1 of a three part mini-series, where I will focus on configuring a Slack app.
Content:
Before you can start using Slack with Talend, you have to configure Slack so that you can use it. This involves setting up an app, configuring security, requesting permissions, and so on. If you are the admin of Slack at your organization this won’t be too tiresome. For the rest of us, raise a ticket with your IT team now to get their attention, then by the last blog in this series, you may be ready to start.
The following step by step guide will take you through the configuration steps I used to build the Slack App to notify Talend employees of unanswered Talend Community questions. The App is called TalendCommunityMessenger.
channels:read | Allows the app to get information about public channels in order to communicate with them. In this case it is used to retrieve the channelId that is needed for the bot to instant message the channels. |
groups:read | Allows the app to get information about private channels that the bot is a member of. It is used to retrieve the channelId of private channels, which is needed for the bot to instant message the private channels. |
users:read | Allows the app to get information about users. This is needed to retrieve a channelId for each user being messaged. |
chat:write | Permits the bot to send messages as @talendcommunitymessen. |
chat:write.public | Allows the bot to send messages to channels. |
files:write | Required to allow the bot to send file data. |
im:write | Allows the bot to initiate a direct message. |
links:write | Allows the bot’s links to be previewed in Slack. |
Once you have your OAuth token, you are able to make use of it to test the API methods linked to each of the scopes. You can test posting messages using the info on Slack API's chat.postMessage page if you have a token and have selected the chat:write scope. There is a Tester tab that allows you to make calls by specifying parameters.
You can also test out building Blocks, which are a Slack way of formatting content. The Block Kit Builder is really useful for trying out different message formats.
At this point, you are free to work on your app without any other app configuration unless you want to add further scopes. If that is the case, you can add scopes as shown in steps 9 and 10, but you will have to get them authorized each time, as in step 11.
In order to secure the OAuth token that has been created for this app, I have used the Jasypt library. You don’t have to do this, but it makes sense to ensure that your OAuth token is safe. The Jasypt library is supplied with the Talend Studio install but can also be found on the Jasypt: Java Simplified Encryption site.
Below you can see the code that has been put together using this library. This is used to both encrypt and decrypt the OAuth token.
package routines; import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; public class JasyptEncryptionUtils { private static StandardPBEStringEncryptor setEncryptor(String password) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(password); encryptor.setAlgorithm("PBEWithMD5AndTripleDES"); return encryptor; } public static String encrypt(String data, String password) { StandardPBEStringEncryptor encryptor = setEncryptor(password); return encryptor.encrypt(data); } public static String decrypt(String data, String password) { StandardPBEStringEncryptor encryptor = setEncryptor(password); return encryptor.decrypt(data); } }
I thought that this code might be useful to you and it is good practice to not store your tokens in clear text. However, in this tutorial I will not focus on the security side in too much detail since you will have your own way of doing that. I will stick with the main elements of how to get Talend sending Slack messages, but may occasionally nod to other areas like this.
You can now experiment with the Slack API and you also have some time to consider how you might want to use Slack with your Talend integrations.
In part 2, I will talk about using the Slack API to retrieve essential data from Slack before you can start sending messages to people and groups.
Continue to Part 2: Collecting your Slack data.