-
Notifications
You must be signed in to change notification settings - Fork 0
feat(methods): add agents.conversations.* method examples #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
zimeg
wants to merge
7
commits into
main
Choose a base branch
from
clack/code-channels-method-examples
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74542be
feat(methods): add agents.conversations.* method examples
zimeg 8113b4f
feat(methods): enable Socket Mode in agents.conversations manifest
zimeg f84870e
docs(methods): match agents.conversations examples to docs #816 verbatim
zimeg bc03f67
feat(methods): use typed builders for agents.conversations complex args
zimeg 1dab5fd
docs: list agents methods in alphabetical order
zimeg f56c1fc
docs: match setCommands description to the reference
zimeg 2d34243
Merge branch 'main' into clack/code-channels-method-examples
zimeg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
methods/src/main/java/agents/conversations/AgentsConversationsArchive.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
methods/src/main/java/agents/conversations/AgentsConversationsCreate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
methods/src/main/java/agents/conversations/AgentsConversationsGetCanvas.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
28 changes: 28 additions & 0 deletions
28
methods/src/main/java/agents/conversations/AgentsConversationsListViews.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
methods/src/main/java/agents/conversations/AgentsConversationsRemoveView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } | ||
30 changes: 30 additions & 0 deletions
30
methods/src/main/java/agents/conversations/AgentsConversationsSetCanvasContent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
methods/src/main/java/agents/conversations/AgentsConversationsSetCommands.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
methods/src/main/java/agents/conversations/AgentsConversationsSetProperties.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
| .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); | ||
| } | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
methods/src/main/java/agents/conversations/AgentsConversationsSetView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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: