-
Notifications
You must be signed in to change notification settings - Fork 425
Slack tool #821
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
Merged
Merged
Slack tool #821
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e99c2ce
TLK-1725 - Slack tool initial commit
EugeneLightsOn 8496771
TLK-1725 - Slack tool
EugeneLightsOn b993973
TLK-1725 - Slack tool
EugeneLightsOn eaef7c1
Merge branch 'refs/heads/main' into eugene/TLK-1725_slack_tool
EugeneLightsOn e3bc975
TLK-1725 - Slack tool lint
EugeneLightsOn c7c8c44
TLK-1725 - Slack tool pyright
EugeneLightsOn a7c5b2c
TLK-1725 - Slack tool pyright
EugeneLightsOn 326a5a3
TLK-1725 - Slack tool pyright
EugeneLightsOn 8df6946
TLK-1725 - Slack tool pyright
EugeneLightsOn c3fa93d
TLK-1725 - Slack tool - pyright
EugeneLightsOn 50bb431
TLK-1725 - Slack tool
EugeneLightsOn 8976f3f
TLK-1725 - Slack tool small improvements
EugeneLightsOn 6099821
TLK-1725 - Slack tool
EugeneLightsOn 20ae543
TLK-1725 - Slack tool review fixes
EugeneLightsOn 1fa44fa
TLK-1725 - Slack tool review fixes
EugeneLightsOn f046f1a
Merge branch 'refs/heads/main' into eugene/TLK-1725_slack_tool
EugeneLightsOn ec17758
TLK-1725 - Slack tool prettier
EugeneLightsOn e237183
TLK-1725 - Slack tool
EugeneLightsOn e64bb61
TLK-1725 - Slack tool
EugeneLightsOn e6004b0
TLK-1725 - Slack tool
EugeneLightsOn a51a069
Merge branch 'refs/heads/main' into eugene/TLK-1725_slack_tool
EugeneLightsOn 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
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,128 @@ | ||
| # Slack Tool Setup | ||
|
|
||
| To set up the Slack tool you will need a Slack application. Follow the steps below to set it up: | ||
|
|
||
| ## 1. Create a Slack App | ||
|
|
||
| Head to the [Slack API](https://api.slack.com/apps) and create a new app. | ||
| After creating the app, you will see the `App Credentials` section. Copy the `Client ID` and `Client Secret` values. | ||
| That will be used for the environment variables specified above. | ||
|
|
||
| ## 2. Set up OAuth & Permissions | ||
| OAuth flow is required to authenticate users with Slack. | ||
| To enable it please set the following redirect URL to your app's settings: | ||
| ```bash | ||
| https://<your_backend_url>/v1/tool/auth | ||
| ``` | ||
| Please note that for the local development you will need to enable HTTPS. | ||
| See the [Setup HTTPS for Local Development](#5-setup-https-for-local-development) section for more details. | ||
| If you are using a local https setup, redirect url should be | ||
| ``` | ||
| https://localhost:8000/v1/tool/auth | ||
| ``` | ||
| Also, you can set up a proxy, such as [ngrok](https://ngrok.com/docs/getting-started/), to expose your local server to the internet. | ||
|
|
||
| The Slack tool uses User Token Scopes to access the user's Slack workspace. | ||
| The required and the default permission scope is `search:read`. | ||
| Set it in the `OAuth & Permissions` section of your Slack app settings. | ||
|
|
||
| To work with the Slack Tool Advanced token security via token rotation is required. | ||
| To enable it, go to the `OAuth & Permissions` section of your Slack app settings and click 'Opt in' button in the 'Advanced token security via token rotation' section. | ||
|
|
||
| More information about the OAuth flow can be found [here](https://api.slack.com/authentication/oauth-v2). | ||
|
|
||
| ## 3. Set Up Environment Variables | ||
|
|
||
| Then set the following environment variables. You can either set the below values in your `.env` file: | ||
|
|
||
| ```bash | ||
| SLACK_CLIENT_ID=<your_client_id from step 1> | ||
| SLACK_CLIENT_SECRET=<your_client_secret from step 1> | ||
| ``` | ||
|
|
||
| or update your `secrets.yaml` configuration to contain: | ||
|
|
||
| ```bash | ||
| slack: | ||
| client_id: <your_client_id from step 1> | ||
| client_secret: <your_client_secret from step 1> | ||
| ``` | ||
|
|
||
| ## 4. Enable the Slack Tool in the Frontend | ||
|
|
||
| To enable the Slack tool in the frontend, you will need to modify the `src/community/config/tools.py` file. Add the `TOOL_SLACK_ID` to the `AGENT_SETTINGS_TOOLS` list. | ||
|
|
||
| ```typescript | ||
| export const AGENT_SETTINGS_TOOLS = [ | ||
| TOOL_HYBRID_WEB_SEARCH_ID, | ||
| TOOL_PYTHON_INTERPRETER_ID, | ||
| TOOL_WEB_SCRAPE_ID, | ||
| TOOL_SLACK_ID, | ||
| ]; | ||
| ``` | ||
|
|
||
| ## 5. Setup HTTPS for Local Development | ||
|
|
||
| To enable HTTPS for local development, the self-signed certificate needs to be generated. | ||
| Run the following command in the project root directory to generate the certificate and key: | ||
|
|
||
| ```bash | ||
| openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365 | ||
| ``` | ||
|
|
||
| Then, update the backend Docker configuration(src/backend/Dockerfile) to use the generated certificate. | ||
| Just change next lines in the Dockerfile: | ||
| ```Dockerfile | ||
| COPY pyproject.toml poetry.lock cert.pem key.pem ./ | ||
| ``` | ||
| and | ||
| ```Dockerfile | ||
| CMD uvicorn backend.main:app --reload --host 0.0.0.0 --port ${PORT} --timeout-keep-alive 300 --ssl-keyfile /workspace/key.pem --ssl-certfile /workspace/cert.pem | ||
| ``` | ||
| Change NEXT_PUBLIC_API_HOSTNAME environment variable in the .env `https` protocol: | ||
| ```bash | ||
| NEXT_PUBLIC_API_HOSTNAME=https://localhost:8000 | ||
| ``` | ||
|
|
||
| or in the configurations.yaml file: | ||
|
|
||
| ```yaml | ||
| auth: | ||
| backend_hostname: https://localhost:8000 | ||
| ``` | ||
|
|
||
| To run the Frontend with HTTPS, update the `start` script in the `package.json` file: | ||
|
|
||
| ```json | ||
| "scripts": { | ||
| "dev": "next dev --port 4000 --experimental-https", | ||
| .......... | ||
| } | ||
| ``` | ||
|
|
||
| Add the following line to the 'docker-compose.yml' file to the frontend environment variables: | ||
|
|
||
| ```yaml | ||
| NEXT_PUBLIC_API_HOSTNAME=https://localhost:8000 | ||
| ``` | ||
|
|
||
| and change the API_HOSTNAME to | ||
|
|
||
| ```yaml | ||
| API_HOSTNAME: https://localhost:8000 | ||
| ``` | ||
| also change the src/interfaces/assistants_web/.env.development file env variables to use https. | ||
|
|
||
| ## 6. Run the Backend and Frontend | ||
|
|
||
| run next command to start the backend and frontend: | ||
|
|
||
| ```bash | ||
| make dev | ||
| ``` | ||
|
|
||
| ## 7. Troubleshooting | ||
|
|
||
| If you encounter any issues with OAuth, please check the following [link](https://api.slack.com/authentication/oauth-v2#errors) | ||
| For example, if you see the invalid_team_for_non_distributed_app error, | ||
| please ensure the app is distributed or try logging in with the workspace owner's account. | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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,11 @@ | ||
| from backend.tools.slack.auth import SlackAuth | ||
| from backend.tools.slack.constants import ( | ||
| SLACK_TOOL_ID, | ||
| ) | ||
| from backend.tools.slack.tool import SlackTool | ||
|
|
||
| __all__ = [ | ||
| "SlackAuth", | ||
| "SlackTool", | ||
| "SLACK_TOOL_ID", | ||
| ] |
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.
Uh oh!
There was an error while loading. Please reload this page.