Skip to content
Draft
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
13 changes: 13 additions & 0 deletions methods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ $ slack run chat_post_message # Make the request
### chat

- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/chat/chat_post_message.py).

### codeChannels

- **[codeChannels.archive](https://docs.slack.dev/reference/methods/codeChannels.archive)**: Archives a code channel, optionally recording a summary message on the channel. [Implementation](./src/code_channels/code_channels_archive.py).
- **[codeChannels.create](https://docs.slack.dev/reference/methods/codeChannels.create)**: Creates a dedicated code channel for an agent session. [Implementation](./src/code_channels/code_channels_create.py).
- **[codeChannels.getCanvas](https://docs.slack.dev/reference/methods/codeChannels.getCanvas)**: Fetches a canvas attached to a code channel — full content plus comment threads — in a single round-trip. [Implementation](./src/code_channels/code_channels_get_canvas.py).
- **[codeChannels.listViews](https://docs.slack.dev/reference/methods/codeChannels.listViews)**: Lists the view tabs attached to a code channel. [Implementation](./src/code_channels/code_channels_list_views.py).
- **[codeChannels.removeView](https://docs.slack.dev/reference/methods/codeChannels.removeView)**: Removes a view from a code channel. [Implementation](./src/code_channels/code_channels_remove_view.py).
- **[codeChannels.rename](https://docs.slack.dev/reference/methods/codeChannels.rename)**: Renames a code channel. [Implementation](./src/code_channels/code_channels_rename.py).
- **[codeChannels.setCanvasContent](https://docs.slack.dev/reference/methods/codeChannels.setCanvasContent)**: Replaces the full markdown content of a canvas attached to a code channel, preserving the comment threads on the sections your agent didn't change. [Implementation](./src/code_channels/code_channels_set_canvas_content.py).
- **[codeChannels.setCommands](https://docs.slack.dev/reference/methods/codeChannels.setCommands)**: Registers the set of slash commands your agent offers in a code channel. [Implementation](./src/code_channels/code_channels_set_commands.py).
- **[codeChannels.setProperties](https://docs.slack.dev/reference/methods/codeChannels.setProperties)**: Sets properties on a code channel: context bar items and external resource details. [Implementation](./src/code_channels/code_channels_set_properties.py).
- **[codeChannels.setView](https://docs.slack.dev/reference/methods/codeChannels.setView)**: Creates or updates a view in a code channel. Views can render HTML, diffs, Block Kit, or canvases as tabs alongside the conversation. [Implementation](./src/code_channels/code_channels_set_view.py).
2 changes: 2 additions & 0 deletions methods/src/code_channels/.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/code_channels/.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/code_channels/.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.
18 changes: 18 additions & 0 deletions methods/src/code_channels/code_channels_archive.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 codeChannels.archive method
response = client.codeChannels_archive(
channel_id="C123ABC456",
summary_message_ts="1717171717.123456",
)

# Inspect the response
print(response)
19 changes: 19 additions & 0 deletions methods/src/code_channels/code_channels_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 codeChannels.create method
response = client.codeChannels_create(
name="Fix flaky login test",
origin_channel_id="C123ABC456",
origin_message_ts="1717171717.123456",
)

# Inspect the response
print(response)
18 changes: 18 additions & 0 deletions methods/src/code_channels/code_channels_get_canvas.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 codeChannels.getCanvas method
response = client.codeChannels_getCanvas(
channel_id="C123ABC456",
canvas_id="F123ABC456",
)

# Inspect the response
print(response)
17 changes: 17 additions & 0 deletions methods/src/code_channels/code_channels_list_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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 codeChannels.listViews method
response = client.codeChannels_listViews(
channel_id="C123ABC456",
)

# Inspect the response
print(response)
18 changes: 18 additions & 0 deletions methods/src/code_channels/code_channels_remove_view.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 codeChannels.removeView method
response = client.codeChannels_removeView(
channel_id="C123ABC456",
view_id="V123ABC456",
)

# Inspect the response
print(response)
18 changes: 18 additions & 0 deletions methods/src/code_channels/code_channels_rename.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 codeChannels.rename method
response = client.codeChannels_rename(
channel_id="C123ABC456",
name="Fix flaky login test v2",
)

# Inspect the response
print(response)
19 changes: 19 additions & 0 deletions methods/src/code_channels/code_channels_set_canvas_content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 codeChannels.setCanvasContent method
response = client.codeChannels_setCanvasContent(
channel_id="C123ABC456",
canvas_id="F123ABC456",
content="# Plan\n\n1. Reproduce the flaky test\n2. Fix the race\n3. Verify",
)

# Inspect the response
print(response)
27 changes: 27 additions & 0 deletions methods/src/code_channels/code_channels_set_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 codeChannels.setCommands method
response = client.codeChannels_setCommands(
channel_id="C123ABC456",
commands=[
{
"name": "test",
"description": "Run the test suite",
},
{
"name": "diff",
"description": "Show the current diff",
},
],
)

# Inspect the response
print(response)
27 changes: 27 additions & 0 deletions methods/src/code_channels/code_channels_set_properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 codeChannels.setProperties method
response = client.codeChannels_setProperties(
channel_id="C123ABC456",
code_channel={
"context_bar_items": [
{
"key": "repo",
"label": "acme/billing",
"icon": "folder",
"url": "https://github.com/acme/billing",
},
]
},
)

# Inspect the response
print(response)
21 changes: 21 additions & 0 deletions methods/src/code_channels/code_channels_set_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 codeChannels.setView method
response = client.codeChannels_setView(
channel_id="C123ABC456",
type="diff",
content="diff --git a/cron.py b/cron.py\n--- a/cron.py\n+++ b/cron.py\n@@ ...",
base_branch="main",
head_branch="agent/migrate-cron",
)

# Inspect the response
print(response)
25 changes: 25 additions & 0 deletions methods/src/code_channels/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"display_information": {
"name": "Slack API Methods",
"description": "Example implementations to call \"codeChannels\" methods"
},
"features": {
"bot_user": {
"display_name": "Slack API Methods",
"always_online": true
},
"code_channels": {
"enabled": true
}
},
"oauth_config": {
"scopes": {
"bot": ["code_channels:manage"]
}
},
"settings": {
"org_deploy_enabled": true,
"socket_mode_enabled": false,
"token_rotation_enabled": false
}
}
Loading