Package Exports
- messaging-api-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 (messaging-api-slack) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
messaging-api-slack
Messaging API client for Slack
Installation
npm i --save messaging-api-slackor
yarn add messaging-api-slackUsage
Initialize
Get your webhook url by adding a Incoming Webhooks integreation to your team or setup Incoming Webhooks function to your app.
import { SlackClient } from '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
sendRawBody(body)
client.sendRawBody({ text: 'Hello!' });sendText(text)
client.sendText('Hello!');sendAttachments(attachments)
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)
client.sendAttachment({
fallback: 'some text',
pretext: 'some pretext',
color: 'good',
fields: [
{
title: 'aaa',
value: 'bbb',
short: false,
},
],
});