Skip to content

Releases: slackapi/java-slack-sdk

version 1.2.0

06 Oct 07:06
Compare
Choose a tag to compare

New Features

Steps from Apps

Workflow Steps from apps allow your app to create and process custom workflow steps that users can add using Workflow Builder. Check the document for details: https://slack.dev/java-slack-sdk/guides/steps-from-apps

import com.slack.api.bolt.App;
import com.slack.api.bolt.middleware.builtin.WorkflowStep;

App app = new App();
WorkflowStep step = WorkflowStep.builder()
  .callbackId("copy_review")
  .edit((req, ctx) -> { return ctx.ack(); })
  .save((req, ctx) -> { return ctx.ack(); })
  .execute((req, ctx) -> { return ctx.ack(); })
  .build();
app.step(step);

If you are a Koltin developer, try the Kotlin extensions out! With the optional modules, building Workflow Steps can be even more concise!

val step = WorkflowStep.builder()
  .callbackId("copy_review")
  .edit { _, ctx ->
    ctx.configure(withBlocks {
      input {
        blockId("task_name_input")
        element {
          plainTextInput {
            actionId("task_name")
            placeholder("Write a task name")
          }
        }
        label("Task name")
      }
    })
    ctx.ack()
  }
  .save { req, ctx ->
    val values = req.payload.view.state.values
    val inputs = mapOf("taskName" to stepInput { it.value(values["task_name_input"]?.get("task_name")?.value) })
    val outputs = listOf(stepOutput { it.name("taskName").type("text").label("Task Name") })
    ctx.update(inputs, outputs)
    ctx.ack()
  }
  .executeAutoAcknowledgement(false)
  .execute { req, ctx ->
    val step = req.payload.event.workflowStep
    GlobalScope.async {
      try {
        val email = step.inputs["taskAuthorEmail"]?.value.toString()
        val outputs = mapOf("taskName" to step.inputs["taskName"]?.value)
        ctx.complete(outputs)
      } catch (e: Exception) {
        ctx.fail(mapOf("message" to "Something wrong! ($e)"))
      }
    }
    ctx.ack()
  }
  .build()

val app = App()
app.step(step)

New Events API Payload Support

Events will no longer contain full lists of authed_users or authed_teams

https://api.slack.com/changelog/2020-09-15-events-api-truncate-authed-users

Since this version, this SDK supports newly added authorizations and is_ext_shared_channel fields in Events API payloads. Also, the slack-api-client provides the method to call apps.event.authorizations.list API method for fetching the complete set of installations associated with a given event.

If you need a full list of all the parties an event is visible to, you'll call the apps.event.authorizations.list method.

Google Cloud Function extension for Bolt

A new Bolt extension is available for Google Cloud Functions users. This module requires JDK 11+.

package functions;
import com.slack.api.bolt.App;

public class HelloSlack extends SlackApiFunction {
  private static final App app = new App();
  static {
    app.command("/hi", (req, ctx) -> {
      return ctx.ack("Hi from Google Cloud Functions!");
    });
  }
  public HelloSlack() { super(app); }
}

// gcloud functions deploy my-first-function \
// --entry-point functions.HelloSlack \
// --runtime java11 --trigger-http --memory 512MB --allow-unauthenticated \
// --set-env-vars SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN,SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET

Changes

  • [bolt] #569 #571 #574 Steps from Apps support - Thanks @seratch @misscoded
  • [bolt] #572 Add appId to Installer and Bot model classes - Thanks @mihristov @seratch
  • [bolt] #573 Improve the compatibility with Bolt for JS / Python - Thanks @seratch
  • [bolt] #577 Change the fallback behavior of Events API handlers to be compatible with Bolt JS/Python - Thanks @seratch
  • [bolt-google-cloud-functions] #498 #550 Add Google Cloud Functions support - Thanks @seratch
  • [bolt-helion] Upgrade Helidon SE version from 1.4 to 2.0 - Thanks @seratch
  • [slack-app-backend] #576 Add complete support for new Events API payload format - Thanks @seratch
  • [slack-api-client] #566 #568 Stop propagation of okhttp's exception message including header values - Thanks @AlexeiZenin @seratch
  • [slack-api-client] Add new fields to Audit Logs API response - Thanks @seratch
  • [slack-api-client] Upgrade okhttp version from 4.8 to 4.9 - Thanks @seratch
  • [*-kotlin-extensions] Upgrade Kotlin language version from 1.3 to 1.4 - Thanks @seratch

