Skip to content

version 1.22.0

Compare
Choose a tag to compare
@seratch seratch released this 03 May 02:46
· 756 commits to main since this release

New Features

Message Metadata (Open Beta) Support

Message Metadata is a new feature in the Slack Platform, which enables developers to link a message inside Slack to a corresponding outside event or pattern.

With this Java SDK, you can post a message with metadata as below:

String token = System.getenv("SLACK_BOT_TOKEN");
MethodsClient client = Slack.getInstance().methods(token);
// Post a message with metadata

// You can set any type of data under the event_payload part
Map<String, Object> eventPayload = new HashMap<>();
eventPayload.put("procurement-id", "id-123");
eventPayload.put("amount", 1024);
eventPayload.put("tags", Arrays.asList("Procurement", "Engineering Division"));

// Build the metadata to attach to your app's message
Message.Metadata metadata = Message.Metadata.builder()
  .eventType("internal-procurement-approval")
  .eventPayload(eventPayload)
  .build();

// Post a channel message with the metadata
ChatPostMessageResponse resposne = client.chatPostMessage(req -> req
  .channel("#random")
  .text("Can you approve this procurement process request?")
  .metadata(metadata));

Once your app post a message with metadata, your app (and other apps too!) can access the message metadata by several ways:

If you go with the message_metadata_* events, please don't forget having the following settings in your App Manifest:

settings:
  event_subscriptions:
    request_url: https://{your domain}/slack/events
    bot_events:
      - message_metadata_deleted
      - message_metadata_posted
      - message_metadata_updated
    # Manually add this part in the App Manifest editor at https://api.slack.com/apps 
    metadata_subscriptions:
      - app_id: "*"
        event_type: internal-procurement-approval

Refer to the following test code and example for more details:

Changes

  • [slack-api-cljent] #980 #979 #968 Message metadata beta support - Thanks @seratch
  • [slack-api-client] #973 Upgrade tyrus 1.x to 1.18, lombok patch version, and optional ones - Thanks @seratch