Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kentcdodds/slack

README.md

61 lines · 2.1 KB · Markdown

@kentcdodds/slack

Intent

Provide reusable, headless Slack helpers that let Kody read conversations the authorizing user can access and send explicitly confirmed messages as that user, never as a bot.

Required setup

Create a Slack app for the target workspace and save a Kody OAuth integration named slack using Slack's user-only OAuth flow.

  • Redirect URL: https://kody.codes/connect/oauth
  • Authorize URL: https://slack.com/oauth/v2_user/authorize
  • Token URL: https://slack.com/api/oauth.v2.user.access
  • API host: slack.com
  • Flow: confidential
  • Scope separator: comma

Required user-token scopes:

  • chat:write
  • channels:history, channels:read
  • groups:history, groups:read
  • im:history, im:read
  • mpim:history, mpim:read
  • users:read

Workspace administrators may need to approve the app. Private-channel and direct-message access is limited to conversations available to the authorizing user.

Exports

  • kody:@kentcdodds/slack — package overview and safety metadata
  • kody:@kentcdodds/slack/smoke-test — verify that the saved token is authenticated as a user, not a bot
  • kody:@kentcdodds/slack/list-conversations — list public channels, private channels, DMs, and group DMs
  • kody:@kentcdodds/slack/list-users — list workspace users for resolving message authors
  • kody:@kentcdodds/slack/get-history — read one conversation's message history
  • kody:@kentcdodds/slack/get-replies — read a message thread
  • kody:@kentcdodds/slack/send-message — preview or send a message; sending requires confirm: true

Examples

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

export default async function main() {
  return listConversations({ types: ['public_channel', 'private_channel'] })
}
import sendMessage from 'kody:@kentcdodds/slack/send-message'

export default async function main() {
  return sendMessage({
    channel: 'C0123456789',
    text: 'Hello from Kody',
    dryRun: true,
  })
}

Set confirm: true only after the user has explicitly approved the exact message and destination. A dry run never calls Slack.