wework
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

WeWork Incoming Webhooks

Installation

$ npm install wework

Usage


Initialize the webhook

The package exports a IncomingWebhook class. You'll need to initialize it with the URL you received from WeWork group, see the webhooks docs.

import { IncomingWebhook } from 'wework';
 
// Read a url from the environment variables
const url = process.env.WEWORK_WEBHOOK_URL;
 
// Initialize
const webhook = new IncomingWebhook(url);

Send a Message

Something interesting just happened in your app, so its time to send the message! Just call the .sendText(message) method on the webhook. The message parameter is an string.

import { IncomingWebhook } from 'wework';
const url = process.env.WEWORK_WEBHOOK_URL;
 
const webhook = new IncomingWebhook(url);
 
// Send the message
(async () => {
  // send text message
  await webhook.sendText('Some text message');
  // send markdown message
  await webhook.sendMarkdown(`Some markdown message`)
  // send news articles
  await webhook.sendNews([
    {
      title: 'The title',
      description: 'The description',
      url: 'The link',
      picurl: 'The image url'
    }
  ])
})();

Package Sidebar

Install

npm i wework

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

10.8 kB

Total Files

11

Last publish

Collaborators

  • kuqoi