Skip to main content

Slack

Load data from Slack

Configure via UI

We can load data either by using Channel IDs or Channel Names and specifying Dates for selection.

1. Filter by Channel Names

Load data through Channel Names

Slack

2. Filter by Channel IDs

Load data through Channel IDs

Slack

Configure via API / Client

from llama_cloud.types import CloudSlackDataSource

ds = {
'name': '<your-name>',
'source_type': 'SLACK',
'component': CloudSlackDataSource(
slack_token: '<slack_token>',
# Either 'channel_ids' or 'channel_patterns' must be provided, one of them is required
channel_ids: '<channel_ids>',
channel_patterns: '<channel_patterns>',
latest_date_timestamp: '<latest_date_timestamp>',
earliest_date_timestamp: '<earliest_date_timestamp>',
)
}
data_source = client.data_sources.create_data_source(request=ds)

Steps to generate a Slack Bot token

1. Access the Slack API

  1. Click on Create New App.
  2. Choose From Scratch to create a new app.
  3. Provide a name for your app and select the workspace where you want to install the app.
  4. Click Create App.

2. Configure OAuth & Permissions

  1. In the left sidebar of your app's settings, click on OAuth & Permissions.
  2. Define Scopes: These are permissions that define what your app can do and access in a Slack workspace. They are categorized into Bot Token Scopes and User Token Scopes.

3. Commonly Required Bot Token Scopes:

  1. channels:history: Grants access to view messages and other content in public channels.
  2. channels:read: Grants access to basic information about public channels in a workspace.
  3. groups:read: Grants access to basic information about private channels.
  4. groups:history: Grants access to view messages and other content in private channels.
  5. mpim:history: Grants access to view messages and other content in group direct messages.
  6. users:read: Grants access to information about users in a workspace.
  7. files:read: Allows the app to view files shared in channels.

4. Install the App to Your Workspace

  1. Scroll up to OAuth Tokens for Your Workspace in the OAuth & Permissions section.
  2. Click on Install App to Workspace.
  3. Slack will prompt you to review the scopes you’ve added.
  4. Click "Allow" to install the app with the requested permissions.

5. Retrieve the Bot Token:

  1. Once installed, Slack will generate an OAuth Access Token (Bot Token) for your app.
  2. Important: Copy this token and store it securely (e.g., in environment variables, secret management tools).
Example Slack Bot Token:
xoxb-1234567890-0987654321-abcdefghijklmnopqrstu

Retrieve Slack Bot Token