Browse Source

Add docs for slack and add missing datatype (#1023)

Sidharth Mohanty 1 year ago
parent
commit
bee4e834b1

+ 21 - 4
docs/components/data-sources/slack.mdx

@@ -9,15 +9,33 @@ title: '🤖 Slack'
     - Make sure your slack user token includes [search](https://api.slack.com/scopes/search:read) scope.
 
 ## Example
+
+### Get Started
+
+This will automatically retrieve data from the workspace associated with the user's token.
+
+```python
+import os
+from embedchain import Pipeline as App
+
+os.environ["SLACK_USER_TOKEN"] = "xoxp-xxx"
+app = App()
+
+app.add("in:general", data_type="slack")
+
+result = app.query("what are the messages in general channel?")
+
+print(result)
+```
+
+
+### Customize your SlackLoader
 1. Setup the Slack loader by configuring the Slack Webclient.
 ```Python
 from embedchain.loaders.slack import SlackLoader
 
 os.environ["SLACK_USER_TOKEN"] = "xoxp-*"
 
-loader = SlackLoader()
-
-"""
 config = {
     'base_url': slack_app_url,
     'headers': web_headers,
@@ -25,7 +43,6 @@ config = {
 }
 
 loader = SlackLoader(config)
-"""
 ```
 
 NOTE: you can also pass the `config` with `base_url`, `headers`, `team_id` to setup your SlackLoader.

+ 2 - 0
embedchain/data_formatter/data_formatter.py

@@ -75,6 +75,7 @@ class DataFormatter(JSONSerializable):
             DataType.RSSFEED: "embedchain.loaders.rss_feed.RSSFeedLoader",
             DataType.BEEHIIV: "embedchain.loaders.beehiiv.BeehiivLoader",
             DataType.DIRECTORY: "embedchain.loaders.directory_loader.DirectoryLoader",
+            DataType.SLACK: "embedchain.loaders.slack.SlackLoader",
         }
 
         if data_type == DataType.CUSTOM or loader is not None:
@@ -118,6 +119,7 @@ class DataFormatter(JSONSerializable):
             DataType.RSSFEED: "embedchain.chunkers.rss_feed.RSSFeedChunker",
             DataType.BEEHIIV: "embedchain.chunkers.beehiiv.BeehiivChunker",
             DataType.DIRECTORY: "embedchain.chunkers.common_chunker.CommonChunker",
+            DataType.SLACK: "embedchain.chunkers.common_chunker.CommonChunker",
         }
 
         if chunker is not None:

+ 2 - 0
embedchain/models/data_type.py

@@ -36,6 +36,7 @@ class IndirectDataType(Enum):
     RSSFEED = "rss_feed"
     BEEHIIV = "beehiiv"
     DIRECTORY = "directory"
+    SLACK = "slack"
 
 
 class SpecialDataType(Enum):
@@ -71,3 +72,4 @@ class DataType(Enum):
     RSSFEED = IndirectDataType.RSSFEED.value
     BEEHIIV = IndirectDataType.BEEHIIV.value
     DIRECTORY = IndirectDataType.DIRECTORY.value
+    SLACK = IndirectDataType.SLACK.value