JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 165
  • Score
    100M100P100Q80662F
  • License MIT

Type-safe slack client for TypeScript.

Package Exports

  • typed-slack

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typed-slack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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

  • Incoming Webhook
  • Web API
  • RTM API
  • Events API
  • 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: '😄',
  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)