Skip to content

AGENTS.md

81 lines · 2.3 KB · Markdown
Raw

@kentcdodds/slack — agent notes

Human setup and intent live in README.md. This file is for agents: imports, smoke/dryRun snippets, and edge cases. Auth is the saved OAuth integration named slack (user token). Do not paste tokens. Do not disable live webhooks or jobs.

Auth

  • Integration id: slack (via createAuthenticatedFetch('slack'))
  • Must be a Slack user token (xoxp-… style), never a bot token
  • API origin: https://slack.com

Import paths

ExportImport
overview / safety metadatakody:@kentcdodds/slack
smoke-testkody:@kentcdodds/slack/smoke-test
list-conversationskody:@kentcdodds/slack/list-conversations
list-userskody:@kentcdodds/slack/list-users
get-historykody:@kentcdodds/slack/get-history
get-replieskody:@kentcdodds/slack/get-replies
send-messagekody:@kentcdodds/slack/send-message

Prefer static kody:@kentcdodds/slack/... imports from execute.

Smoke test (read-only)

import smokeTest from 'kody:@kentcdodds/slack/smoke-test'

export default async function main() {
	return await smokeTest()
	// => { ok: true, userIdentity: true, botIdentity: false, teamIdentity }
	// throws if token looks like a bot
}

dryRun / confirm (send)

Preview never calls Slack:

import sendMessage from 'kody:@kentcdodds/slack/send-message'

export default async function main() {
	return await sendMessage({
		channel: 'C0123456789',
		text: 'Hello from Kody',
		dryRun: true,
	})
	// => { dryRun: true, method: 'chat.postMessage', identity: 'authorizing-user', payload }
}

Live send requires explicit user approval of destination + content, then confirm: true (not only dryRun: false).

Read helpers

import listConversations from 'kody:@kentcdodds/slack/list-conversations'

export default async function main() {
	return await listConversations({
		types: ['public_channel', 'private_channel'],
	})
}

types may include only: public_channel, private_channel, im, mpim.

Edge cases

  • Private channels / DMs only if the authorizing user can already see them.
  • send-message throws without confirm: true when not dry-running.
  • Optional send fields: threadTs, blocks (array), unfurlLinks, unfurlMedia.
  • Always prefer dry-run before any live send; never treat smoke as permission to post.