Skip to content

Commit 602f065

Browse files
authored
feat(methods): add chat.postMessage example (#132)
1 parent 92c5e75 commit 602f065

12 files changed

Lines changed: 87 additions & 2 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- "ai/slackbot-mcp-client/rich-responses/mcp-apps"
1717
- "ai/slackbot-mcp-client/slack-identity"
1818
- "block-kit"
19+
- "methods"
1920
steps:
2021
- name: Checkout code
2122
uses: actions/checkout@v7
@@ -29,5 +30,5 @@ jobs:
2930
pip install -r requirements.txt
3031
ruff check
3132
ruff format --diff --check
32-
mypy .
33-
pytest -v
33+
mypy ./**/*.py
34+
if [ -d tests ]; then pytest -v; fi

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ This collections of examples highlights features of a Slack app in the language
66

77
- **[AI in Slack](./ai)**: Agent experiences and MCP features in an interactive conversation interface.
88
- **[Block Kit](./block-kit)**: The framework of visual components arranged to create app layouts.
9+
- **[Methods](./methods)**: An interface for querying information from and enacting change in a Slack workspace.

‎methods/.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__pycache__
2+
.mypy_cache
3+
.pytest_cache
4+
.ruff_cache
5+
.venv

‎methods/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Methods
2+
3+
An interface for querying information from and enacting change in a Slack workspace.
4+
5+
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.
6+
7+
## Making a request
8+
9+
```sh
10+
$ cd src/chat # Navigate to a method family
11+
$ slack install --environment local # Create an app
12+
$ vim chat_post_message.py # Edit arguments
13+
$ export SLACK_TOKEN=xoxb-example # Set if unchanged
14+
$ slack run chat_post_message # Make the request
15+
```
16+
17+
## What's on call
18+
19+
### chat
20+
21+
- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/chat/chat_post_message.py).

‎methods/requirements.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mypy==2.3.0
2+
ruff==0.15.21
3+
slack-cli-hooks==0.3.0
4+
slack_sdk==3.43.0

‎methods/src/__init__.py‎

Whitespace-only changes.

‎methods/src/chat/.slack/.gitignore‎

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

‎methods/src/chat/.slack/hooks.json‎

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/chat/__init__.py‎

Whitespace-only changes.

0 commit comments

Comments
 (0)