tstdel-notify-msteam-async

1.0.0 • Public • Published
                                  #tstdel-notify_msteam_async
  • Item 1 Project Title: tstdel-notify-msteam-async

  • Item 2 Project Owner: Test Delivery Team

  • Item 3 Description: This node package contains functions that are used for sending msteam notification. This package is in the - act-npm repository

How to install:

npm --registry=https://maven.corporate.act.org/repository/npm-group install --save tstdel-notify-msteam-async

How to use:

  • Constructor:

  • parameters:

    • properties
    • type: Object
    • description : properties to connect to msteam and message defaults attributes
    • attributes:
    • messagetype:
      • type: string
      • description: The "type" field must be "MessageCard".
    • themeColor:
      • type: string
      • description: set the message theme color e.g "0072C6".
    • summary:
      • type: string
      • description: Description of message
    • pretext:
      • type: string
      • description: header of incoming message in MSteam.
    • webhook:
      • type: string
      • description: incoming web hook URL where team channel message deliver. You can generate it by logging to ms team in connector section.

Function#1: notify Description: - This function publishes the message to the msteam.

  • parameters:
  • message
    type: string description: message to publish.

Function#2: notifyCustomizedMessage Description: - This function publishes the customized message to the msteam.

  • parameters:
  • message
    type: string description: message to publish
  • messageProperties
    type: array description: Contained the customized message to send the msteam channel.

Function#2: notifyAlternateMsteamDestination Description: - This function publishes the message to the different channel of msteam

  • parameters:
  • message
    type: string description: message to publish
  • msTeamProperties
    type: array description: contain the different ms team channel (setting)information used to override default settings picked frokm config file.

Function#2: notifyMessage Description: - This is th main method communicate with ms team channel using the webhook for transmission of message.

  • parameters:

  • message
    type: string description: message to publish

  • messageProperties

  • summary: type: string description: Description of message

  • pretext: type: string description: header of incoming message in MSteam

  • msTeamProperties

  • messagetype: type: string description: The "type" field must be "MessageCard".

  • themeColor: type: string description: set the message theme color e.g "0072C6".

  • webhook: type: string description: incoming web hook URL where team channel message deliver. You can generate it by logging to ms team in connector section .

Sample code:
const tstdelNofifyMSTeamAsync = require('./tstdel_notify_msteam_async');
async function sendmsgteam(message) {
  try {
    const props = {
      "type": "MessageCard",
      "themecolor": "theme color of message",
      "summary": "Description Message",
      "pretext": "MESSAGE SHOWN IN HEADER",
      "webhook": "WEBHOOK_URL"
    };
    const notifyMSTeam = new tstdelNofifyMSTeamAsync(props);
        const notifyMSTeamresponse = await notifyMSTeam.notify(message);
        if(notifyMSTeamresponse!= undefined && notifyMSTeamresponse.statusText =='OK' && notifyMSTeamresponse.status == 200 ) {
          console.log(`Message has been successfully sent to MsTeam: ${notifyMSTeamresponse.status} - ${notifyMSTeamresponse.statusText}`);
        } else {
          console.error(`Technical error while sending message to Ms Team`);  
        }    
  } catch (error) {
    console.error('Error sending message to MSTeam:', error);
    throw error;  // Re-throw the error to handle it at a higher level if needed.
  }
}
sendmsgteam('test message');

Readme

Keywords

none

Package Sidebar

Install

npm i tstdel-notify-msteam-async

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

6.56 kB

Total Files

3

Last publish

Collaborators

  • mahajann