A node library to send formatted messages and cards to webhook connectors on Microsoft Teams channels.
Use yarn
$ yarn add ms-teams-wrapperUse npm
$ npm install ms-teams-wrapperA 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 files can be found here: https://github.com/adamriaz/ms-teams-wrapper/tree/main/demo
The docs and references: https://adamriaz.github.io/ms-teams-wrapper/
- Clode the repository
- Use yarn
npm i -g yarn yarnto install dependenciesyarn testto testyarn buildto build to the /dist folder
Tests files are written using Jest (Typescript)
Tests files location: /tests/**/*.test.ts
Use yarn test or yarn test:watch