@wemaintain/slack
v0.2.5
Published
Nest module for slack bots
Downloads
5
Readme
Installation
- Install the required packages
npm install --save @wemaintain/slack @slack/web-api @slack/events-api
- Import the SlackModule in your Module, ideally in the root module
@Module({
imports: [
SlackModule
],
controllers: [],
providers: [],
})
export class AppModule {}
Configuration
Configuration of the module can be acheived by using the forRoot
and forRootAsync
method
forRoot:
@Module({
imports: [
SlackModule.forRoot({
signingSecret: process.env.SLACK_SIGNING_SECRET
})
],
controllers: [],
providers: [],
})
export class AppModule {}
forRootAsync:
@Module({
imports: [
ConfigModule,
SlackModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (option) => option.slack
})
],
controllers: [],
providers: [],
})
export class AppModule {}
SlackClient: WebClient API
The SlackClient is a wrapper the WebClient
Slack API
Inject it inside your component like any other Provider:
constructor(
protected readonly slackService: SlackClient,
){}
SlackEvent: Event API
The SlackEventService is a service that listen for the Event
Slack API
If the signingSecret
is provided to the SlackModule it will look for @SlackEvent decorator in your controllers
And bind them to the webhook listener
@Controller()
export class AppController {
@SlackEvent('message')
onMessageInChannel(): void {
// Do thing
}
}