slack-AI.mdx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. [Embedchain Examples Repo](https://github.com/embedchain/examples) contains code on how to build your own Slack AI to chat with the unstructured data lying in your slack channels.
  2. ![Slack AI Demo](/images/slack-ai.png)
  3. ## Getting started
  4. Create a Slack AI involves 3 steps
  5. * Create slack user
  6. * Set environment variables
  7. * Run the app locally
  8. ### Step 1: Create Slack user token
  9. Follow the steps given below to fetch your slack user token to get data through Slack APIs:
  10. 1. Create a workspace on Slack if you don’t have one already by clicking [here](https://slack.com/intl/en-in/).
  11. 2. Create a new App on your Slack account by going [here](https://api.slack.com/apps).
  12. 3. Select `From Scratch`, then enter the App Name and select your workspace.
  13. 4. Navigate to `OAuth & Permissions` tab from the left sidebar and go to the `scopes` section. Add the following scopes under `User Token Scopes`:
  14. ```
  15. # Following scopes are needed for reading channel history
  16. channels:history
  17. channels:read
  18. # Following scopes are needed to fetch list of channels from slack
  19. groups:read
  20. mpim:read
  21. im:read
  22. ```
  23. 5. Click on the `Install to Workspace` button under `OAuth Tokens for Your Workspace` section in the same page and install the app in your slack workspace.
  24. 6. After installing the app you will see the `User OAuth Token`, save that token as you will need to configure it as `SLACK_USER_TOKEN` for this demo.
  25. ### Step 2: Set environment variables
  26. Navigate to `api` folder and set your `HUGGINGFACE_ACCESS_TOKEN` and `SLACK_USER_TOKEN` in `.env.example` file. Then rename the `.env.example` file to `.env`.
  27. <Note>
  28. By default, we use `Mixtral` model from Hugging Face. However, if you prefer to use OpenAI model, then set `OPENAI_API_KEY` instead of `HUGGINGFACE_ACCESS_TOKEN` along with `SLACK_USER_TOKEN` in `.env` file, and update the code in `api/utils/app.py` file to use OpenAI model instead of Hugging Face model.
  29. </Note>
  30. ### Step 3: Run app locally
  31. Follow the instructions given below to run app locally based on your development setup (with docker or without docker):
  32. #### With docker
  33. ```bash
  34. docker-compose build
  35. ec start --docker
  36. ```
  37. #### Without docker
  38. ```bash
  39. ec install-reqs
  40. ec start
  41. ```
  42. Finally, you will have the Slack AI frontend running on http://localhost:3000. You can also access the REST APIs on http://localhost:8000.
  43. ## Credits
  44. This demo was built using the Embedchain's [full stack demo template](https://docs.embedchain.ai/get-started/full-stack). Follow the instructions [given here](https://docs.embedchain.ai/get-started/full-stack) to create your own full stack RAG application.