Load Slack data to Microsoft SQL Server
Build a Slack to Microsoft SQL Server pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Slack API base URL, auth, endpoints, and incremental loading.
Slack conversations.history retrieves messages and events from a specified Slack conversation, with time-range and cursor-based pagination support. Everything needed to build a working Slack → Microsoft SQL Server pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.
Build your Slack to Microsoft SQL Server pipeline
Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.
uvx dlthub-init@latest to build a pipeline from Slack to Microsoft SQL Server and run it on dltHubThat scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the Slack API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →
Prefer to write it yourself? Every fact the agent uses is below.
Slack API at a glance
| Base URL | https://slack.com/api/ |
| Example endpoint | GET conversations.history |
| Records found at | messages |
| Authentication | all requests require a Bearer bot token — sent in the Authorization header, prefixed Bearer |
| Pagination | Cursor-based via cursor, next cursor at response_metadata.next_cursor, page size via limit (default 100, max 999). Conversations.history uses cursor-based pagination: send cursor=response_metadata.next_cursor on the next request. Set limit to control the maximum results per call; Slack recommends no more than 200, and the general Web API pagination documentation states a maximum of 1000, while the method's SDK reference specifies a maximum of 999. Do not treat oldest as the REST pagination cursor: oldest is a timestamp filter for messages after that time. A separate timestamp-based traversal is documented for time-bounded history responses: when has_more is true, set the final message's ts as latest for the next call. Responses can contain fewer than the requested limit even when more results exist; rely on next_cursor/has_more as documented. |
| Incremental field | ts |
| Record id | ts |
| API reference | https://docs.slack.dev/reference/methods/conversations.history |
These values come from the Slack API reference — the authoritative source if anything here looks out of date.
How do I authenticate with the Slack API?
Send the bot access token in the HTTP header Authorization: Bearer xoxb-…. Slack says tokens should be transmitted as bearer tokens in Authorization; do not put the token in the query string or JSON body. For JSON POST requests, set Content-Type: application/json; GET requests may use query parameters for method arguments.
1. Get your credentials
- Go to https://api.slack.com/apps and select Create New App, choose From scratch, enter an app name, select the development workspace, and create the app. 2. Open OAuth & Permissions. Under Bot Token Scopes, select Add an OAuth Scope and add the history scope required for the conversation type: channels for public channels, groups for private channels, im for direct messages, and mpim for group direct messages. 3. Click Install to Workspace (or Reinstall to Workspace), review the requested permissions, and click Allow. 4. Return to OAuth & Permissions and copy the Bot User OAuth Token under OAuth Tokens; bot tokens begin with xoxb-. Keep it secret and store it outside source control. For an app distributed to multiple workspaces, implement Slack OAuth v2 and obtain an installation access token per workspace instead of relying on the single-workspace dashboard token.
2. Add them to .dlt/secrets.toml
[sources.slack_source] api_key = "xoxb-your-slack-bot-token"
dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.
What Slack data can I load into Microsoft SQL Server?
These are the Slack endpoints dlt can load into Microsoft SQL Server:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| conversations_history | conversations.history | GET | messages | Read messages from a conversation. Supports channel, oldest, latest, inclusive, limit, and cursor pagination via cursor; bearer token in Authorization header. For time-based incremental loading, send the previously stored latest message ts as oldest (use inclusive=false, the documented default, to avoid replaying the boundary). Continue paging with response_metadata.next_cursor when present. |
| conversations_list | conversations.list | GET | channels | List channel-like conversations visible to the token. Cursor pagination uses limit and response_metadata.next_cursor; limit must be under 1000 and Slack recommends no more than 200. |
| conversations_replies | conversations.replies | GET | messages | Retrieve a thread's messages using channel and parent ts; supports oldest, latest, inclusive, limit, and cursor pagination. |
| conversations_members | conversations.members | GET | members | List members of a conversation; cursor-paginated with limit and response_metadata.next_cursor. |
| users_list | users.list | GET | members | List workspace users; cursor-paginated with limit and response_metadata.next_cursor. |
| reactions_list | reactions.list | GET | items | List items reacted to by the authenticated user; cursor-paginated with limit and response_metadata.next_cursor. |
| stars_list | stars.list | GET | items | List items starred by the authenticated user; cursor-paginated with limit and response_metadata.next_cursor. |
How do I load only new Slack records?
Slack exposes ts on conversations.history, so dlt can request only the records that changed since the last run. Set it as the cursor_path and dlt tracks the high-water mark for you between runs.
{"name": "conversations_history", "endpoint": { "path": "conversations.history", "data_selector": "messages", "incremental": {"cursor_path": "ts", "initial_value": "2024-01-01T00:00:00Z"}, }}
On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.
What does the generated Slack pipeline look like?
A standard dlt REST API pipeline — the same code you would write by hand, loading conversations.history and conversations.replies from the Slack API into Microsoft SQL Server:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def slack_source(token=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://slack.com/api/", "auth": {"type": "bearer", "token": token}, }, "resources": [ {"name": "conversations_history", "endpoint": {"path": "conversations.history", "data_selector": "messages"}}, {"name": "conversations_list", "endpoint": {"path": "conversations.list", "data_selector": "channels"}} ], } yield from rest_api_resources(config) def load_slack_to_mssql() -> None: pipeline = dlt.pipeline( pipeline_name="slack_pipeline", destination="mssql", dataset_name="slack_data", ) load_info = pipeline.run(slack_source()) print(load_info) if __name__ == "__main__": load_slack_to_mssql()
Run it with uv run python slack_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.
How do I query Slack data in Microsoft SQL Server?
dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("slack_pipeline").dataset() df = data.conversations_history.df() print(df.head())
SQL:
SELECT * FROM slack_data.conversations_history LIMIT 10;
See querying your data with dataset and exploring it in marimo notebooks.
How do I deploy the Slack to Microsoft SQL Server pipeline in production?
The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.
- Deploy & schedule — run the pipeline as a managed job with automatic retries.
- Monitor — observable job queues, alerting, and load metrics for every run.
- Transform — promote raw Slack loads into governed, documented models.
- Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.
What other destinations can I load Slack data to?
dlt loads into any of these — only the destination argument changes:
| Destination | Example value |
|---|---|
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.
Next steps
Was this page helpful?
Community Hub
Need more dlt context for Slack to Microsoft SQL Server?
Request dlt skills, commands, AGENT.md files, and AI-native context.