python-slack-sdk icon indicating copy to clipboard operation
python-slack-sdk copied to clipboard

Add support for assistant.search.context

Open ArielTM opened this issue 9 months ago • 5 comments

Summary

Add support for assistant.search.context . Although listed in docs, it is yet to be supported.

There's a discrepancy between https://api.slack.com/methods/assistant.search.context and https://api.slack.com/docs/apps/data-access-api#use-action-token on whether action_token is required. From my testing it is so I set it as such. Lmk if that's not the case.

Testing

Ran it using my app and workspace

Category

  • [x] slack_sdk.web.WebClient (sync/async) (Web API client)
  • [ ] slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • [ ] slack_sdk.socket_mode (Socket Mode client)
  • [ ] slack_sdk.signature (Request Signature Verifier)
  • [ ] slack_sdk.oauth (OAuth Flow Utilities)
  • [ ] slack_sdk.models (UI component builders)
  • [ ] slack_sdk.scim (SCIM API client)
  • [ ] slack_sdk.audit_logs (Audit Logs API client)
  • [ ] slack_sdk.rtm_v2 (RTM client)
  • [ ] /docs (Documents)
  • [ ] /tutorial (PythOnBoardingBot tutorial)
  • [ ] tests/integration_tests (Automated tests for this library)

Requirements

  • [x] I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

ArielTM avatar Mar 09 '25 06:03 ArielTM

Thanks for the contribution! Before we can merge this, we need @ArielTM to sign the Salesforce Inc. Contributor License Agreement.

salesforce-cla[bot] avatar Mar 09 '25 06:03 salesforce-cla[bot]

Codecov Report

Attention: Patch coverage is 11.11111% with 24 lines in your changes missing coverage. Please review.

Project coverage is 85.20%. Comparing base (1303413) to head (dd5f4e6). Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
slack_sdk/web/async_client.py 11.11% 8 Missing :warning:
slack_sdk/web/client.py 11.11% 8 Missing :warning:
slack_sdk/web/legacy_client.py 11.11% 8 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1667      +/-   ##
==========================================
- Coverage   85.36%   85.20%   -0.16%     
==========================================
  Files         113      113              
  Lines       12802    12829      +27     
==========================================
+ Hits        10928    10931       +3     
- Misses       1874     1898      +24     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Mar 14 '25 19:03 codecov[bot]

Hi @ArielTM thanks for you contribution 🚀 they are alway welcome

Unfortunately we need to hold off on introducing these changes due to these APIs being in a limited access stage

This API is currently in a limited access stage. You may be able to obtain a token and call the API, but to get a valid response, you must be enrolled in the program. Contact Customer Experience at [email protected] to request to be added.

We would also need unit tests for these changes 🙏

WilliamBergamin avatar Mar 14 '25 19:03 WilliamBergamin

@WilliamBergamin Until this is in "limited access" , would you say the best way to use this api would be to do something like this instead ?

app.client.api_call(
                api_method="assistant.search.context",
                http_verb="POST",
                headers={"Authorization": f"Bearer {os.environ.get('SLACK_BOT_TOKEN')}",},
                json={
                    "action_token": action_token,
                    "query": text,
                    "limit": 5,
                },
            )

Pythonista7 avatar Apr 24 '25 05:04 Pythonista7

@Pythonista7 Yess this is the recommended approach 💯 But you may not need to specify the headers or http_verb if the client is configured correctly

WilliamBergamin avatar Apr 24 '25 14:04 WilliamBergamin