Create Slack Feed

User Intent

"I want to sync Slack channels into Graphlit for search and AI interactions"

Operation

  • SDK Method: graphlit.createFeed() with Slack configuration

  • GraphQL: createFeed mutation

  • Entity Type: Feed

  • Common Use Cases: Slack channel sync, team communication search, chat history RAG

TypeScript (Canonical)

import { Graphlit } from 'graphlit-client';
import {
  ContentTypes,
  FeedInput,
  FeedListingTypes,
  FeedTypes,
  SearchTypes,
} from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Optional: Query available Slack channels (requires token/OAuth)
const channelsResponse = await graphlit.querySlackChannels({
  token: process.env.SLACK_TOKEN!,
});

console.log('Available channels:', channelsResponse.slackChannels?.results);

// Step 1: Create a Slack feed for ONE channel (one feed per channel)
const feedInput: FeedInput = {
  name: 'Engineering Slack',
  type: FeedTypes.Slack,
  slack: {
    type: FeedListingTypes.Past,
    channel: 'engineering',
    token: process.env.SLACK_TOKEN!,
    readLimit: 100,
    includeAttachments: true,
  },
};

const response = await graphlit.createFeed(feedInput);
const feedId = response.createFeed.id;

console.log(`Slack feed created: ${feedId}`);

// Step 3: Poll for feed completion
while (true) {
  const status = await graphlit.isFeedDone(feedId);
  if (status.isFeedDone.result) {
    break;
  }
  console.log('Still syncing Slack messages...');
  await new Promise((resolve) => setTimeout(resolve, 10_000));
}

console.log('Slack feed sync complete!');

Parameters

FeedInput (Required)

  • name (string): Display name for the feed

  • type (FeedTypes): Must be SLACK

  • slack (SlackFeedPropertiesInput): Slack-specific configuration

SlackFeedPropertiesInput (Required)

  • type (FeedListingTypes): Past (backfill then continue) or New (new items only)

  • channel (string): Slack channel name (one channel per feed)

  • token (string): Slack token (Token auth) or use connector (Connector auth)

  • includeAttachments (boolean, optional): include file attachments

  • readLimit (int, optional): items per poll/run

Optional

  • correlationId (string): For tracking in production

  • collections (EntityReferenceInput[]): Auto-add synced messages to collections

  • workflow (EntityReferenceInput): Apply workflow to messages

Response

Developer Hints

OAuth Token Requirements

Slack OAuth Scopes Needed:

  • channels:read - List public channels

  • channels:history - Read public channel messages

  • groups:read - List private channels (if needed)

  • groups:history - Read private channel messages (if needed)

  • users:read - Get user information

Getting a Slack Token:

  1. Create Slack App at https://api.slack.com/apps

  2. Add OAuth scopes under "OAuth & Permissions"

  3. Install app to workspace

  4. Copy Bot User OAuth Token (starts with xoxb-)

Feed is Continuous Sync

Important: Feeds run continuously. To stop syncing, disable or delete the feed.

Polling for Initial Sync

Channel Discovery

Variations

1. Sync Specific Channels Only

Create multiple feeds (one per channel):

2. Sync with Auto-Collection

Automatically add messages to a collection:

3. Sync with Entity Extraction

Extract people and topics from messages:

4. Query Synced Messages

Search through synced Slack messages:

5. Multi-Channel Pattern with Filtering

Sync multiple channels and filter by date:

Common Issues

Issue: Invalid token error Solution: Ensure Slack token has required OAuth scopes. Regenerate token with correct scopes.

Issue: Channel not found Solution: Use querySlackChannels() to confirm the exact channel name. The app/user must have access to the channel.

Issue: Feed created but no messages syncing Solution: Verify token has channels:history scope and the app/user has access to the channel.

Issue: Feed sync taking too long Solution: This is normal for channels with many messages. Use isFeedDone() to poll. Initial sync can take minutes for large channels.

Production Example

Last updated