You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

messaging-api-slack

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messaging-api-slack

Messaging API client for Slack

0.2.5-1
Source
npm
Version published
Weekly downloads
2.3K
-24.78%
Maintainers
1
Weekly downloads
 
Created
Source

messaging-api-slack

Messaging API client for Slack

Slack

Table of Contents

  • Installation
  • Usage
  • API Reference

Installation

npm i --save messaging-api-slack

or

yarn add messaging-api-slack

Usage

Initialize

Get your webhook url by adding a Incoming Webhooks integreation to your team or setup Incoming Webhooks function to your app.

const { SlackClient } = require('messaging-api-slack');

// get webhook URL by adding a Incoming Webhook integration to your team.
// https://my.slack.com/services/new/incoming-webhook/
const client = SlackClient.connect(
  'https://hooks.slack.com/services/XXXXXXXX/YYYYYYYY/zzzzzZZZZZ'
);

API Reference

All methods return a Promise.

Send API - Official docs

sendRawBody(body)

body

Type: Object

client.sendRawBody({ text: 'Hello!' });

sendText(text)

text

Type: String

client.sendText('Hello!');

sendAttachments(attachments) - Official docs

attachments

Type: Array<Object>

client.sendAttachments([
  {
    fallback: 'some text',
    pretext: 'some pretext',
    color: 'good',
    fields: [
      {
        title: 'aaa',
        value: 'bbb',
        short: false,
      },
    ],
  },
  {
    fallback: 'some other text',
    pretext: 'some pther pretext',
    color: '#FF0000',
    fields: [
      {
        title: 'ccc',
        value: 'ddd',
        short: false,
      },
    ],
  },
]);

sendAttachment(attachment) - Official docs

attachment

Type: Object

client.sendAttachment({
  fallback: 'some text',
  pretext: 'some pretext',
  color: 'good',
  fields: [
    {
      title: 'aaa',
      value: 'bbb',
      short: false,
    },
  ],
});

Keywords

bot

FAQs

Package last updated on 04 Aug 2017

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