Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

typed-slack

starhoshi859MIT0.1.4TypeScript support: included

Type-safe slack client for TypeScript.

tsd, DefinitelyTyped, slack, typescript

readme

typed-slack npm version Build Status Codacy Badge License: MIT

Typed-slack is a type-safe slack client for TypeScript.

slackapi/node-slack-sdk is great slack client. However, it does not contain d.ts files. Typed-slack has type definitions, so you can handle slack-api easily and type-safely.

Code completion is enabled when using VSCode.

vscode\.gif \(898×298\)

TODO

  • <input checked="" disabled="" type="checkbox"> Incoming Webhook
  • <input disabled="" type="checkbox"> Web API
  • <input disabled="" type="checkbox"> RTM API
  • <input disabled="" type="checkbox"> Events API
  • <input disabled="" type="checkbox"> Interactive Messages

Install

npm install typed-slack

Usage

Webhook

import * as Slack from 'typed-slack'

let slack = new Slack.IncomingWebhook('https://hooks.slack.com/services/.......')
slack.send({ text: 'text' }).then(e => {
  console.log('success')
}).catch(e => {
  console.error(e)
})

Options

More optional parameters are here#typed-slack.d.ts

const options = <Slack.IncomingWebhookOptions>{
  text: '@star__hoshi Hi!',
  channel: 'debug',
  icon_emoji: ':smile:',
  link_names: 1,
  attachments: [
    {
      color: Slack.Color.Danger,
      fields: [
        {
          title: 'Priority',
          value: 'High',
          short: false
        }
      ],
      image_url: 'http://my-website.com/path/to/image.jpg',
      ts: 123456789
    }
  ]
}
await slack.send(options)