Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions methods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques

- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/main/java/chat/ChatPostMessage.java).

### entity

- **[entity.presentComments](https://docs.slack.dev/reference/methods/entity.presentComments)**: Provide comments for Work Objects. Apps call this method to send per-user flexpane comment data to the client. [Implementation](./src/main/java/entity/EntityPresentComments.java).

### slackbot

- **[slackbot.skills.create](https://docs.slack.dev/reference/methods/slackbot.skills.create)**: Creates a skill from markdown instructions, or turns an existing canvas the caller owns into a skill. [Implementation](./src/main/java/slackbot/skills/SlackbotSkillsCreate.java).
Expand Down
89 changes: 89 additions & 0 deletions methods/src/main/java/entity/EntityPresentComments.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package entity;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.entity.EntityPresentCommentsRequest;

Check failure on line 6 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol
import com.slack.api.methods.response.entity.EntityPresentCommentsResponse;

Check failure on line 7 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol
import com.slack.api.model.EntityComment;

Check failure on line 8 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol
import com.slack.api.model.EntityMetadata;
import com.slack.api.model.block.RichTextBlock;
import com.slack.api.model.block.element.RichTextSectionElement;
import java.io.IOException;
import java.util.Arrays;

public class EntityPresentComments {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the entity.presentComments method
EntityPresentCommentsRequest request = EntityPresentCommentsRequest.builder()

Check failure on line 25 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol

Check failure on line 25 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol
.comments(Arrays.asList(
EntityComment.builder()

Check failure on line 27 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol
.sender(EntityMetadata.EntityPayload.User.builder()
.userId("U123456789")
.build())
.timestamp(1741164235)
.id("comment-unique-identifier-001")
.url("your.app/item/1/comment/1")
.canEdit(true)
.canDelete(true)
.canReply(true)
.replyCount(2)
.replyUsers(Arrays.asList(
EntityMetadata.EntityPayload.User.builder()
.userId("U234567890")
.build(),
EntityMetadata.EntityPayload.User.builder()
.text("External User")
.icon(EntityMetadata.EntityPayload.Icon.builder()
.url("...")
.build())
.build()))
.latestReplyTs(1741165000)
.lastEditTs(1741164300)
.comment(EntityComment.Content.builder()

Check failure on line 50 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

package EntityComment does not exist
.blocks(RichTextBlock.builder()
.elements(Arrays.asList(RichTextSectionElement.builder()
.elements(Arrays.asList(RichTextSectionElement.Text.builder()
.text(
"Check out these different block types with paragraph breaks between them:\n\n")
.build()))
.build()))
.build())
.build())
.build(),
EntityComment.builder()

Check failure on line 61 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol
.sender(EntityMetadata.EntityPayload.User.builder()
.text("UserFirstName UserLastName")
.icon(EntityMetadata.EntityPayload.Icon.builder()
.altText("Summary of image's content")
.url("...")
.build())
.url("your.app/user/userId")
.email("firstname.lastname@domain.com")
.build())
.timestamp(1741164358)
.id("comment-unique-identifier-002")
.url("your.app/item/1/comment/2")
.threadRootId("comment-unique-identifier-001")
.comment(EntityComment.Content.builder()

Check failure on line 75 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

package EntityComment does not exist
.value("Plain text comment")
.format("markdown")
.build())
.build()))
.triggerId("1234567890123.1234567890123.abcdef01234567890abcdef012345689")
.canPostComment(true)
.deleteActionId("your-delete-action-id")
.build();
EntityPresentCommentsResponse response = methods.entityPresentComments(request);

Check failure on line 84 in methods/src/main/java/entity/EntityPresentComments.java

View workflow job for this annotation

GitHub Actions / maven@java17 (methods)

cannot find symbol

// Inspect the response
System.out.println(response);
}
}
16 changes: 16 additions & 0 deletions methods/src/main/java/entity/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"display_information": {
"name": "Slack API Methods",
"description": "Example implementations to call \"entity\" methods"
},
"oauth_config": {
"scopes": {
"bot": []
}
},
"settings": {
"org_deploy_enabled": true,
"socket_mode_enabled": false,
"token_rotation_enabled": false
}
}
Loading