Skip to content

Commit 6b07f9d

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

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎methods/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ $ slack run chat_post_message.py # Make the request
4848

4949
### assistant
5050

51+
- **[assistant.search.context](https://docs.slack.dev/reference/methods/assistant.search.context)**: Searches messages, files, channels and users across your Slack organization. [Implementation](./src/assistant/search/assistant_search_context.py).
5152
- **[assistant.search.info](https://docs.slack.dev/reference/methods/assistant.search.info)**: Returns search capabilities on a given team. [Implementation](./src/assistant/search/assistant_search_info.py).
5253

5354
### blocks
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
3+
from slack_sdk import WebClient
4+
5+
# Read a token from an environment variable
6+
token = os.environ.get("SLACK_TOKEN")
7+
8+
# Initialize
9+
client = WebClient(token=token)
10+
11+
# Call the assistant.search.context method
12+
response = client.assistant_search_context(
13+
query="What is the latest on project Gizmo?",
14+
term_clauses=["project gizmo"],
15+
action_token="12345.98765.abcd2358fdea",
16+
channel_types=["public_channel", "private_channel", "mpim", "im"],
17+
content_types=["messages", "files", "channels"],
18+
include_context_messages=True,
19+
include_bots=False,
20+
sort="timestamp",
21+
sort_dir="asc",
22+
before=1755191113,
23+
after=1752512713,
24+
include_message_blocks=True,
25+
)
26+
27+
# Inspect the response
28+
print(response)

‎methods/src/assistant/search/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"oauth_config": {
1313
"scopes": {
14-
"bot": ["search:read.public"]
14+
"bot": ["search:read.files", "search:read.public", "search:read.users"]
1515
}
1616
},
1717
"settings": {

0 commit comments

Comments
 (0)