Skip to content

Commit b6e6406

Browse files
zimegClaude
andauthored
feat(methods): add canvases.create and canvases.getContent examples (#336)
Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
1 parent aeee741 commit b6e6406

8 files changed

Lines changed: 79 additions & 0 deletions

File tree

‎methods/README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ $ slack run chat_post_message.py # Make the request
3434

3535
- **[blocks.validate](https://docs.slack.dev/reference/methods/blocks.validate)**: Validates blocks, messages, and views Block Kit JSON payloads. [Implementation](./src/blocks/blocks_validate.py).
3636

37+
### canvases
38+
39+
- **[canvases.create](https://docs.slack.dev/reference/methods/canvases.create)**: Create canvas for a user. [Implementation](./src/canvases/canvases_create.py).
40+
- **[canvases.getContent](https://docs.slack.dev/reference/methods/canvases.getContent)**: Get the content of a canvas as markdown (default) or HTML. [Implementation](./src/canvases/canvases_get_content.py).
41+
3742
### chat
3843

3944
- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/chat/chat_post_message.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/canvases/__init__.py‎

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 canvases.create method
12+
response = client.canvases_create(
13+
title="Your Brilliant Title",
14+
document_content={
15+
"type": "markdown",
16+
"markdown": "> standalone canvas!",
17+
},
18+
)
19+
20+
# Inspect the response
21+
print(response)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 canvases.getContent method
12+
response = client.canvases_getContent(
13+
canvas_id="F1234ABCD",
14+
content_type="markdown",
15+
)
16+
17+
# Inspect the response
18+
print(response)

‎methods/src/canvases/manifest.json‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"display_information": {
3+
"name": "Slack API Methods",
4+
"description": "Example implementations to call \"canvases\" methods"
5+
},
6+
"features": {
7+
"bot_user": {
8+
"display_name": "Slack API Methods",
9+
"always_online": true
10+
}
11+
},
12+
"oauth_config": {
13+
"scopes": {
14+
"bot": ["canvases:read", "canvases:write"]
15+
}
16+
},
17+
"settings": {
18+
"org_deploy_enabled": true,
19+
"socket_mode_enabled": false,
20+
"token_rotation_enabled": false
21+
}
22+
}

0 commit comments

Comments
 (0)