@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:writechannels:history,channels:readgroups:history,groups:readim:history,im:readmpim:history,mpim:readusers: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 metadatakody:@kentcdodds/slack/smoke-test— verify that the saved token is authenticated as a user, not a botkody:@kentcdodds/slack/list-conversations— list public channels, private channels, DMs, and group DMskody:@kentcdodds/slack/list-users— list workspace users for resolving message authorskody:@kentcdodds/slack/get-history— read one conversation's message historykody:@kentcdodds/slack/get-replies— read a message threadkody:@kentcdodds/slack/send-message— preview or send a message; sending requiresconfirm: 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.