Skip to content

version 1.44.0

Latest
Compare
Choose a tag to compare
@seratch seratch released this 17 Oct 05:13
· 2 commits to main since this release

New Features

Agents & Assistants

A better Agents & Assistants support in Bolt is now available!

While you already can implement your agents using app.event(...) listeners for assistant_thread_started, assistant_thread_context_changed, and message events, Bolt offers a simpler approach. You just need to create an Assistant instance, attach the needed event handlers to it, and then add the assistant to your App instance.

App app = new App();
Assistant assistant = new Assistant(app.executorService());

assistant.threadStarted((req, ctx) -> {
  try {
    ctx.say(r -> r.text("Hi, how can I help you today?"));
    ctx.setSuggestedPrompts(Collections.singletonList(
      SuggestedPrompt.create("What does SLACK stand for?")
    ));
  } catch (Exception e) {
    ctx.logger.error("Failed to handle assistant thread started event: {e}", e);
  }
});

assistant.userMessage((req, ctx) -> {
  try {
    ctx.setStatus("is typing...");
    Thread.sleep(500L);
    if (ctx.getThreadContext() != null) {
      String contextChannel = ctx.getThreadContext().getChannelId();
      ctx.say(r -> r.text("I am ware of the channel context: <#" + contextChannel + ">"));
    } else {
      ctx.say(r -> r.text("Here you are!"));
    }
  } catch (Exception e) {
    ctx.logger.error("Failed to handle assistant thread started event: {e}", e);
    try {
      ctx.say(r -> r.text(":warning: Sorry, something went wrong during processing your request!"));
    } catch (Exception ee) {
      ctx.logger.error("Failed to inform the error to the end-user: {ee}", ee);
    }
  }
});

app.assistant(assistant);

Please refer to https://tools.slack.dev/java-slack-sdk/guides/assistants for more details.

Changes

  • [bolt] #1372 #1383 Add Agents & Assistants document page - Thanks @seratch
  • [bolt] #1388 Fix #1348 channel_convert_to_public message events - Thanks @seratch @mgroth0
  • [bolt] #1380 Remove extra double quotes from the "Add to Slack" OAuth image alt text - Thanks @zimeg
  • [slack-api-client] #1382 Add conversations.requestSharedInvite.list API support - Thanks @seratch
  • [slack-api-client] #1376 Add RichTextBlock support to Block Kit Kotlin DSL builder - Thanks @KENNYSOFT