A Winston transport hook to log messages to a Microsoft Teams Webhook connector.
$ npm install msteams-winston
- Winston
- A previously configured MS Teams Webhook is required Incoming Connector. You will need this Webhook URI to configure the msteams-winston logger.
const { createLogger } = require('winston');
const msTeamsWinston = require("msteams-winston");
const hookUri = 'https://outlook.office.com/webhook/............../...........'
const msTeamsWinstonOptions = {
"webhook": hookUri,
"name": "Testing Microsoft Teams Winston",
"summary": "Test Logger"
};
const logger = createLogger({
transports: [
new (msTeamsWinston) (msTeamsWinstonOptions)
]
});
// This log will be sent to the MS Teams channel configured with the Webhook
logger.info('MSTeams renders markdown in messages. `Log a block of code` or some *italic text* \n > add a quote block');
Exhaustive Options:
const msTeamsWinstonOptions = {
"webhook": hookUri,
"name": "Testing Microsoft Teams Winston",
"summary": "Test Logger",
"themeColor": "cf0808",
"sections": [{
"activityTitle": "You can add different sections within your card",
"activitySubtitle": "Section Subtitle",
"markdown": true
}],
"potentialAction": [{
"@type": "ActionCard",
"name": "Click Here To Comment",
"inputs": [{
"@type": "TextInput",
"id": "comment",
"isMultiline": false,
"title": "You can set action buttons, like this one that allows you to comment!"
}],
"actions": [{
"@type": "HttpPOST",
"name": "Add comment",
"target": "http://...URI TO POST INPUT TO"
}]
}, {
"@type": "ActionCard",
"name": "Click Here To Input a Date",
"inputs": [{
"@type": "DateInput",
"id": "dueDate",
"title": "This action allows you to select a date, customize the add a action with a target to post the input"
}],
"actions": [{
"@type": "HttpPOST",
"name": "Save",
"target": "http://...URI TO POST INPUT TO"
}]
}]
};
Give a ⭐️ star if this project helped you!
Copyright © 2023 Haeven Dickerson.
This project is MIT licensed.