ms-teams-wrapper
v1.0.2
Published
A node library to send messages to Microsoft Teams webhooks.
Downloads
22
Maintainers
Readme
Microsoft Teams Webhook Wrapper
A node library to send formatted messages and cards to webhook connectors on Microsoft Teams channels.
Install
Use yarn
$ yarn add ms-teams-wrapper
Use npm
$ npm install ms-teams-wrapper
Usage
A simple example to execute a message to your connector.
import { Webhook, SimpleTextCard } from "ms-teams-wrapper";
const url = "https://[account-name].webhook.office.com";
const data = new SimpleTextCard("Hello World!");
const webhook = new Webhook(url, data);
const response = await webhook.sendMessage();
Another way to send messages is to pass a plain object. This needs to be in the correct format to successfully send the message.
const data = {
text: "Test notification"
};
const webhook = new Webhook(url, data);
const response = await webhook.sendMessage();
The connector url can be found by following this guide: https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=javascript#create-incoming-webhooks-1
Demo
Demo files can be found here: https://github.com/adamriaz/ms-teams-wrapper/tree/main/demo
Development
- Clode the repository
- Use yarn
npm i -g yarn
yarn
to install dependenciesyarn test
to testyarn build
to build to the /dist folder
Testing
Tests files are written using Jest (Typescript)
Tests files location: /tests/**/*.test.ts
Use yarn test
or yarn test:watch