version 1.2.0-RC2

05 Oct 03:04
Compare
Choose a tag to compare
version 1.2.0-RC2 Pre-release
Pre-release

Changes

  • [bolt] #569 #571 #574 Steps from Apps support - Thanks @seratch @misscoded
  • [bolt] #572 Add appId to Installer and Bot model classes - Thanks @mihristov @seratch
  • [bolt] #573 Improve the compatibility with Bolt for JS / Python - Thanks @seratch
  • [bolt] #577 Change the fallback behavior of Events API handlers to be compatible with Bolt JS/Python - Thanks @seratch
  • [bolt-google-cloud-functions] #498 #550 Add Google Cloud Functions support - Thanks @seratch
  • [bolt-helion] Upgrade Helidon SE version from 1.4 to 2.0 - Thanks @seratch
  • [slack-app-backend] #576 Add complete support for new Events API payload format - Thanks @seratch
  • [slack-api-client] #566 #568 Stop propagation of okhttp's exception message including header values - Thanks @AlexeiZenin @seratch
  • [slack-api-client] Add new fields to Audit Logs API response - Thanks @seratch
  • [slack-api-client] Upgrade okhttp version from 4.8 to 4.9 - Thanks @seratch
  • [*-kotlin-extensions] Upgrade Kotlin language version from 1.3 to 1.4 - Thanks @seratch

version 1.2.0-RC1

01 Oct 08:05
Compare
Choose a tag to compare
version 1.2.0-RC1 Pre-release
Pre-release

Changes

  • [bolt] #569 #571 #574 Steps from Apps support - Thanks @seratch @misscoded
  • [bolt] #572 Add appId to Installer and Bot model classes - Thanks @mihristov @seratch
  • [bolt] #573 Improve the compatibility with Bolt for JS / Python - Thanks @seratch
  • [bolt-google-cloud-functions] #498 #550 Add Google Cloud Functions support - Thanks @seratch
  • [bolt-helion] Upgrade Helidon SE version from 1.4 to 2.0 - Thanks @seratch
  • [slack-api-client] #566 #568 Stop propagation of okhttp's exception message including header values - Thanks @AlexeiZenin @seratch
  • [slack-api-client] Add new fields to Audit Logs API response - Thanks @seratch
  • [slack-api-client] Upgrade okhttp version from 4.8 to 4.9 - Thanks @seratch
  • [*-kotlin-extensions] Upgrade Kotlin language version from 1.3 to 1.4 - Thanks @seratch

version 1.1.6

29 Sep 07:34
Compare
Choose a tag to compare

Changes

  • [slack-api-client] #566 #568 Stop propagation of okhttp's exception message including header values - Thanks @AlexeiZenin @seratch
  • [slack-api-client] Add new fields to Audit Logs API response - Thanks @seratch

version 1.1.5

18 Sep 02:14
Compare
Choose a tag to compare

Changes

  • [bolt] #560 #563 Correct cookie parsing logic to support all use cases - Thanks @nickmelis

version 1.1.4

11 Sep 02:30
Compare
Choose a tag to compare

Changes

  • [slack-api-client] #554 #553 Add new admin.conversations.* APIs - Thanks @seratch
  • [slack-app-backend] #539 Fix #538 by adding api_app_id to SlashCommandPayload - Thanks @seratch
  • [slack-api-client] #540 Fix a typo in ChatUnfurlRequest docs - Thanks @markrmullan
  • [slack-api-client] Update data classes/constants for Web APIs and Audit Logs API - Thanks @seratch
  • [slack-api-client] #556 Add original_connected_channel_id to entry.channel in Audit Logs response - Thanks @seratch

version 1.1.3

07 Aug 00:34
Compare
Choose a tag to compare

Changes

  • [slack-api-model] #533 #534 Fails to parse CallBlock when receiving a message including a call block - Thanks @seratch
  • [slack-api-client] #535 Bump the patch versions of okhttp, micronaut, s3 client - Thanks @seratch

version 1.1.2

04 Aug 09:52
Compare
Choose a tag to compare

Changes


version 1.1.1

28 Jul 03:43
Compare
Choose a tag to compare

Changes


version 1.1.0

14 Jul 05:12
27c0361
Compare
Choose a tag to compare

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.

Related issues/PRs: #500 #499

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.

Related issues/PRs: #502 #468

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