Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- "ai/slackbot-mcp-client/rich-responses/mcp-apps"
- "ai/slackbot-mcp-client/slack-identity"
- "block-kit"
- "methods"
steps:
- name: Checkout code
uses: actions/checkout@v7
Expand All @@ -29,5 +30,5 @@ jobs:
pip install -r requirements.txt
ruff check
ruff format --diff --check
mypy .
pytest -v
mypy ./**/*.py
if [ -d tests ]; then pytest -v; fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ This collections of examples highlights features of a Slack app in the language

- **[AI in Slack](./ai)**: Agent experiences and MCP features in an interactive conversation interface.
- **[Block Kit](./block-kit)**: The framework of visual components arranged to create app layouts.
- **[Methods](./methods)**: An interface for querying information from and enacting change in a Slack workspace.
5 changes: 5 additions & 0 deletions methods/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
.mypy_cache
.pytest_cache
.ruff_cache
.venv
21 changes: 21 additions & 0 deletions methods/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Methods

An interface for querying information from and enacting change in a Slack workspace.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤓 note: Most wording is gathered from docs upstream if found.


Read the [docs](https://docs.slack.dev/apis/web-api/) for explanations of concepts, or explore [reference](https://docs.slack.dev/reference/methods) pages for specific functionalities.

## Making a request

```sh
$ cd src/chat # Navigate to a method family
$ slack install --environment local # Create an app
$ vim chat_post_message.py # Edit arguments
$ export SLACK_TOKEN=xoxb-example # Set if unchanged
$ slack run chat_post_message # Make the request

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👁️‍🗨️ note: Hook detection might require a virtual environment here but let's follow up with these additions!

```

## What's on call

### chat

- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/chat/chat_post_message.py).
4 changes: 4 additions & 0 deletions methods/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mypy==2.3.0
ruff==0.15.21
slack-cli-hooks==0.3.0
slack_sdk==3.43.0
Empty file added methods/src/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions methods/src/chat/.slack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apps.dev.json
cache/
6 changes: 6 additions & 0 deletions methods/src/chat/.slack/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"manifest": {
"source": "local"
},
"project_id": "00000000-0000-0000-0000-000000000000"
}
5 changes: 5 additions & 0 deletions methods/src/chat/.slack/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"hooks": {
"get-hooks": "python3 -m slack_cli_hooks.hooks.get_hooks"
}
}
Empty file added methods/src/chat/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions methods/src/chat/chat_post_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from slack_sdk import WebClient

# Read a token from an environment variable
token = os.environ.get("SLACK_TOKEN")

# Initialize
client = WebClient(token=token)

# Call the chat.postMessage method
response = client.chat_postMessage(
channel="C123ABC456",
text="Here's a message for you",
)

# Inspect the response
print(response)
22 changes: 22 additions & 0 deletions methods/src/chat/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"display_information": {
"name": "Slack API Methods",
"description": "Example implementations to call \"chat\" methods"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗣️ note: We prefer method names in description to avoid character limits.

},
"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
}
}