Skip to content

Commit b86b328

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

7 files changed

Lines changed: 114 additions & 0 deletions

File tree

‎methods/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ $ slack run chat_post_message.py # Make the request
5454

5555
- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/chat/chat_post_message.py).
5656

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

5963
- **[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/slackbot/skills/slackbot_skills_create.py).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
apps.dev.json
2+
cache/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"manifest": {
3+
"source": "local"
4+
},
5+
"project_id": "00000000-0000-0000-0000-000000000000"
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"get-hooks": "python3 -m slack_cli_hooks.hooks.get_hooks"
4+
}
5+
}

‎methods/src/entity/__init__.py‎

Whitespace-only changes.
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)

‎methods/src/entity/manifest.json‎

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)