From c853031c87661f40517a027588477ed787e884cd Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Wed, 26 Aug 2026 09:48:14 -0700 Subject: [PATCH 1/4] feat(methods): add blocks.validate example Add a blocks method-family example that validates a Block Kit payload built with typed model classes (SectionBlock / PlainTextObject), mirroring the chat.postMessage example. blocks.validate is unauthenticated, so the client is created without a token. Co-Authored-By: Claude --- methods/README.md | 4 ++++ methods/src/blocks/.slack/.gitignore | 2 ++ methods/src/blocks/.slack/config.json | 6 ++++++ methods/src/blocks/.slack/hooks.json | 5 +++++ methods/src/blocks/__init__.py | 0 methods/src/blocks/blocks_validate.py | 13 +++++++++++++ methods/src/blocks/manifest.json | 22 ++++++++++++++++++++++ 7 files changed, 52 insertions(+) create mode 100644 methods/src/blocks/.slack/.gitignore create mode 100644 methods/src/blocks/.slack/config.json create mode 100644 methods/src/blocks/.slack/hooks.json create mode 100644 methods/src/blocks/__init__.py create mode 100644 methods/src/blocks/blocks_validate.py create mode 100644 methods/src/blocks/manifest.json diff --git a/methods/README.md b/methods/README.md index 299a2d5..6139ddc 100644 --- a/methods/README.md +++ b/methods/README.md @@ -16,6 +16,10 @@ $ slack run chat_post_message.py # Make the request ## What's on call +### blocks + +- **[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). + ### chat - **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/chat/chat_post_message.py). diff --git a/methods/src/blocks/.slack/.gitignore b/methods/src/blocks/.slack/.gitignore new file mode 100644 index 0000000..973ba60 --- /dev/null +++ b/methods/src/blocks/.slack/.gitignore @@ -0,0 +1,2 @@ +apps.dev.json +cache/ diff --git a/methods/src/blocks/.slack/config.json b/methods/src/blocks/.slack/config.json new file mode 100644 index 0000000..909afbe --- /dev/null +++ b/methods/src/blocks/.slack/config.json @@ -0,0 +1,6 @@ +{ + "manifest": { + "source": "local" + }, + "project_id": "00000000-0000-0000-0000-000000000000" +} diff --git a/methods/src/blocks/.slack/hooks.json b/methods/src/blocks/.slack/hooks.json new file mode 100644 index 0000000..ce474c9 --- /dev/null +++ b/methods/src/blocks/.slack/hooks.json @@ -0,0 +1,5 @@ +{ + "hooks": { + "get-hooks": "python3 -m slack_cli_hooks.hooks.get_hooks" + } +} diff --git a/methods/src/blocks/__init__.py b/methods/src/blocks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/methods/src/blocks/blocks_validate.py b/methods/src/blocks/blocks_validate.py new file mode 100644 index 0000000..2fec26e --- /dev/null +++ b/methods/src/blocks/blocks_validate.py @@ -0,0 +1,13 @@ +from slack_sdk import WebClient +from slack_sdk.models.blocks import PlainTextObject, SectionBlock + +# Initialize (blocks.validate is unauthenticated, so no token is needed) +client = WebClient() + +# Call the blocks.validate method +response = client.blocks_validate( + blocks=[SectionBlock(text=PlainTextObject(text="Hello world"))], +) + +# Inspect the response +print(response) diff --git a/methods/src/blocks/manifest.json b/methods/src/blocks/manifest.json new file mode 100644 index 0000000..1f9aa3c --- /dev/null +++ b/methods/src/blocks/manifest.json @@ -0,0 +1,22 @@ +{ + "display_information": { + "name": "Slack API Methods", + "description": "Example implementations to call \"blocks\" methods" + }, + "features": { + "bot_user": { + "display_name": "Slack API Methods", + "always_online": true + } + }, + "oauth_config": { + "scopes": { + "bot": ["chat:write"] + } + }, + "settings": { + "org_deploy_enabled": true, + "socket_mode_enabled": false, + "token_rotation_enabled": false + } +} From 3d4896589ef312826d5f2ea999a86acc3d08bb91 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Wed, 26 Aug 2026 10:16:28 -0700 Subject: [PATCH 2/4] chore(methods): drop unused scopes from blocks example manifest blocks.validate is unauthenticated, so the example app needs no bot scopes or bot user. Co-Authored-By: Claude --- methods/src/blocks/manifest.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/methods/src/blocks/manifest.json b/methods/src/blocks/manifest.json index 1f9aa3c..3033aa0 100644 --- a/methods/src/blocks/manifest.json +++ b/methods/src/blocks/manifest.json @@ -3,15 +3,9 @@ "name": "Slack API Methods", "description": "Example implementations to call \"blocks\" methods" }, - "features": { - "bot_user": { - "display_name": "Slack API Methods", - "always_online": true - } - }, "oauth_config": { "scopes": { - "bot": ["chat:write"] + "bot": [] } }, "settings": { From 530ef3ef17a90351b723258406e8b74ee1732992 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Wed, 26 Aug 2026 10:21:54 -0700 Subject: [PATCH 3/4] style(methods): match chat example comment in blocks.validate example Co-Authored-By: Claude --- methods/src/blocks/blocks_validate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/methods/src/blocks/blocks_validate.py b/methods/src/blocks/blocks_validate.py index 2fec26e..5265f05 100644 --- a/methods/src/blocks/blocks_validate.py +++ b/methods/src/blocks/blocks_validate.py @@ -1,7 +1,7 @@ from slack_sdk import WebClient from slack_sdk.models.blocks import PlainTextObject, SectionBlock -# Initialize (blocks.validate is unauthenticated, so no token is needed) +# Initialize client = WebClient() # Call the blocks.validate method From b47c530d36746c80d433909fa6c320ef1e2106b3 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Thu, 27 Aug 2026 00:59:43 -0700 Subject: [PATCH 4/4] style(methods): multiline the blocks list in the blocks.validate example Expand blocks=[...] one entry per line (magic trailing comma) so the list-of-blocks shape reads clearly and scales when a reader adds another block. Co-Authored-By: Claude --- methods/src/blocks/blocks_validate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/methods/src/blocks/blocks_validate.py b/methods/src/blocks/blocks_validate.py index 5265f05..58677d6 100644 --- a/methods/src/blocks/blocks_validate.py +++ b/methods/src/blocks/blocks_validate.py @@ -6,7 +6,9 @@ # Call the blocks.validate method response = client.blocks_validate( - blocks=[SectionBlock(text=PlainTextObject(text="Hello world"))], + blocks=[ + SectionBlock(text=PlainTextObject(text="Hello world")), + ], ) # Inspect the response