Skip to content

Commit d69ccce

Browse files
authored
feat(methods): add agents.sessions method examples (#201)
1 parent 4961f20 commit d69ccce

9 files changed

Lines changed: 85 additions & 0 deletions

File tree

‎methods/README.md‎

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

1717
## What's on call
1818

19+
### agents
20+
21+
- **[agents.sessions.rename](https://docs.slack.dev/reference/methods/agents.sessions.rename)**: Rename an agent session. [Implementation](./src/agents/sessions/agents_sessions_rename.py).
22+
- **[agents.sessions.setStatus](https://docs.slack.dev/reference/methods/agents.sessions.setStatus)**: Set an agent session's lifecycle status, creating the session if needed. [Implementation](./src/agents/sessions/agents_sessions_set_status.py).
23+
1924
### blocks
2025

2126
- **[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).

‎methods/src/agents/__init__.py‎

Whitespace-only changes.
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/agents/sessions/__init__.py‎

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 agents.sessions.rename method
12+
response = client.agents_sessions_rename(
13+
channel_id="C123ABC",
14+
thread_ts="1717171717.123456",
15+
title="Bora Bora trip prep",
16+
)
17+
18+
# Inspect the response
19+
print(response)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 agents.sessions.setStatus method
12+
response = client.agents_sessions_setStatus(
13+
channel_id="C123ABC",
14+
thread_ts="1717171717.123456",
15+
status="processing",
16+
title="Scuba diving research",
17+
)
18+
19+
# Inspect the response
20+
print(response)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"display_information": {
3+
"name": "Slack API Methods",
4+
"description": "Example implementations to call \"agents.sessions\" methods"
5+
},
6+
"features": {
7+
"bot_user": {
8+
"display_name": "Slack API Methods",
9+
"always_online": true
10+
},
11+
"agent_view": {
12+
"agent_description": "Example implementations to call \"agents.sessions\" methods"
13+
}
14+
},
15+
"oauth_config": {
16+
"scopes": {
17+
"bot": ["assistant:write", "chat:write", "im:history"]
18+
}
19+
},
20+
"settings": {
21+
"event_subscriptions": {
22+
"bot_events": ["agent_session_stopped", "app_home_opened", "message.im"]
23+
},
24+
"org_deploy_enabled": true,
25+
"socket_mode_enabled": true,
26+
"token_rotation_enabled": false
27+
}
28+
}

0 commit comments

Comments
 (0)