Skip to content

Commit afc65c2

Browse files
zimegClaude
andcommitted
docs(methods): add agents.sessions method examples
Mirror the Python examples (slackapi/bolt-python-examples) for the two agents.sessions methods, nested under agents/sessions/ to match: - agents.sessions.rename Rename an agent session. - agents.sessions.setStatus Set an agent session's lifecycle status, creating the session if needed. Adds the two example classes, a per-family manifest (agent_view + the agent bot events), and an "agents" section in the methods README. Requires the agents.sessions methods in slack-api-client (adds via slackapi/java-slack-sdk#1633); the example pom stays pinned to the released SDK until that ships. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent 3d7135f commit afc65c2

4 files changed

Lines changed: 91 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 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques
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/main/java/agents/sessions/AgentsSessionsRename.java).
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/main/java/agents/sessions/AgentsSessionsSetStatus.java).
23+
1924
### chat
2025

2126
- **[chat.postMessage](https://docs.slack.dev/reference/methods/chat.postmessage)**: Sends a message to a channel. [Implementation](./src/main/java/chat/ChatPostMessage.java).
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package agents.sessions;
2+
3+
import com.slack.api.Slack;
4+
import com.slack.api.methods.MethodsClient;
5+
import com.slack.api.methods.SlackApiException;
6+
import com.slack.api.methods.request.agents.sessions.AgentsSessionsRenameRequest;
7+
import com.slack.api.methods.response.agents.sessions.AgentsSessionsRenameResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsSessionsRename {
11+
12+
public static void main(String[] args) throws IOException, SlackApiException {
13+
// Read a token from an environment variable
14+
String token = System.getenv("SLACK_TOKEN");
15+
16+
// Initialize
17+
MethodsClient methods = Slack.getInstance().methods(token);
18+
19+
// Call the agents.sessions.rename method
20+
AgentsSessionsRenameRequest request = AgentsSessionsRenameRequest.builder()
21+
.channelId("C123ABC456")
22+
.title("Fix flaky login test")
23+
.build();
24+
AgentsSessionsRenameResponse response = methods.agentsSessionsRename(request);
25+
26+
// Inspect the response
27+
System.out.println(response);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package agents.sessions;
2+
3+
import com.slack.api.Slack;
4+
import com.slack.api.methods.MethodsClient;
5+
import com.slack.api.methods.SlackApiException;
6+
import com.slack.api.methods.request.agents.sessions.AgentsSessionsSetStatusRequest;
7+
import com.slack.api.methods.response.agents.sessions.AgentsSessionsSetStatusResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsSessionsSetStatus {
11+
12+
public static void main(String[] args) throws IOException, SlackApiException {
13+
// Read a token from an environment variable
14+
String token = System.getenv("SLACK_TOKEN");
15+
16+
// Initialize
17+
MethodsClient methods = Slack.getInstance().methods(token);
18+
19+
// Call the agents.sessions.setStatus method
20+
AgentsSessionsSetStatusRequest request = AgentsSessionsSetStatusRequest.builder()
21+
.channelId("C123ABC456")
22+
.status("processing")
23+
.build();
24+
AgentsSessionsSetStatusResponse response = methods.agentsSessionsSetStatus(request);
25+
26+
// Inspect the response
27+
System.out.println(response);
28+
}
29+
}
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)