Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Agents & Assistant support #1372

Merged
merged 4 commits into from
Oct 17, 2024
Merged

Conversation

seratch
Copy link
Member

@seratch seratch commented Sep 17, 2024

This pull request adds the newly added assistant feature to bolt-java. Our teram is still working on the design, so some of the details may be adjusted before merging. See also: slackapi/bolt-python#1162

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);

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you agree to those rules.

@seratch seratch added enhancement M-T: A feature request for new functionality project:bolt labels Sep 17, 2024
@seratch seratch self-assigned this Sep 17, 2024
@seratch seratch added this to the 1.44.0 milestone Sep 17, 2024
@seratch seratch marked this pull request as draft September 17, 2024 05:04
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 34.98233% with 184 lines in your changes missing coverage. Please review.

Project coverage is 74.02%. Comparing base (e033580) to head (26ec2ed).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...m/slack/api/bolt/middleware/builtin/Assistant.java 45.09% 48 Missing and 8 partials ⚠️
...m/slack/api/bolt/context/builtin/EventContext.java 0.00% 45 Missing ⚠️
.../builtin/DefaultAssistantThreadContextService.java 37.50% 26 Missing and 4 partials ⚠️
...m/slack/api/bolt/request/builtin/EventRequest.java 52.94% 10 Missing and 6 partials ⚠️
...lack/api/methods/impl/AsyncMethodsRateLimiter.java 0.00% 12 Missing ⚠️
...om/slack/api/bolt/util/EventsApiPayloadParser.java 50.00% 3 Missing and 2 partials ⚠️
bolt/src/main/java/com/slack/api/bolt/App.java 50.00% 3 Missing and 1 partial ⚠️
...slack/api/methods/impl/AsyncMethodsClientImpl.java 0.00% 4 Missing ⚠️
...pi/bolt/middleware/builtin/IgnoringSelfEvents.java 66.66% 1 Missing and 1 partial ⚠️
...om/slack/api/audit/impl/AsyncAuditRateLimiter.java 0.00% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1372      +/-   ##
============================================
- Coverage     74.67%   74.02%   -0.66%     
- Complexity     4337     4378      +41     
============================================
  Files           473      476       +3     
  Lines         13509    13785     +276     
  Branches       1378     1421      +43     
============================================
+ Hits          10088    10204     +116     
- Misses         2611     2750     +139     
- Partials        810      831      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seratch seratch force-pushed the assistant-apps branch 3 times, most recently from 65353a5 to 819068d Compare September 20, 2024 01:11
@seratch seratch marked this pull request as ready for review September 20, 2024 01:35
@seratch seratch merged commit f65dc3d into slackapi:main Oct 17, 2024
6 checks passed
@seratch seratch deleted the assistant-apps branch October 17, 2024 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality project:bolt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant