Skip to content
Merged
9 changes: 9 additions & 0 deletions methods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques

### agents

- **[agents.conversations.archive](https://docs.slack.dev/reference/methods/agents.conversations.archive)**: Archive a code channel. [Implementation](./src/main/java/agents/conversations/AgentsConversationsArchive.java).
- **[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).
- **[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).
- **[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).
- **[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).
- **[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).
- **[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).
- **[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).
- **[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).
- **[agents.sessions.rename](https://docs.slack.dev/reference/methods/agents.sessions.rename)**: Rename an agent session. [Implementation](./src/main/java/agents/sessions/AgentsSessionsRename.java).
- **[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).

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsArchiveRequest;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsArchiveResponse;
import java.io.IOException;

public class AgentsConversationsArchive {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.archive method
AgentsConversationsArchiveRequest request = AgentsConversationsArchiveRequest.builder()
.channelId("C9876543210")
.summaryMessageTs("1717182000.456789")
.build();
AgentsConversationsArchiveResponse response = methods.agentsConversationsArchive(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsCreateRequest;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsCreateResponse;
import java.io.IOException;

public class AgentsConversationsCreate {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.create method
AgentsConversationsCreateRequest request = AgentsConversationsCreateRequest.builder()
.name("Migrate billing cron to Temporal")
.sessionId("ses_8675309")
.originChannelId("C0123456789")
.originMessageTs("1717171717.123456")
.build();
AgentsConversationsCreateResponse response = methods.agentsConversationsCreate(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsGetCanvasRequest;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsGetCanvasResponse;
import java.io.IOException;

public class AgentsConversationsGetCanvas {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.getCanvas method
AgentsConversationsGetCanvasRequest request = AgentsConversationsGetCanvasRequest.builder()
.channel("C9876543210")
.canvasId("F1234567890")
.includeResolved(false)
.build();
AgentsConversationsGetCanvasResponse response = methods.agentsConversationsGetCanvas(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsListViewsRequest;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsListViewsResponse;
import java.io.IOException;

public class AgentsConversationsListViews {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.listViews method
AgentsConversationsListViewsRequest request = AgentsConversationsListViewsRequest.builder()
.channelId("C9876543210")
.build();
AgentsConversationsListViewsResponse response = methods.agentsConversationsListViews(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsRemoveViewRequest;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsRemoveViewResponse;
import java.io.IOException;

public class AgentsConversationsRemoveView {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.removeView method
AgentsConversationsRemoveViewRequest request = AgentsConversationsRemoveViewRequest.builder()
.channelId("C9876543210")
.viewKey("reports/coverage.html")
.build();
AgentsConversationsRemoveViewResponse response = methods.agentsConversationsRemoveView(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetCanvasContentRequest;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetCanvasContentResponse;
import java.io.IOException;

public class AgentsConversationsSetCanvasContent {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.setCanvasContent method
AgentsConversationsSetCanvasContentRequest request = AgentsConversationsSetCanvasContentRequest.builder()
.channel("C9876543210")
.canvasId("F1234567890")
.content("# Migration plan\n\n1. Inventory cron jobs\n2. Port billing jobs last\n")
.build();
AgentsConversationsSetCanvasContentResponse response = methods.agentsConversationsSetCanvasContent(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetCommandsRequest;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetCommandsRequest.Command;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetCommandsResponse;
import java.io.IOException;
import java.util.List;

public class AgentsConversationsSetCommands {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.setCommands method
AgentsConversationsSetCommandsRequest request = AgentsConversationsSetCommandsRequest.builder()
.channelId("C9876543210")
.commands(List.of(
Command.builder()
.name("create-pr")
.description("Open a pull request for the current branch")
.argumentHint("[title]")
.build(),
Command.builder()
.name("run-tests")
.description("Run the test suite and report back")
.build(),
Command.builder()
.name("summarize")
.description("Post a summary of the work so far")
.build()))
.build();
AgentsConversationsSetCommandsResponse response = methods.agentsConversationsSetCommands(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest.CodeChannel;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetPropertiesRequest.ContextBarItem;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetPropertiesResponse;
import java.io.IOException;
import java.util.List;

public class AgentsConversationsSetProperties {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.setProperties method
AgentsConversationsSetPropertiesRequest request = AgentsConversationsSetPropertiesRequest.builder()
.channelId("C9876543210")
.codeChannel(CodeChannel.builder()
.contextBarItems(List.of(
ContextBarItem.builder()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 note: We prefer the specific imports here instead of something like follows for now:

AgentsConversationsSetPropertiesRequest.ContextBarItem.builder()

.key("repo")
.label("borant/billing")
.icon("folder")
.url("https://github.com/borant/billing")
.build(),
ContextBarItem.builder()
.key("branch")
.label("agent/migrate-cron")
.icon("branch")
.url("https://github.com/borant/billing/tree/agent/migrate-cron")
.build(),
ContextBarItem.builder()
.key("pr")
.label("PR #42 is open")
.icon("hierarchy")
.url("https://github.com/borant/billing/pull/42")
.build(),
ContextBarItem.builder()
.key("ci")
.label("Tests pending")
.icon("terminal")
.build()))
.build())
.build();
AgentsConversationsSetPropertiesResponse response = methods.agentsConversationsSetProperties(request);

// Inspect the response
System.out.println(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package agents.conversations;

import com.slack.api.Slack;
import com.slack.api.methods.MethodsClient;
import com.slack.api.methods.SlackApiException;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetViewRequest;
import com.slack.api.methods.request.agents.conversations.AgentsConversationsSetViewRequest.Csp;
import com.slack.api.methods.response.agents.conversations.AgentsConversationsSetViewResponse;
import java.io.IOException;
import java.util.List;

public class AgentsConversationsSetView {

public static void main(String[] args) throws IOException, SlackApiException {
// Read a token from an environment variable
String token = System.getenv("SLACK_TOKEN");

// Initialize
MethodsClient methods = Slack.getInstance().methods(token);

// Call the agents.conversations.setView method
AgentsConversationsSetViewRequest request = AgentsConversationsSetViewRequest.builder()
.channelId("C9876543210")
.viewKey("reports/coverage.html")
.name("Coverage")
.content("<!doctype html><html><head>…</head><body>…</body></html>")
.csp(Csp.builder()
.resourceDomains(List.of("https://cdn.jsdelivr.net"))
.build())
.build();
AgentsConversationsSetViewResponse response = methods.agentsConversationsSetView(request);

// Inspect the response
System.out.println(response);
}
}
25 changes: 25 additions & 0 deletions methods/src/main/java/agents/conversations/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 \"agents.conversations\" 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": true,
"token_rotation_enabled": false
}
}
Loading