Skip to content

Commit 5f23a60

Browse files
authored
feat(methods): add agents.conversations.* method examples (#87)
1 parent c4dac96 commit 5f23a60

11 files changed

Lines changed: 348 additions & 0 deletions

‎methods/README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques
1818

1919
### agents
2020

21+
- **[agents.conversations.archive](https://docs.slack.dev/reference/methods/agents.conversations.archive)**: Archive a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsArchive.java).
22+
- **[agents.conversations.create](https://docs.slack.dev/reference/methods/agents.conversations.create)**: Create a dedicated code channel for an agent session. [Implementation](./src/main/java/agents/conversations/AgentsConversationsCreate.java).
23+
- **[agents.conversations.getCanvas](https://docs.slack.dev/reference/methods/agents.conversations.getCanvas)**: Fetch a canvas attached to a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsGetCanvas.java).
24+
- **[agents.conversations.listViews](https://docs.slack.dev/reference/methods/agents.conversations.listViews)**: List the views currently attached to a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsListViews.java).
25+
- **[agents.conversations.removeView](https://docs.slack.dev/reference/methods/agents.conversations.removeView)**: Remove a view from a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsRemoveView.java).
26+
- **[agents.conversations.setCanvasContent](https://docs.slack.dev/reference/methods/agents.conversations.setCanvasContent)**: Replace the full markdown content of a plan canvas attached to a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsSetCanvasContent.java).
27+
- **[agents.conversations.setCommands](https://docs.slack.dev/reference/methods/agents.conversations.setCommands)**: Register the set of agent-defined slash commands for the calling agent in a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsSetCommands.java).
28+
- **[agents.conversations.setProperties](https://docs.slack.dev/reference/methods/agents.conversations.setProperties)**: Set properties on a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsSetProperties.java).
29+
- **[agents.conversations.setView](https://docs.slack.dev/reference/methods/agents.conversations.setView)**: Create or update a view in a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsSetView.java).
2130
- **[agents.sessions.rename](https://docs.slack.dev/reference/methods/agents.sessions.rename)**: Rename an agent session. [Implementation](./src/main/java/agents/sessions/AgentsSessionsRename.java).
2231
- **[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).
2332

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsArchiveRequest;
7+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsArchiveResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsConversationsArchive {
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.conversations.archive method
20+
AgentsConversationsArchiveRequest request = AgentsConversationsArchiveRequest.builder()
21+
.channelId("C9876543210")
22+
.summaryMessageTs("1717182000.456789")
23+
.build();
24+
AgentsConversationsArchiveResponse response = methods.agentsConversationsArchive(request);
25+
26+
// Inspect the response
27+
System.out.println(response);
28+
}
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsCreateRequest;
7+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsCreateResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsConversationsCreate {
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.conversations.create method
20+
AgentsConversationsCreateRequest request = AgentsConversationsCreateRequest.builder()
21+
.name("Migrate billing cron to Temporal")
22+
.sessionId("ses_8675309")
23+
.originChannelId("C0123456789")
24+
.originMessageTs("1717171717.123456")
25+
.build();
26+
AgentsConversationsCreateResponse response = methods.agentsConversationsCreate(request);
27+
28+
// Inspect the response
29+
System.out.println(response);
30+
}
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsGetCanvasRequest;
7+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsGetCanvasResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsConversationsGetCanvas {
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.conversations.getCanvas method
20+
AgentsConversationsGetCanvasRequest request = AgentsConversationsGetCanvasRequest.builder()
21+
.channel("C9876543210")
22+
.canvasId("F1234567890")
23+
.includeResolved(false)
24+
.build();
25+
AgentsConversationsGetCanvasResponse response = methods.agentsConversationsGetCanvas(request);
26+
27+
// Inspect the response
28+
System.out.println(response);
29+
}
30+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsListViewsRequest;
7+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsListViewsResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsConversationsListViews {
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.conversations.listViews method
20+
AgentsConversationsListViewsRequest request = AgentsConversationsListViewsRequest.builder()
21+
.channelId("C9876543210")
22+
.build();
23+
AgentsConversationsListViewsResponse response = methods.agentsConversationsListViews(request);
24+
25+
// Inspect the response
26+
System.out.println(response);
27+
}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsRemoveViewRequest;
7+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsRemoveViewResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsConversationsRemoveView {
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.conversations.removeView method
20+
AgentsConversationsRemoveViewRequest request = AgentsConversationsRemoveViewRequest.builder()
21+
.channelId("C9876543210")
22+
.viewKey("reports/coverage.html")
23+
.build();
24+
AgentsConversationsRemoveViewResponse response = methods.agentsConversationsRemoveView(request);
25+
26+
// Inspect the response
27+
System.out.println(response);
28+
}
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsSetCanvasContentRequest;
7+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetCanvasContentResponse;
8+
import java.io.IOException;
9+
10+
public class AgentsConversationsSetCanvasContent {
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.conversations.setCanvasContent method
20+
AgentsConversationsSetCanvasContentRequest request = AgentsConversationsSetCanvasContentRequest.builder()
21+
.channel("C9876543210")
22+
.canvasId("F1234567890")
23+
.content("# Migration plan\n\n1. Inventory cron jobs\n2. Port billing jobs last\n")
24+
.build();
25+
AgentsConversationsSetCanvasContentResponse response = methods.agentsConversationsSetCanvasContent(request);
26+
27+
// Inspect the response
28+
System.out.println(response);
29+
}
30+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsSetCommandsRequest;
7+
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetCommandsRequest.Command;
8+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetCommandsResponse;
9+
import java.io.IOException;
10+
import java.util.List;
11+
12+
public class AgentsConversationsSetCommands {
13+
14+
public static void main(String[] args) throws IOException, SlackApiException {
15+
// Read a token from an environment variable
16+
String token = System.getenv("SLACK_TOKEN");
17+
18+
// Initialize
19+
MethodsClient methods = Slack.getInstance().methods(token);
20+
21+
// Call the agents.conversations.setCommands method
22+
AgentsConversationsSetCommandsRequest request = AgentsConversationsSetCommandsRequest.builder()
23+
.channelId("C9876543210")
24+
.commands(List.of(
25+
Command.builder()
26+
.name("create-pr")
27+
.description("Open a pull request for the current branch")
28+
.argumentHint("[title]")
29+
.build(),
30+
Command.builder()
31+
.name("run-tests")
32+
.description("Run the test suite and report back")
33+
.build(),
34+
Command.builder()
35+
.name("summarize")
36+
.description("Post a summary of the work so far")
37+
.build()))
38+
.build();
39+
AgentsConversationsSetCommandsResponse response = methods.agentsConversationsSetCommands(request);
40+
41+
// Inspect the response
42+
System.out.println(response);
43+
}
44+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsSetPropertiesRequest;
7+
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest.CodeChannel;
8+
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest.ContextBarItem;
9+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetPropertiesResponse;
10+
import java.io.IOException;
11+
import java.util.List;
12+
13+
public class AgentsConversationsSetProperties {
14+
15+
public static void main(String[] args) throws IOException, SlackApiException {
16+
// Read a token from an environment variable
17+
String token = System.getenv("SLACK_TOKEN");
18+
19+
// Initialize
20+
MethodsClient methods = Slack.getInstance().methods(token);
21+
22+
// Call the agents.conversations.setProperties method
23+
AgentsConversationsSetPropertiesRequest request = AgentsConversationsSetPropertiesRequest.builder()
24+
.channelId("C9876543210")
25+
.codeChannel(CodeChannel.builder()
26+
.contextBarItems(List.of(
27+
ContextBarItem.builder()
28+
.key("repo")
29+
.label("borant/billing")
30+
.icon("folder")
31+
.url("https://github.com/borant/billing")
32+
.build(),
33+
ContextBarItem.builder()
34+
.key("branch")
35+
.label("agent/migrate-cron")
36+
.icon("branch")
37+
.url("https://github.com/borant/billing/tree/agent/migrate-cron")
38+
.build(),
39+
ContextBarItem.builder()
40+
.key("pr")
41+
.label("PR #42 is open")
42+
.icon("hierarchy")
43+
.url("https://github.com/borant/billing/pull/42")
44+
.build(),
45+
ContextBarItem.builder()
46+
.key("ci")
47+
.label("Tests pending")
48+
.icon("terminal")
49+
.build()))
50+
.build())
51+
.build();
52+
AgentsConversationsSetPropertiesResponse response = methods.agentsConversationsSetProperties(request);
53+
54+
// Inspect the response
55+
System.out.println(response);
56+
}
57+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package agents.conversations;
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.conversations.AgentsConversationsSetViewRequest;
7+
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetViewRequest.Csp;
8+
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetViewResponse;
9+
import java.io.IOException;
10+
import java.util.List;
11+
12+
public class AgentsConversationsSetView {
13+
14+
public static void main(String[] args) throws IOException, SlackApiException {
15+
// Read a token from an environment variable
16+
String token = System.getenv("SLACK_TOKEN");
17+
18+
// Initialize
19+
MethodsClient methods = Slack.getInstance().methods(token);
20+
21+
// Call the agents.conversations.setView method
22+
AgentsConversationsSetViewRequest request = AgentsConversationsSetViewRequest.builder()
23+
.channelId("C9876543210")
24+
.viewKey("reports/coverage.html")
25+
.name("Coverage")
26+
.content("<!doctype html><html><head>…</head><body>…</body></html>")
27+
.csp(Csp.builder()
28+
.resourceDomains(List.of("https://cdn.jsdelivr.net"))
29+
.build())
30+
.build();
31+
AgentsConversationsSetViewResponse response = methods.agentsConversationsSetView(request);
32+
33+
// Inspect the response
34+
System.out.println(response);
35+
}
36+
}

0 commit comments

Comments
 (0)