version 1.1.0
New Features
Block Kit Kotlin DSL
Block Kit Kotlin DSL is a huge addition since this release. The new optional modules enable Kotlin developers to use much smoother and more intuitive DSLs for constructing rich messages, modal views, and Home tabs. Refer to the document pages and examples in the repository for details.
import com.slack.api.Slack
import com.slack.api.model.block.Blocks.*
import com.slack.api.model.kotlin_extension.request.chat.blocks
val slack = Slack.getInstance()
val token = System.getenv("SLACK_BOT_TOKEN")
val response = slack.methods(token).chatPostMessage { it
.channel("C1234567")
.blocks {
section {
// "text" fields can be constructed via plainText() and markdownText()
markdownText("*Please select a restaurant:*")
}
divider()
actions {
// To align with the JSON structure, you could put the elements { } block around the buttons but for brevity it can be omitted
// The same is true for things such as the section block's "accessory" container
button {
// For instances where only plain text is acceptable, the field's name can be filled with plain text inputs
text("Farmhouse", emoji = true)
value("farmhouse")
}
button {
text("Kin Khao", emoji = true)
value("kin-khao")
}
}
}
}
Related issues/PRs: #428 #469 #501 #503 #504 #513
http.proxyHost / http.proxyPort support in all Slack API clients
In v1.0.x versions, slack-api-client
users have to manually extract http.proxyHost
and http.proxyPort
from system properties, concatenate those into a single string value, and then call SlackConfig#setProxyUrl(String)
with the generated URL.
As those system properties are the standard ones, SlackConfig
started supporting them out-of-the-box since v1.1.0. It works this way: 1) automatically read them, 2) build the proxy URL that consists of the value, and set it as the default value of proxyUrl
when the properties exist.
In the case a developer explicitly gives a proxyUrl
value, the URL must be prioritized over the host + port in system properties.
Short-time cache for Bolt authorization
Bolt for Java used to excessively call auth.test
every time the app receives an incoming request from the Slack API server. I
t's the safest way to always ensure if the underlying token is valid but it can be a not-small overhead for the app's response time. We've introduced the following options to enable Bolt apps to have a short-time cache for the auth.test
API calls.
AppConfig#authTestCacheEnabled
(default: false)AppConfig#authTestCacheExpirationMillis
(default: 3000)
The default behavior won't be changed. Only when a Bolt app turns the flag on, the cache will be enabled.
The cache layer doesn't support distributed cache implementations (e.g., the ones using Memcached, Redis) by design. As mentioned in #468, the purpose of this cache is to reduce the number of auth.test
API calls in Bolt apps that tend to receive lots of incoming requests from Slack in a short time of period.
A bunch of new APIs
As of July 13, the slack-api-client
module supports all the public Web APIs.
- admin.usergroups.addTeams
- admin.conversations.restrictAccess.*
- calls.participants.remove
- conversations.mark
Changes
- [kotlin-extension] #428 #469 #501 #503 #504 #513 Add Kotlin DSL modules for constructing Block Kit payloads - thanks @emanguy @seratch
- [bolt] #502 #468 short-time cache for authorization middleware - thanks @eamelink @seratch
- [slack-api-client] #508 Bump okhttp version from 4.7.2 to 4.8.0 - thanks @seratch
- [slack-api-client] #500 #499 Add proxy system properties support (http.proxyHost / http.proxyPort) - thanks @seratch
- [slack-api-client] #512 Redact authorization header from debug logging outputs - thanks @seratch
- [slack-api-client] #507 Add admin.conversations.restrictAccess.* APIs - thanks @seratch
- [slack-api-client] #509 Add conversations.mark API - thanks @seratch
- [slack-api-client] #505 Add calls.participants.remove, admin.usergroups.addTeams API - thanks @seratch
- [slack-app-backend] #494 #496 Add file_share message events & files in message_changed events - thanks @Hariprasad-Ramakrishnan @seratch
- [bolt-micronaut] #508 Bump micronaut from 1.3 to 2.0 - thanks @seratch