|
| 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