An asychronous HTTP client wrapping Slack's RPC-style web api. Provides an extensible API with builder-style parameters and responses, allowing you to focus on your interactions with users, rather than your interactions with Slack. Notably, we:
NOTICE:
The original web API method for uploading files to Slack, files.upload
, is being sunset on March 11, 2025. See details
On October 18th 2019, Slack will stop supporting the replies
thread on a Message
returned from the conversations.replies
endpoint as well as any places that use LiteMessage
.
Due to this, we are deprecating getReplies()
on LiteMessage
It will return the data as long as Slack still returns it, bue when they stop, we will just return an empty array.
More context in the April 2019 changelog
You can continue to use an older version of this client until October 18th, at which time you'll need to upgrade to the latest.
Like most APIs, deprecations and modifications that we'll call "breaking changes" will occur on Slack's web API. General guidelines on detecting and handling "breaking changes" can be found here
We currently support:
We happily welcome any PRs for APIs that haven't yet been implemented!
To use with Maven-based projects, add the following dependencies::
<dependency>
<groupId>com.hubspot.slack</groupId>
<artifactId>slack-base</artifactId>
<version>{latest version}</version>
</dependency>
<dependency>
<groupId>com.hubspot.slack</groupId>
<artifactId>slack-java-client</artifactId>
<version>{latest version}</version>
</dependency>
Latest version can be seen here, on Maven central.
Install the SlackClientModule
in the Guice module you want to use to talk to slack.
public class MyFancyModule extends AbstractModule {
@Override
protected void configure() {
install(new SlackClientModule());
}
}
Finally inject the factory where you want to build the client:
public class MySlacker {
private final SlackClient slackClient;
public MySlacker(
SlackWebClient.Factory clientFactory
) {
this.slackClient = clientFactory.build(
SlackClientRuntimeConfig.builder()
.setTokenSupplier(() -> "your token here")
// ... all your configuration here
.build()
);
}
// then just use the client!
}
If you're not familiar with Java 8's CompletableFuture
API, know that you can transform this client from an asynchronous one to a synchronous one by calling join
on any of the futures returned. To simplify getting started, we've included an example module with some common tasks to give you a feel for how you can interact with the client.
Copyright 2018 HubSpot, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.