Skip to content

ashwanthkumar/slack-java-webhook

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

Build Status

slack-java-webhook

Java Client to Slack's Webhook feature.

Dependencies

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 scala-java-webhook on Maven Central

Usage

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

Notes

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

  • text
  • link
  • bold
  • italic
  • code
  • preformatted
  • quote

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

  • fallback
  • color
  • preText
  • author
  • title
  • text
  • imageUrl
  • addField

License

http://www.apache.org/licenses/LICENSE-2.0

About

Java Client to Slack's Webhook feature.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages