{"id":15393137,"url":"https://github.com/shgysk8zer0/slack","last_synced_at":"2026-04-15T08:39:19.085Z","repository":{"id":195583397,"uuid":"693231820","full_name":"shgysk8zer0/slack","owner":"shgysk8zer0","description":"An npm package for sending messages in Slack","archived":false,"fork":false,"pushed_at":"2026-04-08T21:43:07.000Z","size":238,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-08T23:27:43.248Z","etag":null,"topics":["node","npm","slack"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@shgysk8zer0/slack","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shgysk8zer0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"shgysk8zer0","liberapay":"shgysk8zer0"}},"created_at":"2023-09-18T15:57:23.000Z","updated_at":"2026-04-08T21:43:12.000Z","dependencies_parsed_at":"2023-09-18T21:36:52.912Z","dependency_job_id":"92f13e7b-9191-481e-9ff2-2eb2d2807d76","html_url":"https://github.com/shgysk8zer0/slack","commit_stats":null,"previous_names":["shgysk8zer0/slack"],"tags_count":7,"template":false,"template_full_name":"shgysk8zer0/npm-template","purl":"pkg:github/shgysk8zer0/slack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fslack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fslack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fslack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fslack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shgysk8zer0","download_url":"https://codeload.github.com/shgysk8zer0/slack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shgysk8zer0%2Fslack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31833836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T07:17:56.427Z","status":"ssl_error","status_checked_at":"2026-04-15T07:17:30.007Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node","npm","slack"],"created_at":"2024-10-01T15:17:57.725Z","updated_at":"2026-04-15T08:39:19.051Z","avatar_url":"https://github.com/shgysk8zer0.png","language":"JavaScript","funding_links":["https://github.com/sponsors/shgysk8zer0","https://liberapay.com/shgysk8zer0","https://liberapay.com/shgysk8zer0/donate"],"categories":[],"sub_categories":[],"readme":"# `@shgysk8zer0/slack`\n\nAn npm package for sending messages in Slack using [Incoming Webhooks](https://api.slack.com/messaging/webhooks)\n\n[![CodeQL](https://github.com/shgysk8zer0/slack/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/shgysk8zer0/slack/actions/workflows/codeql-analysis.yml)\n![Node CI](https://github.com/shgysk8zer0/slack/workflows/Node%20CI/badge.svg)\n![Lint Code Base](https://github.com/shgysk8zer0/slack/workflows/Lint%20Code%20Base/badge.svg)\n\n[![GitHub license](https://img.shields.io/github/license/shgysk8zer0/slack.svg)](https://github.com/shgysk8zer0/slack/blob/master/LICENSE)\n[![GitHub last commit](https://img.shields.io/github/last-commit/shgysk8zer0/slack.svg)](https://github.com/shgysk8zer0/slack/commits/master)\n[![GitHub release](https://img.shields.io/github/release/shgysk8zer0/slack?logo=github)](https://github.com/shgysk8zer0/slack/releases)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/shgysk8zer0?logo=github)](https://github.com/sponsors/shgysk8zer0)\n\n[![npm](https://img.shields.io/npm/v/@shgysk8zer0/slack)](https://www.npmjs.com/package/@shgysk8zer0/slack)\n![node-current](https://img.shields.io/node/v/@shgysk8zer0/slack)\n![npm bundle size gzipped](https://img.shields.io/bundlephobia/minzip/@shgysk8zer0/slack)\n[![npm](https://img.shields.io/npm/dw/@shgysk8zer0/slack?logo=npm)](https://www.npmjs.com/package/@shgysk8zer0/slack)\n\n[![GitHub followers](https://img.shields.io/github/followers/shgysk8zer0.svg?style=social)](https://github.com/shgysk8zer0)\n![GitHub forks](https://img.shields.io/github/forks/shgysk8zer0/slack.svg?style=social)\n![GitHub stars](https://img.shields.io/github/stars/shgysk8zer0/slack.svg?style=social)\n[![Twitter Follow](https://img.shields.io/twitter/follow/shgysk8zer0.svg?style=social)](https://twitter.com/shgysk8zer0)\n\n[![Donate using Liberapay](https://img.shields.io/liberapay/receives/shgysk8zer0.svg?logo=liberapay)](https://liberapay.com/shgysk8zer0/donate \"Donate using Liberapay\")\n- - -\n\n- [Code of Conduct](./.github/CODE_OF_CONDUCT.md)\n- [Contributing](./.github/CONTRIBUTING.md)\n\u003c!-- - [Security Policy](./.github/SECURITY.md) --\u003e\n\n## Installation\n\n### NPM\n\n```bash\nnpm i @shgysk8zer0/slack\n```\n\n### ESModule / unpkg\n\nThis package also works in browsers and can be imported from [unpkg.com](https://unpkg.com/browse/@shgysk8zer0/slack)\nfrom `https://unpkg.com/@shgys8zer0/slack/*`.\n\n## About\n\n`@shgysk8zer0/slack` is a JavaScript library that simplifies sending messages to Slack channels using [Incoming Webhooks](https://api.slack.com/messaging/webhooks). Whether you're building a web app, a Node.js script, or experimenting with Deno, this library makes Slack messaging a breeze.\n\n**Why This Library?**\n\n- **Simplicity**: Easily create Slack messages with user-friendly classes.\n- **Error Help**: Get detailed error messages for easier debugging.\n- **Versatile**: Use it in web apps, Node.js, and, to some extent, Deno.\n- **Customizable**: Tailor it to your needs.\n\nWhile this library is designed to be versatile, please note that full Deno support is not thoroughly tested. While many features work across different JavaScript environments, certain features, such as `SlackError.openInBlockKitBuilder()`, may not be fully compatible in Deno.\n\nThis library adapts to your JavaScript environment, making Slack messaging a snap without being tied to a specific platform.\n\n**Important Note**: While this library can be used in both server-side (Node.js) and client-side (browser) JavaScript applications, it's strongly recommended to avoid exposing webhook URLs in client-side code. Exposing sensitive information like webhook URLs to the public can pose security risks. For client-side applications, consider using this library within a server-side context or handling the Slack integration server-side to keep your webhook URLs secure.\n\n## Getting Started\n\nThis package uses Slack's Incoming Webhooks, which requires a little setup.\n\n1. [Create a Slack App](https://api.slack.com/apps/new)\n2. [Enable Incoming Webhooks](https://api.slack.com/apps)\n3. Create an Incoming Webhook\n\nSee [Sending messages using Incoming Webhooks | Slack](https://api.slack.com/messaging/webhooks) for full details.\n\n## Environment Setup\n\nIn a Node.js environment, you can set the SLACK_WEBHOOK_URL environment variable in your .env file or directly in your environment to avoid passing the URL to the constructor every time.\n\n```bash\n# .env file\nSLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxxx/xxxxxxxx\n```\n\nWhen using this package in a browser, you'll need to provide the webhook URL directly when constructing the SlackMessage instance.\n\n## Example\n\n### Import the classes\n\n#### Option 1 - Import from Individual Class Files\n\n```js\nimport { SlackMessage } from '@shgysk8zer0/slack/message.js';\nimport { SlackHeaderBlock } from '@shgysk8zer0/slack/block/header.js';\nimport { SlackPlainTextElement } from '@shgysk8zer0/slack/element/plain-text.js';\nimport { SlackMarkdownElement } from '@shgysk8zer0/slack/element/markdown.js';\nimport { SlackImageBlock } from '@shgysk8zer0/slack/block/image.js';\nimport { SlackDividerBlock } from '@shgysk8zer0/slack/block/divider.js';\nimport { SlackButtonElement } from '@shgysk8zer0/slack/element/button.js';\nimport { SlackSectionBlock } from '@shgysk8zer0/slack/block/section.js';\nimport { SlackError } from '@shgysk8zer0/slack/error.js';\n```\n\n#### Option 2 - Import the Entire Package\n\n```js\nimport {\n\tSlackHeader,\n\tSlackPlainText,\n\tSlackMarkdownElement,\n\tSlackImageBlock,\n\tSlackDividerBlock,\n\tSlackButtonElement,\n\tSlackSectionBlock,\n\tSlackError,\n} from '@shgysk8zer0/slack';\n```\n\n### Build and Send the Message\n\n### Class-Based Approach\n\n```js\n// Create a new SlackMessage instance with the specified webhook URL.\n// This is set to `process.env.SLACK_WEBHOOK_URL` as a default in node\nnew SlackMessage(SLACK_WEBHOOK_URL)\n\t.add(\n\t\t// Add a header block with a plain text element.\n\t\tnew SlackHeaderBlock(new SlackPlainTextElement('New Message from Slack Bot')),\n\t\t// Add a divider block to separate content.\n\t\tnew SlackDividerBlock(),\n\t\t// Add an image block with a title and alt text.\n\t\tnew SlackImageBlock('https://example.com/img.png', {\n\t\t\ttitle: new SlackPlainTextElement('Here is some image'),\n\t\t\talt: 'Some image',\n\t\t}),\n\t\t// Add a section block with Markdown-formatted text.\n\t\tnew SlackSectionBlock(\n\t\t\tnew SlackMarkdownElement('This is some example \u003cmarkdown | https://en.wikipedia.org/wiki/Markdown\u003e'), {\n\t\t\t\t// Add a button accessory with a primary style and a URL.\n\t\t\t\taccessory: new SlackButtonElement('Open link!', {\n\t\t\t\t\tstyle: 'primary',\n\t\t\t\t\turl: 'https://example.com',\n\t\t\t\t}),\n\t\t\t\t// Add plain text fields and a Markdown field for email and phone number.\n\t\t\t\tfields: [\n\t\t\t\t\tnew SlackPlainTextElement('Reply'),\n\t\t\t\t\tnew SlackMarkdownElement('*Email:* \u003cmailto:user@example.com | user@example.com\u003e'),\n\t\t\t\t\tnew SlackMarkdownElement('*Phone:* \u003ctel:+1-555-555-5555 | 555-555-5555\u003e'),\n\t\t\t\t],\n\t\t\t}\n\t\t)\n\t)\n\t// Send the constructed Slack message with a timeout of 5000 milliseconds using an AbortSignal.\n\t.send({ signal: AbortSignal.timeout(5000) })\n\t.then(() =\u003e {\n\t\t// Log a success message when the message is sent.\n\t\tconsole.log('Message sent');\n\t})\n\t// An error (a custom SlackError) was thrown\n\t.catch(async err =\u003e {\n\t\tconsole.error(err);\n\t\t\n\t\t// Status code of the response - 0 if there was a network error or aborted signal\n\t\tif (err.status !== 0) {\n\t\t\t// Open the message body in Slack's Block Kit Builder to show where any errors are.\n\t\t\tawait err.openInBlockKitBuilder();\n\t\t}\n\t});\n```\n\n### Function-Based Approach\n\n\u003e **Note:** Both the \"Class-Based\" and \"Function-Based\" approaches are functionally equivalent. In the \"Function-Based\" approach, functions serve as convenient wrappers around the class constructors. They accept the same arguments as the constructors and simply create instances of the respective classes using the provided arguments.\n\n```js\nimport { createSlackMessage } from '@shgysk8zer0/slack/message.js';\nimport { createSlackHeaderBlock } from '@shgysk8zer0/slack/block/header.js';\nimport { createSlackPlainTextElement } from '@shgysk8zer0/slack/element/plain-text.js';\nimport { createSlackMarkdownElement } from '@shgysk8zer0/slack/element/markdown.js';\nimport { createSlackImageBlock } from '@shgysk8zer0/slack/block/image.js';\nimport { createSlackDividerBlock } from '@shgysk8zer0/slack/block/divider.js';\nimport { createSlackButtonElement } from '@shgysk8zer0/slack/element/button.js';\nimport { createSlackSectionBlock } from '@shgysk8zer0/slack/block/section.js';\n\ncreateSlackMessage(undefined,\n\tcreateSlackHeaderBlock(createSlackPlainTextElement('New Message on from Slack Bot')),\n\tcreateSlackDividerBlock(),\n\tcreateSlackImageBlock('https://example.com/img.png', {\n\t\ttitle: createSlackPlainTextElement('Here is some image'),\n\t\talt: 'Missing Image',\n\t}),\n\tcreateSlackSectionBlock(\n\t\tcreateSlackMarkdownElement('This is some example \u003cmarkdown | https://en.wikipedia.org/wiki/Markdown\u003e'),\n\t\t{\n\t\t\taccessory: createSlackButtonElement('Open link!', {\n\t\t\t\tstyle: 'primary',\n\t\t\t\turl: 'https://example.com',\n\t\t\t}),\n\t\t\tfields: [\n\t\t\t\tcreateSlackPlainTextElement('Click Something!'),\n\t\t\t\tcreateSlackMarkdownElement('*Email:* \u003cmailto:user@example.com | user@example.com\u003e'),\n\t\t\t\tcreateSlackMarkdownElement('*phone:* \u003ctel:+1-555-555-5555 | 555-555-5555\u003e'),\n\t\t\t]\n\t\t},\n\t),\n).send({ signal: AbortSignal.timeout(5000) }).then(\n\t() =\u003e console.log('Message sent'),\n\tasync err =\u003e {\n\t\tconsole.error(err);\n\n\t\tif (err.status !== 0) {\n\t\t\tawait err.openInBlockKitBuilder();\n\t\t}\n\t}\n);\n```\n\n## To-Do (Work in Progress)\n\nThis package is a work in progress, and there are some areas that are still under development. Here's what's on the to-do list:\n\n- [ ] Complete missing Block and Element types: Some Slack Blocks and Elements are not yet implemented in this package. We'll be adding support for additional types in future updates.\n- [ ] Implement missing properties: While the core functionality is in place, there may be some properties on existing classes that are not yet fully implemented. We'll be working on adding support for these properties in upcoming releases.\n- [ ] Additional documentation: While we provide documentation for the classes and methods introduced in this package, we'll also be adding `@see` links in comments to the relevant Slack API documentation on `api.slack.com` for reference.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshgysk8zer0%2Fslack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshgysk8zer0%2Fslack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshgysk8zer0%2Fslack/lists"}