{"_id":"@bcpros/nestjs-slack-bolt","name":"@bcpros/nestjs-slack-bolt","dist-tags":{"latest":"1.1.0"},"versions":{"1.1.0":{"name":"@bcpros/nestjs-slack-bolt","version":"1.1.0","description":"A Nestjs module using Slack Bold SDK","author":{"name":"bamada"},"license":"MIT","url":"https://github.com/bamada/nest-slack-bolt#readme","scripts":{"test":"jest","build":"tsc -p tsconfig.json","format":"prettier --write \"**/*.ts\"","lint":"eslint \"src/**/*.ts\" --fix","prepublish:next":"npm run build","publish:next":"npm publish --access public --tag next","prepublish:npm":"npm run build","publish:npm":"npm publish --access public","prerelease":"npm run build","release":"release-it","prepare":"husky install"},"dependencies":{"@commitlint/cli":"18.6.0","@commitlint/config-angular":"18.6.0","@nestjs/common":"^10.1.3","@nestjs/config":"3.1.1","@nestjs/core":"^10.1.3","@slack/bolt":"3.17.1","husky":"9.0.2","reflect-metadata":"0.1.14"},"devDependencies":{"@nestjs/cli":"10.3.0","@nestjs/schematics":"10.1.0","@nestjs/testing":"10.3.1","@release-it/conventional-changelog":"^8.0.0","@types/jest":"29.5.11","@types/node":"20.11.6","@types/supertest":"6.0.2","@typescript-eslint/eslint-plugin":"6.19.1","@typescript-eslint/parser":"6.19.1","eslint":"8.56.0","eslint-config-prettier":"9.1.0","eslint-plugin-prettier":"5.1.3","jest":"29.7.0","lint-staged":"15.2.0","prettier":"3.2.4","release-it":"^17.0.0","rxjs":"7.8.1","source-map-support":"0.5.21","supertest":"6.3.4","ts-jest":"29.1.2","ts-node":"10.9.2","tsconfig-paths":"4.2.0","typescript":"5.3.3"},"peerDependencies":{"@nestjs/common":"^9.0.0 || ^10.1.3","@nestjs/core":"^9.0.0 || ^10.1.3","reflect-metadata":"0.1.14","rxjs":"^7.2.0"},"lint-staged":{"**/*.{ts,json}":[]},"jest":{"moduleFileExtensions":["js","json","ts"],"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":"ts-jest"},"collectCoverageFrom":["**/*.(t|j)s"],"coverageDirectory":"../coverage","testEnvironment":"node"},"repository":{"type":"git","url":"git+https://github.com/bamada/nest-slack-bolt.git"},"types":"./index.d.ts","gitHead":"b7d9e8fd1b1a029ee3951b00b01a6962f287296c","bugs":{"url":"https://github.com/bamada/nest-slack-bolt/issues"},"homepage":"https://github.com/bamada/nest-slack-bolt#readme","_id":"@bcpros/nestjs-slack-bolt@1.1.0","_nodeVersion":"20.2.0","_npmVersion":"9.6.6","dist":{"integrity":"sha512-DU5GgxrpTqljxGmumoiAPyV+d8gyzPycmdXIlYw48HgqiiNSL7g0JpYpKSOmifT8+gfsJjVl0aaKG5Mf46sbBg==","shasum":"70d83a5342a7aa5e3e3c94cfbf0133d53fb1256a","tarball":"https://registry.npmjs.org/@bcpros/nestjs-slack-bolt/-/nestjs-slack-bolt-1.1.0.tgz","fileCount":51,"unpackedSize":63280,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEViS0FUE/R1RnFEckPTpghghfUSqqDoYIFPxqIcW76nAiB7as1sPplzNNAkQw25qt+9b230PKpjXW8G08U3sfXygw=="}]},"_npmUser":{"name":"ngocviet","email":"vince.tran8x@gmail.com"},"directories":{},"maintainers":[{"name":"ngocviet","email":"vince.tran8x@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-slack-bolt_1.1.0_1707048345977_0.16864383763918722"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-04T12:05:45.867Z","1.1.0":"2024-02-04T12:05:46.179Z","modified":"2024-02-04T12:05:46.454Z"},"maintainers":[{"name":"ngocviet","email":"vince.tran8x@gmail.com"}],"description":"A Nestjs module using Slack Bold SDK","homepage":"https://github.com/bamada/nest-slack-bolt#readme","repository":{"type":"git","url":"git+https://github.com/bamada/nest-slack-bolt.git"},"author":{"name":"bamada"},"bugs":{"url":"https://github.com/bamada/nest-slack-bolt/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <a href=\"https://github.com/bamada/nest-slack-bolt\" target=\"blank\"><img src=\"logo.svg\" width=\"100\" alt=\"Nestjs Slack Bolt\" /></a>\n</p>\n\n[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456\n[circleci-url]: https://circleci.com/gh/nestjs/nest\n\n<p align=\"center\">A <a href=\"http://nestjs.com/\" target=\"blank\">Nestjs</a> module to interact seamlessly with <a href=\"https://api.slack.com/\" target=\"_blank\">Slack</a> API using the <a href=\"https://api.slack.com/bolt\">Bolt</a> SDK.</p>\n\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\n---\n## Table of Contents\n- [Description](#description)\n- [Features](#features)\n- [Installation](#installation)\n- [Setting Up](#setting-up)\n- [Usage](#usage)\n- [Examples](#examples)\n    - [Using annotations](#using-annotations)\n      - [Handling a message event](#handling-a-message-event)      \n      - [Handling an action](#handling-an-action)\n      - [Handling a command](#handling-a-command)\n      - [Handling an event](#handling-an-event)\n      - [Handling a shortcut event](#handling-a-shortcut-event)\n    - [Using the SlackService](#using-the-slackservice)\n- [To-Do List](#to-do-list)\n- [Contribute & Disclaimer](#contribute--disclaimer)\n- [Contributors](#contributors-)\n\n--- \n\n## Description\n\nThis module gives a handy way to develop Slack applications using the Nestjs framework\n\n## Features\n\nThe Nestjs Slack Bolt module offers the following features to simplify the interaction between your application and Slack API:\n\n- Message Handling\n- Command Handling\n- Action Handling\n- Event Handling\n- Shortcut Handling\n\n---\n## Installation\n\nThe module can be installed using yarn or npm:\n\n```bash\n$ yarn add nestjs-slack-bolt\n```\n\nOR\n\n```bash\n$ npm i nestjs-slack-bolt\n```\n\n---\n\n## Setting Up\n\nAdd these variables to the `.env` file to set up the module:\n\n```bash\n# To define on API mode\nSLACK_SIGNING_SECRET=\"**\"\n\n# To define on Socket mode\nSLACK_APP_TOKEN=\"**\"\n\n# Required variables\nSLACK_BOT_TOKEN=\"**\"\nSLACK_SOCKET_MODE=true\n```\n\n---\n## Usage\n\nTo use the module, import the `SlackModule`:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { SlackModule } from 'nestjs-slack-bolt';\nimport { AppController } from './app.controller';\nimport { AppService } from './app.service';\n\n@Module({\n  imports: [SlackModule.forRoot()],\n  controllers: [AppController],\n  providers: [AppService],\n})\nexport class AppModule {}\n```\n\n---\n\n## Examples\n\nHere are a few examples to demonstrate how you can use the Nestjs Slack Bolt module in your application:\n\n### Using annotations\n#### Handling a message event\n```typescript\nimport { Controller } from '@nestjs/common';\nimport { Message } from 'nestjs-slack-bolt';\nimport { SlackEventMiddlewareArgs } from '@slack/bolt';\n\n@Controller()\nexport class AppController {\n  @Message('hi')\n  message({ say }: SlackEventMiddlewareArgs) {\n    say('Hello, I received your message!');\n  }\n  // Other handlers...\n}\n```\n\n#### Handling an action\n```typescript\nimport { Controller } from '@nestjs/common';\nimport { Action } from 'nestjs-slack-bolt';\nimport { SlackActionMiddlewareArgs } from '@slack/bolt';\n\n@Controller()\nexport class AppController {\n  @Action('click')\n  action({ say }: SlackActionMiddlewareArgs) {\n    say('Click event received, nice job!');\n  }\n  // Other handlers...\n}\n```\n#### Handling a command\n```typescript\nimport { Controller } from '@nestjs/common';\nimport { Command } from 'nestjs-slack-bolt';\nimport { SlackCommandMiddlewareArgs } from '@slack/bolt';\n\n@Controller()\nexport class AppController {\n  @Command('/list')\n  command({ say }: SlackCommandMiddlewareArgs) {\n    say('The /list command has been received. Processing...');\n  }\n  // Other handlers...\n}\n```\n#### Handling an event\n```typescript\nimport { Controller } from '@nestjs/common';\nimport { Event } from 'nestjs-slack-bolt';\nimport { SlackEventMiddlewareArgs } from '@slack/bolt';\n\n@Controller()\nexport class AppController {\n  @Event('app_home_opened')\n  event({ say }: SlackEventMiddlewareArgs) {\n    say('The app was just opened!');\n  }\n  // Other handlers...\n}\n```\n#### Handling a shortcut event\n```typescript\nimport { Controller } from '@nestjs/common';\nimport { Shortcut } from 'nestjs-slack-bolt';\n\n@Controller()\nexport class AppController {\n  @Shortcut('test_shortcut')\n  async shortcut({ shortcut, ack, client, logger }) {\n    try {\n      await ack(); //Acknowledge shortcut request\n\n      const result = await client.views.open({\n        trigger_id: shortcut.trigger_id,\n        view: { /* Your view parameters */ }\n      });\n\n      logger.info(result); // Log the result\n    } \n    catch (error) {\n      logger.error(error); // Log any error\n    }\n  }\n  // Other handlers...\n}\n```\nThese examples demonstrate how to handle different types of interactions in your Slack application using the NestJS Slack Bolt module.\n\n### Using the SlackService\n\n```typescript\nimport { Controller } from '@nestjs/common';\nimport { ConfigService } from '@nestjs/config';\nimport { SlackService } from 'nestjs-slack-bolt/services/slack.service';\nimport { Cron, CronExpression } from '@nestjs/schedule';\nimport { from } from 'rxjs';\n\n@Controller()\nexport class AppController {\n  constructor(\n    private readonly slackService: SlackService,\n    private readonly configService: ConfigService,\n  ) {}\n\n  @Cron(CronExpression.EVERY_10_SECONDS)\n  cronJob() {\n    this.searchUsers()\n      .pipe()\n      .subscribe((users) => {\n        console.log(JSON.stringify(users));\n      });\n  }\n\n  searchUsers(cursor?: string) {\n    return from(\n      this.slackService.client.users.list({\n        token: this.configService.get('SLACK_BOT_TOKEN'),\n        limit: 1,\n        ...(cursor && { cursor }),\n      }),\n    );\n  }\n}\n```\n\n---\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/bamada\"><img src=\"https://avatars.githubusercontent.com/u/7466570?v=4?s=100\" width=\"100px;\" alt=\"madcam\"/><br /><sub><b>madcam</b></sub></a><br /><a href=\"https://github.com/bamada/nest-slack-bolt/commits?author=bamada\" title=\"Tests\">⚠️</a> <a href=\"https://github.com/bamada/nest-slack-bolt/commits?author=bamada\" title=\"Code\">💻</a> <a href=\"https://github.com/bamada/nest-slack-bolt/commits?author=bamada\" title=\"Documentation\">📖</a> <a href=\"https://github.com/bamada/nest-slack-bolt/issues?q=author%3Abamada\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/nadirabbas\"><img src=\"https://avatars.githubusercontent.com/u/38838675?v=4?s=100\" width=\"100px;\" alt=\"Nadir Abbas\"/><br /><sub><b>Nadir Abbas</b></sub></a><br /><a href=\"https://github.com/bamada/nest-slack-bolt/commits?author=nadirabbas\" title=\"Tests\">⚠️</a> <a href=\"https://github.com/bamada/nest-slack-bolt/commits?author=nadirabbas\" title=\"Documentation\">📖</a> <a href=\"https://github.com/bamada/nest-slack-bolt/issues?q=author%3Anadirabbas\" title=\"Bug reports\">🐛</a> <a href=\"https://github.com/bamada/nest-slack-bolt/commits?author=nadirabbas\" title=\"Code\">💻</a></td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","readmeFilename":"README.md"}