# Slack as a Data Source for Conversational and User Learning

## Overview

The Slack connector retrieves data from your Slack workspace to support three learning functions:

* **KB Learning** — Ingests each selected Slack channel as a single Knowledge Base article. All messages in a channel are combined into one article. Images are downloaded and stored in Aisera; other attachments are included as hyperlinks in the article body. Use the date range settings during data source setup to control how far back messages are included.
* **Conversations Learning** — Ingests each message in a selected channel as a separate entry using the Conversations data model.
* **User Learning** — Ingests user data from your Slack workspace. For most use cases, User Learning is sufficient. User Profile Learning is only needed if you require additional profile attribute data beyond what standard User Learning provides.

You can enable one or more learning functions on a single data source. If you plan to use Conversations Learning, run User Learning first so that ingested messages can be associated with known users in your workspace.

See [**Conversational Learning**](https://docs.aisera.com/aisera-platform/generative-ai-learning/conversational-learning) and [**Gen AI Learning**](https://docs.aisera.com/aisera-platform/generative-ai-learning) for more information about running these jobs.

## Prepare

Before setting up the Slack connector in Aisera, you need to create and configure a Slack application in your Slack workspace.

### Endpoint

Before you begin, note the following endpoint for use during integration setup:

`https://slack.com`

### Create a service account

Create a dedicated Slack user account for Aisera to use when connecting to your workspace. Using a service account rather than an admin account limits Aisera's access to only the permissions it requires.

The service account needs Read permissions with Export ability to transfer data to Aisera. If you plan to use features that write back to Slack, such as Ticket Concierge or Knowledge Generation, the account will also need Read/Write permissions with Import and Export ability.

This account does not need Execute or Delete permissions. All Aisera operations are performed, tracked, and logged in the Aisera cloud.

Use this account to complete the remaining steps in Prepare.

### Create a Slack application

1. Log in to the Slack workspace where you want to install the Aisera bot.
2. Go to <https://api.slack.com/apps>.
3. Click **Create New App** and select **From scratch**.
4. Set the **App Name** and **Slack Development Workspace**.
5. Set the display information for your app:
   * App name
   * Short description
   * App icon (512x512 px PNG)
   * Background color
6. Click **Save Changes**.
7. From the left navigation menu, click **Event Subscriptions**.
8. Enable **Events**.
9. Expand **Subscribe to bot events**, click **Add Bot User Events**, and add the required events.
10. Click **Save Changes**.
11. From the left navigation menu, go to **Interactivity & Shortcuts** and enable it.
12. Set the following URL as the **Request URL** in both the **Event Subscriptions** window and the **Interactivity & Select Menus** window: `https://<tenant_id>.chatbot.aisera.<top_level_domain>/slack/receive`

### OAuth authorization

1. From the left navigation menu, go to **OAuth & Permissions**.
2. In the **Scopes** section, add the following scopes to your user or bot token:
   * User Learning: `users:read`
   * Conversations Learning: `channels:read`, `groups:read`, `im:read`, `mpim:read`, `channels:history`, `groups:history`, `im:history`, `mpim:history`
3. Click **Install to \[App Name]** under **OAuth Tokens** and click **Allow**.
4. Copy the **User OAuth Token** from the **OAuth Tokens** section.

After completing this section you should have:

* User OAuth Token
* Authorization URL: `https://slack.com/oauth/v2/authorize`
* Access Token URL: `https://slack.com/api/oauth.v2.access`

### Basic authentication

1. From the left navigation menu, go to **Basic Information**.
2. Under **App Credentials**, copy the **Verification Token**.

After completing this section you should have:

* Verification Token

## Integration setup

To create the Slack integration:

1. In the Aisera Admin UI, navigate to **Settings → Integrations** and click **+ New Integration**.
2. Select **Slack** from the list.
3. Enter a name for the integration and click **Next**.
4. Select your **Auth Type** and enter the credentials from your Prepare steps.
5. Click **OK**.

## Data source setup

To create a Slack data source:

1. In the Aisera Admin UI, navigate to **Settings → Data Sources** and click **+ New Data Source**.
2. Select **Slack** from the list.
3. Enter the following details and click **Next**:

   <table data-header-hidden><thead><tr><th width="152.39996337890625">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>A name for this data source</td></tr><tr><td><strong>Functions</strong></td><td>Select the learning functions you want to enable for this data source</td></tr><tr><td><strong>Integration</strong></td><td>Select the Slack integration you created in Integration setup</td></tr><tr><td><strong>Schedule</strong></td><td>Select how frequently the data source should run</td></tr><tr><td><strong>Data Retrieval</strong></td><td>How you would like data to be retrieved. <strong>Incremental</strong> retrieves only messages created or updated since the last data ingestion. <strong>Date Range (UTC)</strong> retrieves messages within a specified date range. Leave the end date blank to retrieve all messages after the start date.</td></tr><tr><td><strong>Language</strong></td><td>Select the language of your Slack content</td></tr></tbody></table>

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>The remaining fields on this screen are optional configurations. See Optional configurations for details. </p></div>
4. Click **Next** through the remaining steps and click **OK** to complete the data source creation.
5. Contact your Aisera representative to configure a channel override for your data source. Provide the names or IDs of the Slack channels you want to ingest. Your representative will add the override on your behalf before data ingestion can run.<br>

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>If you are using <strong>Conversations Learning</strong> with <strong>Incremental</strong> data retrieval, note that edited messages will not be captured on subsequent runs. This is a limitation of the Slack API: edited messages retain their original timestamp and are filtered out as already-ingested. Use <strong>Date Range</strong> retrieval if capturing edited messages is a requirement.</p></div>
6. Click **Next** until the setup wizard closes to complete the data source creation.

## Optional configurations

### Transformation Script

\[STUB: document when guidance is available from engineering]

### Auto Commit

Automatically commits ingested content without requiring manual review. See [Data Source Configurations](https://docs.aisera.com/aisera-platform/adding-data-to-your-tenant/integrations-and-data-sources/creating-a-connector/adding-and-managing-data-sources-in-your-tenant/data-source-configurations#h_01jtpfj2nshmvwv6knwhkjr0nv) for full details.

## Post-setup actions

### Next steps

Run data ingestion to begin pulling content into Aisera. See [Data Ingestion](https://docs.aisera.com/aisera-platform/adding-data-to-your-tenant/data-ingestion).

To make your Aisera bot available in Slack, install it as a Slack channel. See [Setting up a Slack Channel](https://docs.aisera.com/aisera-platform/channels/setting-up-a-slack-channel).
