If you’re new to Unstructured, read this note first.

Before you can create a source connector, you must first sign in to your Unstructured account:

  • If you do not already have an Unstructured account, go to https://unstructured.io/contact and fill out the online form to indicate your interest.
  • If you already have an Unstructured account, go to https://platform.unstructured.io and sign in by using the email address, Google account, or GitHub account that is associated with your Unstructured account.

After you sign in, the Unstructured user interface (UI) appears, which you use to get your Unstructured API key. To learn how, watch this 40-second how-to video.

After you create the source connector, add it along with a destination connector to a workflow. Then run the worklow as a job. To learn how, try out the hands-on Workflow Endpoint quickstart, go directly to the quickstart notebook, or watch the two 4-minute video tutorials for the Unstructured Python SDK.

You can also create source connectors with the Unstructured user interface (UI). Learn how.

If you need help, reach out to the community on Slack, or contact us directly.

You are now ready to start creating a source connector! Keep reading to learn how.

Ingest your files into Unstructured from Slack.

The requirements are as follows.

  • A Slack app. Create a Slack app by following Step 1: Creating an app.

  • The app must have the the following OAuth scopes:

    • To read messages from public channels, add the scopes channels:join and channels:history.
    • To read messages from private channels, add the scope groups:history.

    Add these scopes to the app by following Step 2: Requesting scopes.

  • The app must be installed and authorized for the target Slack workspace. Install and authorize the app by following Step 3: Installing and authorizing the app.

  • The app’s access token. Get this token by following Step 3: Installing and authorizing the app.

  • Add the app to the target channels in the Slack workspace. To do this from the channel, open the channel’s details page, click the Integrations tab, click Add apps, and follow the on-screen directions to install the app.

  • The channel ID for each target channel. To get this ID, open the channel’s details page, and look for the Channel ID field on the About tab.

  • The starting and ending date and time range for the channels to be processed. Supported formats include:

    • YYYY-MM-DD
    • YYYY-MM-DDTHH:MM:SS
    • YYYY-MM-DDTHH:MM:SSZ
    • YYYY-MM-DD+HH:MM:SS
    • YYYY-MM-DD-HH:MM:SS

To create a Slack source connector, see the following examples.

import os

from unstructured_client import UnstructuredClient
from unstructured_client.models.operations import CreateSourceRequest
from unstructured_client.models.shared import (
    CreateSourceConnector,
    SourceConnectorType,
    SlackSourceConnectorConfigInput
)

with UnstructuredClient(api_key_auth=os.getenv("UNSTRUCTURED_API_KEY")) as client:
    response = client.sources.create_source(
        request=CreateSourceRequest(
            create_source_connector=CreateSourceConnector(
                name="<name>",
                type=SourceConnectorType.SLACK,
                config=SlackSourceConnectorConfigInput(
                    channels=[
                        "<channel>",
                        "<channel>"
                    ],
                    start_date="<start-date>",
                    end_date="<end-date>",
                    token="<token>"
                )
            )
        )
    )

    print(response.source_connector_information)

Replace the preceding placeholders as follows:

  • <name> (required) - A unique name for this connector.
  • <channel> (required): The ID of the target Slack channel to read messages from.
  • <start-date>: The starting date and time, in ISO 8601 format such as YYYY-MM-DDTHH:MM:SSZ, to start reading messages from. Messages that were created earlier than this date and time are ignored. By default, all messages are read unless <end-date> is specified.
  • <end-date>: The ending date and time, in ISO 8601 format such as YYYY-MM-DDTHH:MM:SSZ, to stop reading messages at. Messages that are created after this date and time are ignored. By default, all messages are read unless <start-date> is specified.
  • <token> (required): The access token for the Slack app that has access to the target Slack channels to read messages from.