|
| 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 | +} |
0 commit comments