---
name: slack-sync
description: >
  Pull latest Slack messages from active conversations into WALL-E's brain.
  Discovers recently active channels, fetches new messages incrementally.
  Use for keeping Slack context fresh.
version: 1.0.0
author: wall-e
execution: script
entry: ../../../scripts/slack-channel-history.js
args: ["--sync"]
trigger:
  type: interval
  schedule: "every 15m"
requires:
  env:
    - SLACK_OWNER_USER_ID
config:
  mode:
    type: string
    enum: [incremental, full]
    default: incremental
tags: [slack, messaging, sync, ingestion]
permissions:
  - slack:read
  - brain:write
---
# Slack Conversation Sync

## What This Skill Does

Incrementally syncs Slack messages from your most active conversations
into WALL-E's brain. Only checks recently active channels (last 7 days)
to minimize API calls and run time.

## How It Works

1. Search Slack for YOUR recent messages to discover active channels
2. Query brain DB for channels with recent activity (last 3 days)
3. For each active channel, fetch messages since last sync using pagination
4. Deduplicate and store new messages as memories with source_id
5. Emit CHECKPOINT after each channel for resume support

## Configuration

- `mode: incremental` (default) -- Only pulls channels with activity in the last 7 days (~35 channels, ~1 min)
- `mode: full` -- Pulls ALL known channels (~800 channels, ~15 min)

## Output

Prints progress per channel and emits CHECKPOINT lines for task runner resume support.
Returns summary: `{ new_messages, skipped, channels_done, total_after }`

## Error Handling

- Slack token expiry triggers exit code 1 with clear error message
- Channel not found errors are logged and skipped
- Other errors are logged per-channel and processing continues
