Skip to content

Commit de6b710

Browse files
committed
feat(methods): add entity.presentComments method example
1 parent d51f1a7 commit de6b710

3 files changed

Lines changed: 109 additions & 0 deletions

File tree

‎methods/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques
5353

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

56+
### entity
57+
58+
- **[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).
59+
5660
### slackbot
5761

5862
- **[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).
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package entity;
2+
3+
import com.slack.api.Slack;
4+
import com.slack.api.methods.MethodsClient;
5+
import com.slack.api.methods.SlackApiException;
6+
import com.slack.api.methods.request.entity.EntityPresentCommentsRequest;
7+
import com.slack.api.methods.response.entity.EntityPresentCommentsResponse;
8+
import com.slack.api.model.EntityComment;
9+
import com.slack.api.model.EntityMetadata;
10+
import com.slack.api.model.block.RichTextBlock;
11+
import com.slack.api.model.block.element.RichTextSectionElement;
12+
import java.io.IOException;
13+
import java.util.Arrays;
14+
15+
public class EntityPresentComments {
16+
17+
public static void main(String[] args) throws IOException, SlackApiException {
18+
// Read a token from an environment variable
19+
String token = System.getenv("SLACK_TOKEN");
20+
21+
// Initialize
22+
MethodsClient methods = Slack.getInstance().methods(token);
23+
24+
// Call the entity.presentComments method
25+
EntityPresentCommentsRequest request = EntityPresentCommentsRequest.builder()
26+
.comments(Arrays.asList(
27+
EntityComment.builder()
28+
.sender(EntityMetadata.EntityPayload.User.builder()
29+
.userId("U123456789")
30+
.build())
31+
.timestamp(1741164235)
32+
.id("comment-unique-identifier-001")
33+
.url("your.app/item/1/comment/1")
34+
.canEdit(true)
35+
.canDelete(true)
36+
.canReply(true)
37+
.replyCount(2)
38+
.replyUsers(Arrays.asList(
39+
EntityMetadata.EntityPayload.User.builder()
40+
.userId("U234567890")
41+
.build(),
42+
EntityMetadata.EntityPayload.User.builder()
43+
.text("External User")
44+
.icon(EntityMetadata.EntityPayload.Icon.builder()
45+
.url("...")
46+
.build())
47+
.build()))
48+
.latestReplyTs(1741165000)
49+
.lastEditTs(1741164300)
50+
.comment(EntityComment.Content.builder()
51+
.blocks(RichTextBlock.builder()
52+
.elements(Arrays.asList(RichTextSectionElement.builder()
53+
.elements(Arrays.asList(RichTextSectionElement.Text.builder()
54+
.text(
55+
"Check out these different block types with paragraph breaks between them:\n\n")
56+
.build()))
57+
.build()))
58+
.build())
59+
.build())
60+
.build(),
61+
EntityComment.builder()
62+
.sender(EntityMetadata.EntityPayload.User.builder()
63+
.text("UserFirstName UserLastName")
64+
.icon(EntityMetadata.EntityPayload.Icon.builder()
65+
.altText("Summary of image's content")
66+
.url("...")
67+
.build())
68+
.url("your.app/user/userId")
69+
.email("firstname.lastname@domain.com")
70+
.build())
71+
.timestamp(1741164358)
72+
.id("comment-unique-identifier-002")
73+
.url("your.app/item/1/comment/2")
74+
.threadRootId("comment-unique-identifier-001")
75+
.comment(EntityComment.Content.builder()
76+
.value("Plain text comment")
77+
.format("markdown")
78+
.build())
79+
.build()))
80+
.triggerId("1234567890123.1234567890123.abcdef01234567890abcdef012345689")
81+
.canPostComment(true)
82+
.deleteActionId("your-delete-action-id")
83+
.build();
84+
EntityPresentCommentsResponse response = methods.entityPresentComments(request);
85+
86+
// Inspect the response
87+
System.out.println(response);
88+
}
89+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"display_information": {
3+
"name": "Slack API Methods",
4+
"description": "Example implementations to call \"entity\" methods"
5+
},
6+
"oauth_config": {
7+
"scopes": {
8+
"bot": []
9+
}
10+
},
11+
"settings": {
12+
"org_deploy_enabled": true,
13+
"socket_mode_enabled": false,
14+
"token_rotation_enabled": false
15+
}
16+
}

0 commit comments

Comments
 (0)