Slack
Read Slack channels, people and messages, and post messages, from DuckDB SQL
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available Β· $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/slack/index.md to help me query Slack with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Find your largest Slack channels
SELECT name, num_members
FROM slack.main.channels()
WHERE is_member
ORDER BY num_members DESC
LIMIT 10
Quick start
Choose where to run Slack, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach the release directly
Downloads the latest release for your platform and caches it locally.
ATTACH 'slack' AS slack (
TYPE vgi,
LOCATION 'github-auto://Query-farm/vgi-slack'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'slack' AS slack (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-slack:0.2.0'
);
3. Run a query
SELECT name, num_members
FROM slack.main.channels()
WHERE is_member
ORDER BY num_members DESC
LIMIT 10
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connectorβs deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'slack' AS slack
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT name, num_members
FROM slack.main.channels()
WHERE is_member
ORDER BY num_members DESC
LIMIT 10
Query Farm operates Slack for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use slack as the catalog alias for the query below.
4. Run a query
SELECT name, num_members
FROM slack.main.channels()
WHERE is_member
ORDER BY num_members DESC
LIMIT 10
Technical details
- Verified connector release
- v0.2.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until youβre ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach the release directly
Uses the verified release each time you attach the connector.
ATTACH 'slack' AS slack (
TYPE vgi,
LOCATION 'github-auto://Query-farm/[email protected]'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'slack' AS slack (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-slack:0.2.0'
);
Overview
Slack workspace data as SQL tables: channels, people, channel history and threads, read through the Slack Web API with a bot token, plus posting messages from a query.
Query Slack channels, people and messages, and post messages, from SQL.
Attach with a bot token: ATTACH 'slack' (TYPE vgi, LOCATION '/abs/path/bin/vgi-slack-worker', token getenv('SLACK_BOT_TOKEN')). The token is declared secret, so DuckDB redacts it from duckdb_databases() and never logs it.
Bot token scopes: channels:read, groups:read, channels:history, groups:history, users:read (plus users:read.email for emails) and chat:write. Invite the bot to every channel it should read or post in.
Sources and references
- Slack Web API: the HTTP API every function calls, with the method reference for
conversations.*,users.list,auth.testandchat.postMessage. - Slack apps: create an app and install it to get the bot token; token types explains bot tokens.
- OAuth scopes: what each scope above grants.
ATTACH options
- token
- Slack bot token (xoxb-...). Pass it as an expression to keep it out of the SQL text: token getenv('SLACK_BOT_TOKEN').VARCHAR
- api_url
- Slack Web API root URL. Change it only for a proxy or a test server.VARCHAR
Catalog
Everything slack exposes once attached β read straight from the worker's
released build.
main 7 functions
Slack readers for channels, people and conversations, and writers that post messages.
Schema examples (14)
Check which workspace and bot the token is for
SELECT team, user, bot_id FROM slack.main.auth_info();
The ten largest channels the bot is in
SELECT name, num_members
FROM slack.main.channels()
WHERE is_member
ORDER BY num_members DESC
LIMIT 10;
Count public and private channels, including archived ones
SELECT is_private, count(*) AS channels
FROM slack.main.channels(exclude_archived := false)
GROUP BY is_private;
Who created each channel the bot can see, oldest channel first (include_deleted keeps creators who have left)
SELECT c.name, u.real_name AS created_by, c.created_at
FROM slack.main.channels() c
LEFT JOIN slack.main.users(include_deleted := true) u ON u.id = c.creator
ORDER BY c.created_at;
10 more examples
Where the workspace's people are, by time zone
SELECT tz, count(*) AS people
FROM slack.main.users()
WHERE NOT is_bot
GROUP BY tz
ORDER BY people DESC;
Most active people in #general since the start of 2026
SELECT u.real_name, count(*) AS messages
FROM slack.main.messages('#general', oldest := TIMESTAMPTZ '2026-01-01') m
JOIN slack.main.users() u ON u.id = m.user_id
GROUP BY u.real_name
ORDER BY messages DESC
LIMIT 10;
The twenty latest messages in a channel, by ID
SELECT posted_at, text
FROM slack.main.messages('C0123ABCD')
ORDER BY posted_at DESC
LIMIT 20;
Read one thread in order
SELECT posted_at, user_id, text
FROM slack.main.replies('#general', '1700000000.000100')
ORDER BY posted_at;
Read a thread (parent message first, then replies) with each author's real name instead of a user ID
SELECT r.posted_at, coalesce(u.real_name, r.user_id) AS author, r.text
FROM slack.main.replies('#general', '1767225900.000100') r
LEFT JOIN slack.main.users(include_deleted := true) u ON u.id = r.user_id
ORDER BY r.posted_at;
Announce a deploy and keep the message ts
SELECT channel_id, ts
FROM slack.main.post_message('#deploys', 'Deployed *v1.2* :rocket:');
Reply in an existing thread
SELECT ts
FROM slack.main.post_message('#deploys', 'Rollback finished', thread_ts := '1700000000.000100');
Dry run: an empty input posts nothing (no token or network needed)
SELECT count(*) AS posted
FROM slack.main.post_messages((SELECT '#alerts' AS channel, 'never sent' AS text WHERE false));
Post an alert per down host and count them
SELECT count(*) AS posted
FROM slack.main.post_messages((SELECT '#alerts' AS channel, 'Host ' || h || ' is down' AS text FROM (VALUES ('web-1'), ('web-2')) t(h)));
Reply in the thread of every unanswered message people posted in #general in the last day, and count the nudges
SELECT count(*) AS nudged
FROM slack.main.post_messages((SELECT channel_id AS channel, 'Bumping this: is anyone looking at it?' AS text, ts AS thread_ts FROM slack.main.messages('#general', oldest := now()::TIMESTAMP - INTERVAL 1 DAY) WHERE reply_count IS NULL AND subtype IS NULL AND bot_id IS NULL));
auth_info ()
Show which Slack workspace, user and bot the attached token belongs to
Check which workspace and bot the token is for
SELECT team, user, bot_id FROM slack.main.auth_info();
channels (exclude_archived := BOOLEAN, types := VARCHAR)
List the Slack channels the bot can see
The ten largest channels the bot is in
SELECT name, num_members
FROM slack.main.channels()
WHERE is_member
ORDER BY num_members DESC
LIMIT 10;
Count public and private channels, including archived ones
SELECT is_private, count(*) AS channels
FROM slack.main.channels(exclude_archived := false)
GROUP BY is_private;
Who created each channel the bot can see, oldest channel first (include_deleted keeps creators who have left)
SELECT c.name, u.real_name AS created_by, c.created_at
FROM slack.main.channels() c
LEFT JOIN slack.main.users(include_deleted := true) u ON u.id = c.creator
ORDER BY c.created_at;
messages (channel VARCHAR, latest := TIMESTAMP WITH TIME ZONE, oldest := TIMESTAMP WITH TIME ZONE)
Read a Slack channel's message history, newest first
Most active people in #general since the start of 2026
SELECT u.real_name, count(*) AS messages
FROM slack.main.messages('#general', oldest := TIMESTAMPTZ '2026-01-01') m
JOIN slack.main.users() u ON u.id = m.user_id
GROUP BY u.real_name
ORDER BY messages DESC
LIMIT 10;
The twenty latest messages in a channel, by ID
SELECT posted_at, text
FROM slack.main.messages('C0123ABCD')
ORDER BY posted_at DESC
LIMIT 20;
post_message (channel VARCHAR, text VARCHAR, thread_ts := VARCHAR)
Post one message to a Slack channel and return its ts
Announce a deploy and keep the message ts
SELECT channel_id, ts
FROM slack.main.post_message('#deploys', 'Deployed *v1.2* :rocket:');
Reply in an existing thread
SELECT ts
FROM slack.main.post_message('#deploys', 'Rollback finished', thread_ts := '1700000000.000100');
replies (channel VARCHAR, thread_ts VARCHAR)
Read a Slack thread: the parent message and its replies, oldest first
Read one thread in order
SELECT posted_at, user_id, text
FROM slack.main.replies('#general', '1700000000.000100')
ORDER BY posted_at;
Read a thread (parent message first, then replies) with each author's real name instead of a user ID
SELECT r.posted_at, coalesce(u.real_name, r.user_id) AS author, r.text
FROM slack.main.replies('#general', '1767225900.000100') r
LEFT JOIN slack.main.users(include_deleted := true) u ON u.id = r.user_id
ORDER BY r.posted_at;
users (include_deleted := BOOLEAN)
List the members of the Slack workspace
Where the workspace's people are, by time zone
SELECT tz, count(*) AS people
FROM slack.main.users()
WHERE NOT is_bot
GROUP BY tz
ORDER BY people DESC;
post_messages (data TABLE)
Post one Slack message per input row (columns channel, text, optional thread_ts)
Dry run: an empty input posts nothing (no token or network needed)
SELECT count(*) AS posted
FROM slack.main.post_messages((SELECT '#alerts' AS channel, 'never sent' AS text WHERE false));
Post an alert per down host and count them
SELECT count(*) AS posted
FROM slack.main.post_messages((SELECT '#alerts' AS channel, 'Host ' || h || ' is down' AS text FROM (VALUES ('web-1'), ('web-2')) t(h)));
Reply in the thread of every unanswered message people posted in #general in the last day, and count the nudges
SELECT count(*) AS nudged
FROM slack.main.post_messages((SELECT channel_id AS channel, 'Bumping this: is anyone looking at it?' AS text, ts AS thread_ts FROM slack.main.messages('#general', oldest := now()::TIMESTAMP - INTERVAL 1 DAY) WHERE reply_count IS NULL AND subtype IS NULL AND bot_id IS NULL));
Try these queries
Check which workspace and bot the token is for
SELECT team, user, bot_id FROM slack.main.auth_info()
Uses auth_info
Count public and private channels, including archived ones
SELECT is_private, count(*) AS channels
FROM slack.main.channels(exclude_archived := false)
GROUP BY is_private
Uses channels
Where the workspace's people are, by time zone
SELECT tz, count(*) AS people
FROM slack.main.users()
WHERE NOT is_bot
GROUP BY tz
ORDER BY people DESC
Uses users
Most active people in #general since the start of 2026
SELECT u.real_name, count(*) AS messages
FROM slack.main.messages('#general', oldest := TIMESTAMPTZ '2026-01-01') m
JOIN slack.main.users() u ON u.id = m.user_id
GROUP BY u.real_name
ORDER BY messages DESC
LIMIT 10
Read one thread in order
SELECT posted_at, user_id, text
FROM slack.main.replies('#general', '1700000000.000100')
ORDER BY posted_at
Uses replies
Announce a deploy and keep the message ts
SELECT channel_id, ts
FROM slack.main.post_message('#deploys', 'Deployed *v1.2* :rocket:')
Uses post_message
7 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- Using the slack worker, which Slack workspace (team name) is the bot connected to?
- Using the slack worker, list the names of the channels the bot is a member of.
- Using the slack worker, how many top-level messages are in the #general channel?
- Using the slack worker, which user (by real name) posted the most messages in #general?
Slack is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Discord
Dev & collaboration
Read guilds, channels, members and message history from Discord, post messages, and decode Discord ids and permissions
GitHub
Dev & collaboration
GitHub repositories, issues, pull requests, commits, releases, contributors and Actions runs
GitLab
Dev & collaboration
GitLab projects, merge requests, issues, CI pipelines, jobs and logs as SQL tables