Repository navigation
Expand file tree
/
Copy pathEntityPresentComments.java
More file actions
89 lines (83 loc) · 4.9 KB
/
Copy pathEntityPresentComments.java
File metadata and controls
89 lines (83 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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;
import com.slack.api.methods.response.entity.EntityPresentCommentsResponse;
import com.slack.api.model.EntityComment;
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()
.comments(Arrays.asList(
EntityComment.builder()
.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()
.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()
.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()
.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);
// Inspect the response
System.out.println(response);
}
}