Java Client to Slack's Webhook feature.
For Maven,
<dependency> <groupId>in.ashwanthkumar</groupId> <artifactId>slack-java-webhook</artifactId> <version>${slack-java-webhook.version}</version> </dependency>
For SBT,
libraryDependencies += "in.ashwanthkumar" % "slack-java-webhook" % scalaJavaWebhookVersion
Latest version of slack-java-webhook is
// Using SlackMessage new Slack(webhookUrl) .icon(":smiling_imp:") // Ref - http://www.emoji-cheat-sheet.com/ .sendToUser("slackbot") .displayName("slack-java-client") .push(new SlackMessage("Text from my ").bold("Slack-Java-Client")); // Using SlackAttachment new Slack(webhookUrl) .sendToUser("slackbot") .displayName("slack-java-client") .push(new SlackAttachment("Text from my Slack-Java-Client").author("ashwanthkumar", "https://avatars0.githubusercontent.com/u/600279?v=3&s=40"));
With SlackMessage you can create rich text as specified in https://api.slack.com/docs/formatting. Example usage
new SlackMessage("Some text can be") .italic("Italic") .text(". :)")
Available methods on SlackMessage
textlinkbolditaliccodepreformattedquote
With SlackAttachment you can create much more sophisticated rich text as specified in https://api.slack.com/docs/attachments. Example usage
new SlackAttachment() .author("ashwanthkumar") .author("ashwanthkumar", "https://avatars0.githubusercontent.com/u/600279?v=3&s=40")
Available methods on SlackAttachment
fallbackcolorpreTextauthortitletextimageUrladdField