repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: '🤖 Slack' |
| #3 | --- |
| #4 | |
| #5 | ## Pre-requisite |
| #6 | - Download required packages by running `pip install --upgrade "embedchain[slack]"`. |
| #7 | - Configure your slack bot token as environment variable `SLACK_USER_TOKEN`. |
| #8 | - Find your user token on your [Slack Account](https://api.slack.com/authentication/token-types) |
| #9 | - Make sure your slack user token includes [search](https://api.slack.com/scopes/search:read) scope. |
| #10 | |
| #11 | ## Example |
| #12 | |
| #13 | ### Get Started |
| #14 | |
| #15 | This will automatically retrieve data from the workspace associated with the user's token. |
| #16 | |
| #17 | ```python |
| #18 | import os |
| #19 | from embedchain import App |
| #20 | |
| #21 | os.environ["SLACK_USER_TOKEN"] = "xoxp-xxx" |
| #22 | app = App() |
| #23 | |
| #24 | app.add("in:general", data_type="slack") |
| #25 | |
| #26 | result = app.query("what are the messages in general channel?") |
| #27 | |
| #28 | print(result) |
| #29 | ``` |
| #30 | |
| #31 | |
| #32 | ### Customize your SlackLoader |
| #33 | 1. Setup the Slack loader by configuring the Slack Webclient. |
| #34 | ```Python |
| #35 | from embedchain.loaders.slack import SlackLoader |
| #36 | |
| #37 | os.environ["SLACK_USER_TOKEN"] = "xoxp-*" |
| #38 | |
| #39 | config = { |
| #40 | 'base_url': slack_app_url, |
| #41 | 'headers': web_headers, |
| #42 | 'team_id': slack_team_id, |
| #43 | } |
| #44 | |
| #45 | loader = SlackLoader(config) |
| #46 | ``` |
| #47 | |
| #48 | NOTE: you can also pass the `config` with `base_url`, `headers`, `team_id` to setup your SlackLoader. |
| #49 | |
| #50 | 2. Once you setup the loader, you can create an app and load data using the above slack loader |
| #51 | ```Python |
| #52 | import os |
| #53 | from embedchain.pipeline import Pipeline as App |
| #54 | |
| #55 | app = App() |
| #56 | |
| #57 | app.add("in:random", data_type="slack", loader=loader) |
| #58 | question = "Which bots are available in the slack workspace's random channel?" |
| #59 | # Answer: The available bot in the slack workspace's random channel is the Embedchain bot. |
| #60 | ``` |
| #61 | |
| #62 | 3. We automatically create a chunker to chunk your slack data, however if you wish to provide your own chunker class. Here is how you can do that: |
| #63 | ```Python |
| #64 | from embedchain.chunkers.slack import SlackChunker |
| #65 | from embedchain.config.add_config import ChunkerConfig |
| #66 | |
| #67 | slack_chunker_config = ChunkerConfig(chunk_size=1000, chunk_overlap=0, length_function=len) |
| #68 | slack_chunker = SlackChunker(config=slack_chunker_config) |
| #69 | |
| #70 | app.add(slack_chunker, data_type="slack", loader=loader, chunker=slack_chunker) |
| #71 | ``` |