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
2. Filter by Channel IDs
Load data through Channel IDs
Configure via API / Client
- Python Client
- TypeScript 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)
const ds = {
'name': '<your-name>',
'sourceType': 'SLACK',
'component': {
'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>',
}
};
const dataSource = await client.dataSources.createDataSource({
body: ds
});
Steps to generate a Slack Bot token
1. Access the Slack API
- Click on
Create New App
. - Choose
From Scratch
to create a new app. - Provide a name for your app and select the workspace where you want to install the app.
- Click
Create App
.
2. Configure OAuth & Permissions
- In the left sidebar of your app's settings, click on
OAuth & Permissions
. - 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:
channels:history
: Grants access to view messages and other content in public channels.channels:read
: Grants access to basic information about public channels in a workspace.groups:read
: Grants access to basic information about private channels.groups:history
: Grants access to view messages and other content in private channels.mpim:history
: Grants access to view messages and other content in group direct messages.users:read
: Grants access to information about users in a workspace.files:read
: Allows the app to view files shared in channels.
4. Install the App to Your Workspace
- Scroll up to OAuth Tokens for Your Workspace in the OAuth & Permissions section.
- Click on Install App to Workspace.
- Slack will prompt you to review the scopes you’ve added.
- Click "Allow" to install the app with the requested permissions.
5. Retrieve the Bot Token:
- Once installed, Slack will generate an OAuth Access Token (Bot Token) for your app.
- Important: Copy this token and store it securely (e.g., in environment variables, secret management tools).
Example Slack Bot Token:
xoxb-1234567890-0987654321-abcdefghijklmnopqrstu