Skip to content

Commit a1004b9

Browse files
zimegClaude
andauthored
feat(methods): add assistant.search.context method example (#141)
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent e66a6f6 commit a1004b9

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

‎methods/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques
4040
- **[agents.sessions.rename](https://docs.slack.dev/reference/methods/agents.sessions.rename)**: Rename an agent session. [Implementation](./src/main/java/agents/sessions/AgentsSessionsRename.java).
4141
- **[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).
4242

43+
### assistant
44+
45+
- **[assistant.search.context](https://docs.slack.dev/reference/methods/assistant.search.context)**: Searches messages, files, channels and users across your Slack organization. [Implementation](./src/main/java/assistant/search/AssistantSearchContext.java).
46+
4347
### blocks
4448

4549
- **[blocks.validate](https://docs.slack.dev/reference/methods/blocks.validate)**: Validates blocks, messages, and views Block Kit JSON payloads. [Implementation](./src/main/java/blocks/BlocksValidate.java).
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package assistant.search;
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.assistant.search.AssistantSearchContextRequest;
7+
import com.slack.api.methods.response.asssistant.search.AssistantSearchContextResponse;
8+
import java.io.IOException;
9+
import java.util.Arrays;
10+
11+
public class AssistantSearchContext {
12+
13+
public static void main(String[] args) throws IOException, SlackApiException {
14+
// Read a token from an environment variable
15+
String token = System.getenv("SLACK_TOKEN");
16+
17+
// Initialize
18+
MethodsClient methods = Slack.getInstance().methods(token);
19+
20+
// Call the assistant.search.context method
21+
AssistantSearchContextRequest request = AssistantSearchContextRequest.builder()
22+
.query("What is the latest on project Gizmo?")
23+
.termClauses(Arrays.asList("project gizmo"))
24+
.actionToken("12345.98765.abcd2358fdea")
25+
.channelTypes(Arrays.asList("public_channel", "private_channel", "mpim", "im"))
26+
.contentTypes(Arrays.asList("messages", "files", "channels"))
27+
.includeContextMessages(true)
28+
.includeBots(false)
29+
.sort("timestamp")
30+
.sortDir("asc")
31+
.before(1755191113)
32+
.after(1752512713)
33+
.includeMessageBlocks(true)
34+
.build();
35+
AssistantSearchContextResponse response = methods.assistantSearchContext(request);
36+
37+
// Inspect the response
38+
System.out.println(response);
39+
}
40+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"display_information": {
3+
"name": "Slack API Methods",
4+
"description": "Example implementations to call \"assistant.search\" methods"
5+
},
6+
"features": {
7+
"bot_user": {
8+
"display_name": "Slack API Methods",
9+
"always_online": true
10+
}
11+
},
12+
"oauth_config": {
13+
"scopes": {
14+
"bot": ["search:read.files", "search:read.public", "search:read.users"]
15+
}
16+
},
17+
"settings": {
18+
"org_deploy_enabled": true,
19+
"socket_mode_enabled": false,
20+
"token_rotation_enabled": false
21+
}
22+
}

0 commit comments

Comments
 (0)