1.0.2 • Published 10 months ago
@aschlean/slack-wrap v1.0.2
Slack Wrapper
A TypeScript wrapper around Slack's Bolt.js framework that simplifies message sending and monitoring capabilities.
Setup
- Install dependencies:
npm install @aschlean/slack-wrapSet up your Slack app and get the following credentials:
- Bot Token (
SLACK_BOT_TOKEN) - Signing Secret (
SLACK_SIGNING_SECRET) - App Token (
SLACK_APP_TOKEN)
- Bot Token (
Set up environment variables with your Slack credentials:
export SLACK_BOT_TOKEN='xoxb-your-token'
export SLACK_SIGNING_SECRET='your-signing-secret'
export SLACK_APP_TOKEN='xapp-your-app-token'Usage
import { SlackWrapper } from '@aschlean/slack-wrap';
const wrapper = new SlackWrapper({
token: process.env.SLACK_BOT_TOKEN!,
signingSecret: process.env.SLACK_SIGNING_SECRET!,
appToken: process.env.SLACK_APP_TOKEN!
});
wrapper.onMessage(async (message) => {
const userInfo = await wrapper.getUserInfo(message.user);
await wrapper.replyToMessage(message, `Hello ${userInfo.realName}!`);
});
await wrapper.start();Features
- Send messages to channels and threads
- Monitor incoming messages
- Get user information
- Register and remove message handlers
- TypeScript support with full type definitions
Requirements
- Node.js 14+
- TypeScript 4+
- Slack App with appropriate permissions:
chat:write(for sending messages)channels:history(for reading public channels)groups:history(for reading private channels)im:history(for reading direct messages)mpim:history(for reading group DMs)users:read(for fetching user information)