Skip to content

Commit 8195229

Browse files
zimegClaude
andcommitted
feat(methods): add entity.presentComments method example
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent 4e173ba commit 8195229

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

‎methods/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ $ slack run chat_post_message.py # Make the request
6666
### entity
6767

6868
- **[entity.acknowledgeCommentAction](https://docs.slack.dev/reference/methods/entity.acknowledgeCommentAction)**: Acknowledge a comment post, edit, or delete on a Work Object. Apps call this method to confirm they have processed a comment action. [Implementation](./src/entity/entity_acknowledge_comment_action.py).
69+
- **[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/entity/entity_present_comments.py).
6970

7071
### slackbot
7172

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the entity.presentComments method
12+
response = client.entity_presentComments(
13+
comments=[
14+
{
15+
"sender": {
16+
"user_id": "U123456789",
17+
},
18+
"timestamp": 1741164235,
19+
"id": "comment-unique-identifier-001",
20+
"url": "your.app/item/1/comment/1",
21+
"can_edit": True,
22+
"can_delete": True,
23+
"can_reply": True,
24+
"reply_count": 2,
25+
"reply_users": [
26+
{
27+
"user_id": "U234567890",
28+
},
29+
{
30+
"text": "External User",
31+
"icon": {
32+
"url": "...",
33+
},
34+
},
35+
],
36+
"latest_reply_ts": 1741165000,
37+
"last_edit_ts": 1741164300,
38+
"comment": {
39+
"blocks": {
40+
"type": "rich_text",
41+
"elements": [
42+
{
43+
"type": "rich_text_section",
44+
"elements": [
45+
{
46+
"type": "text",
47+
"text": "Check out these different block types with paragraph breaks between them:\n\n",
48+
},
49+
],
50+
},
51+
],
52+
},
53+
},
54+
},
55+
{
56+
"sender": {
57+
"text": "UserFirstName UserLastName",
58+
"icon": {
59+
"alt_text": "Summary of image's content",
60+
"url": "...",
61+
},
62+
"url": "your.app/user/userId",
63+
"email": "firstname.lastname@domain.com",
64+
},
65+
"timestamp": 1741164358,
66+
"id": "comment-unique-identifier-002",
67+
"url": "your.app/item/1/comment/2",
68+
"thread_root_id": "comment-unique-identifier-001",
69+
"comment": {
70+
"value": "Plain text comment",
71+
"format": "markdown",
72+
},
73+
},
74+
],
75+
trigger_id="1234567890123.1234567890123.abcdef01234567890abcdef012345689",
76+
can_post_comment=True,
77+
delete_action_id="your-delete-action-id",
78+
)
79+
80+
# Inspect the response
81+
print(response)

0 commit comments

Comments
 (0)