{"id":13908036,"url":"https://github.com/palantir/roboslack","last_synced_at":"2025-05-07T07:32:34.042Z","repository":{"id":53018515,"uuid":"94377975","full_name":"palantir/roboslack","owner":"palantir","description":"A pluggable, fluent, straightforward Java library for interacting with Slack.","archived":false,"fork":false,"pushed_at":"2024-06-03T16:33:14.000Z","size":337,"stargazers_count":39,"open_issues_count":6,"forks_count":11,"subscribers_count":208,"default_branch":"develop","last_synced_at":"2024-08-06T23:39:11.321Z","etag":null,"topics":["api","fluent-interface","java","octo-correct-managed","slack","slack-webhook","slackapi"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/palantir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-14T22:27:22.000Z","updated_at":"2024-07-17T10:19:18.000Z","dependencies_parsed_at":"2022-09-08T10:24:34.098Z","dependency_job_id":null,"html_url":"https://github.com/palantir/roboslack","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Froboslack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Froboslack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Froboslack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/palantir%2Froboslack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/palantir","download_url":"https://codeload.github.com/palantir/roboslack/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224573430,"owners_count":17333807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","fluent-interface","java","octo-correct-managed","slack","slack-webhook","slackapi"],"created_at":"2024-08-06T23:02:25.662Z","updated_at":"2024-11-14T05:37:41.156Z","avatar_url":"https://github.com/palantir.png","language":"Java","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"RoboSlack\n=========\n[![CircleCI](https://circleci.com/gh/palantir/roboslack/tree/master.svg?style=shield)](https://circleci.com/gh/palantir/roboslack/tree/master)\n[![Download](https://api.bintray.com/packages/palantir/releases/roboslack/images/download.svg)](https://bintray.com/palantir/releases/roboslack/_latestVersion)\n\n\nRoboSlack is a Java 8 API which handles all aspects of authenticating and sending messages to Slack as an incoming webhook\n service. RoboSlack features a fully-articulated Java API that allows consumers to easily create rich Slack messages \n with features including:\n\n1. Text with Slack Markdown features (bold, italic, lists, quotes, emojis, Slack dates)\n2. Links\n3. Attachments\n4. Pictures, Icons, Thumbnails\n5. Titles, authors, footers\n6. Notifications, including: `!channel`, `!here`, `@users`, `#channel`\n\nIt also handles Slack authentication tokens and can perform synchronous message posting requests with basic error handling.\n\nAt this time, RoboSlack does not support core Slack API features like buttons and other interactive items within Slack messages.\n\nCore libraries:\n\n- **roboslack-webhook**: Implementation of the [Incoming Webhooks] functionality via the `SlackWebHookService`\n\nAuxiliary libraries:\n- **roboslack-api**: Data structures for creating and sending messages\n- **roboslack-webhook-api**: Data structures and service interfaces for using [Incoming Webhooks]\n\nSetup\n-----\n\nArtifacts are published to Bintray, the following is an example gradle dependency configuration:\n\n```\nrepositories {\n    maven { url  \"http://palantir.bintray.com/releases\" }\n}\n\ndependencies {\n    compile \"com.palantir.roboslack:roboslack-webhook:${version}\"\n}\n```\n\nroboslack-webhook\n-----------------\n\nProvides a mechanism to send messages through the use of a `WebHookToken`.\n\n### Setting up a `WebHookToken`\n\n1. As an administrator for your Slack team, visit the [Incoming Webhook] application page\n2. Select the **Post to Channel** channel that you wish to use\n    1. **NOTE** that RoboSlack will allow you to post\nto any channel, but the **Post to Channel** option will be the default channel the web hook client (ie. RoboSlack) posts to if no channel is specified\n3.  Click **Add Incoming WebHooks integration**\n4.  Copy the **Webhook URL** into a safe place\n\n### Using a `WebHookToken`\n\nThe **Incoming Webhook URL** should look something like the following:\n```\n// (where each `?` represents one alphanumeric character)\nhttps://hooks.slack.com/services/T????????/B????????/????????????????????????\n```\n\nThe `WebHookToken` refers to the composition of the three path parts at the end of the WebHook URL (ie `T12345678/B12345678/123456789012345678901234`). A `WebHookToken` can be instantiated in several ways:\n```\n// Builder\nWebHookToken token = WebHookToken.builder()\n                    .partT(\"T12345678\")\n                    .partB(\"B12345678\")\n                    .partX(\"123456789012345678901234\")\n                    .build();\n// Static factory\nWebHookToken token = WebHookToken.fromString(\"T12345678/B12345678/123456789012345678901234\");\n// Static factory with URL\nWebHookToken token = WebHookToken.fromString(\"https://hooks.slack.com/services/T12345678/B12345678/123456789012345678901234\");\n// Or from system environment variables:\n//      ROBOSLACK_TOKEN_TPART\n//      ROBOSLACK_TOKEN_BPART\n//      ROBOSLACK_TOKEN_XPART\nWebHookToken token = WebHookToken.fromEnvironment();\n```\n\n### Sending Messages\n\nCreate a `MessageRequest` via the builder pattern:\n```\n// Simple example\nMessageRequest message = MessageRequest.builder()\n                .username(\"roboslack\")\n                \n                // SlackMarkdown string decoration is handled automatically in fields that require it,\n                // so this is valid:\n                .iconEmoji(SlackMarkdown.EMOJI.decorate(\"smile\"))\n                // and passing in the raw decorated string is valid:\n                .iconEmoji(\":smile:\")\n                // or lastly, just pass the undecorated string (also valid):\n                .iconEmoji(\"smile\")\n                \n                .text(\"The simplest message\")\n                .build();\n```\n\nNext, send your message using the `SlackWebHookService` and receive the result:\n\n```\nResponseCode response = SlackWebHookService.with(token)\n                        .sendMessage(message);\n```\n\nRoboSlack handles error responses through the ``ResponseCode`` class. Check your ``ResponseCode`` to see why a message\nmay have failed to send.\n\n#### Slack Date Formatting\n\nRoboSlack supports Slack's Date formatting in fields that allow Slack Markdown. \n\u003e See [\"Formatting Dates\" section in the Slack Docs](https://api.slack.com/docs/message-formatting) for more information.\n\nThe main advantage of the `SlackDateTime` format over simply formatting a [`Temporal`](https://docs.oracle.com/javase/8/docs/api/java/time/temporal/Temporal.html) into a [`String`](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html) and sending that within the Slack message is that the `SlackDateTime` renders differently based on where and when the client is viewing it.  **For example, if the client views a `SlackDateTime` with Date granularity (that represents a point in time at the same day of the client) Slack will render it as`today`, but when they view the same message again the following day, Slack will render the message as `yesterday` instead.**. \n\nAny [`Temporal`](https://docs.oracle.com/javase/8/docs/api/java/time/temporal/Temporal.html) object alone doesn't have this dynamic advantage, and also\ndon't respect clients' timezones as easily as the `SlackDateTime` will.  **If a client crosses a timezone and views a \n`SlackDateTime` again, it will be rendered according to their new location's timezone.**\n\n##### Usage\n\n```\n// Assuming you have some Temporal object (for example a ZonedDateTime)\nZonedDateTime now = ZonedDateTime.now();\n\n// Create a new SlackDateTime for that Temporal\nSlackDateTime slackDateTime = SlackDateTime.of(now);\n\n// Then create a formatter for it using DateTimeFormatTokens\nSlackDateTimeFormatter formatter = SlackDateTimeFormatter.of(\"sent {date} at {time}\");\n\n// Finally create a message containing the SlackDateTime\nMessageRequest message = MessageRequest.builder()\n                .username(\"roboslack\")\n                .text(String.format(\"This is a message with a SlackDateTime: %s\",\n                    formatter.format(slackDateTime)))\n                .build();\n// Which would dynamically render to (when read on a client at the same day):\n//  This is a message with a SlackDateTime: sent today at 12:23PM\n```\n\nUsing the `SlackDateTime.of()` method, input a [`Temporal`](https://docs.oracle.com/javase/8/docs/api/java/time/temporal/Temporal.html) (and optionally a hyperlink reference for the generated text).  Be sure to use a `Temporal` that contains all of the necessary Time/Date fields for proper rendering \naccording to this table:\n\n\n|`DateTimeFormatToken`        | Format | Description                                                                           | Valid `Temporal` types to use                                                         |\n|----------------------------------|--------------------------|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|\n| `{date}`                             | `MMMMM dd, yyyy`           | Long month name, day with ordinal, and year                                           | `Instant`, `*Date`, `*DateTime` (ie. `OffsetDate` or `ZonedDateTime`)|\n| `{date_num}`                         | `yyyy-mm-dd`             | All numbers, with leading zeroes                                                      | `Instant`, `*Date`, `*DateTime` (ie. `OffsetDate` or `ZonedDateTime`)|\n| `{date_short}`                       | `MMM dd, yyyy`            | Short month name, day (no ordinal), and year                                          | `Instant`, `*Date`, `*DateTime` (ie. `OffsetDate` or `ZonedDateTime`)|\n| `{date_long}`                        | `eeee, MMMM dd, yyyy`     | Day of week, long month name, day with ordinal, and year                              | `Instant`, `*Date`, `*DateTime` (ie. `OffsetDate` or `ZonedDateTime`)|\n| `{date_pretty}`                      | `MMMM dd, yyyy`           | Like `DATE` but uses `yesterday`, `today`, `tomorrow` when appropriate                | `Instant`, `*Date`, `*DateTime` (ie. `OffsetDate` or `ZonedDateTime`)|\n| `{date_short_pretty}`                | `MMM dd, yyyy`             | Like `DATE_SHORT` but uses `yesterday`, `today`, `tomorrow` when appropriate          | `Instant`, `*Date`, `*DateTime` (ie. `OffsetDate` or `ZonedDateTime`)|\n| `{date_long_pretty}`                 | `eeee, MMMMM dd, yyyy`     | Like `DATE_LONG` but uses `yesterday`, `today`, `tomorrow` when appropriate           | `Instant`, `*Date`, `*DateTime` (ie. `OffsetDate` or `ZonedDateTime`)|\n| `{time}`                             | `kk:mm`                   | 12/24 hour : minute, AM/PM if client configured for 12-hour time                      | `Instant`, `*Time` (ie. `LocalTime`)                           |\n| `{time_secs}`                        | `kk:mm:ss`               | 12/24 hour : minute : second, AM/PM if client configured for 12-hour time             | `Instant`, `*Time` (ie. `LocalTime`)                           |\n\nFor more information, see the [Java DateTime API Pages].\nUse any combination of these `DateTimeFormatTokens` to display the Date or Time as needed.\n\nIf you supply a `Temporal` that doesn't support all of the required  for your `DateTimeFormatToken`, or that isn't\nconvertible to an Epoch Timestamp as Slack requires, RoboSlack will throw an `IllegalArgumentException` and won't proceed\nwith parsing your message.\n\nDevelopment\n-----------\n\nLooking to build upon RoboSlack?  Come join us in our [RoboSlack Slack Channel]!\n\nLicense\n-------\nThis project is made available under the [Apache 2.0 License].\n\n[Incoming Webhooks]: https://api.slack.com/incoming-webhooks\n[Incoming Webhook]: https://my.slack.com/services/new/incoming-webhook/\n\n[Java DateTime API Pages]: http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html\n\n[RoboSlack Slack Channel]: https://robo-slack.slack.com\n\n[Apache 2.0 License]: http://www.apache.org/licenses/LICENSE-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalantir%2Froboslack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpalantir%2Froboslack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpalantir%2Froboslack/lists"}