Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@slack/webhook

Package Overview
Dependencies
Maintainers
12
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slack/webhook

Official library for using the Slack Platform's Incoming Webhooks

  • 6.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
579K
decreased by-0.79%
Maintainers
12
Weekly downloads
 
Created

What is @slack/webhook?

@slack/webhook is an npm package that allows you to send messages to Slack channels using Incoming Webhooks. It provides a simple interface to post messages, which can include text, attachments, and other rich content, to Slack.

What are @slack/webhook's main functionalities?

Send a simple message

This feature allows you to send a simple text message to a Slack channel using an Incoming Webhook URL.

const { IncomingWebhook } = require('@slack/webhook');
const url = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX';
const webhook = new IncomingWebhook(url);
(async () => {
  await webhook.send('Hello, Slack!');
})();

Send a message with attachments

This feature allows you to send a message with attachments, which can include additional information like titles, links, and colors.

const { IncomingWebhook } = require('@slack/webhook');
const url = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX';
const webhook = new IncomingWebhook(url);
(async () => {
  await webhook.send({
    text: 'New issue reported',
    attachments: [
      {
        title: 'Issue #1234',
        title_link: 'http://example.com/issues/1234',
        text: 'Description of the issue',
        color: '#ff0000'
      }
    ]
  });
})();

Send a message with blocks

This feature allows you to send a message using Slack's Block Kit, which provides a more flexible and rich way to format messages.

const { IncomingWebhook } = require('@slack/webhook');
const url = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX';
const webhook = new IncomingWebhook(url);
(async () => {
  await webhook.send({
    blocks: [
      {
        type: 'section',
        text: {
          type: 'mrkdwn',
          text: 'A message with *blocks*'
        }
      },
      {
        type: 'divider'
      },
      {
        type: 'section',
        text: {
          type: 'mrkdwn',
          text: 'Another block of text'
        }
      }
    ]
  });
})();

Other packages similar to @slack/webhook

Keywords

FAQs

Package last updated on 12 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc