1.0.0 • Published 7 months ago

tstdel-notify-msteam-callback v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago
                                  #tstdel-notify_msteam_callback
  • Item 1 Project Title: tstdel-notify-msteam-callback

  • 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-callback

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.
  • callback
    type:callback description: make a call to callback function notifyMessage for the final result.

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.
  • callback
    type:callback description: make a call to callback function notifyMessage for the final result.

Function#3: 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.
  • callback
    type:callback description: make a call to callback function notifyMessage for the final result.

Function#4: 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 .
  • callback
    type:callback description: execute call back function and return the final result.

Sample code:
const tstdelNotifyMSTeamCallback = require('./tstdel_notify_msteam_callback');
function sendmsgteam(message, callback) {
  try {
    const props = {
      "type": "MessageCard",
      "themecolor": "theme color of message",
      "summary": "Description Message",
      "pretext": "MESSAGE SHOWN IN HEADER",
      "webhook": "https://actinc.webhook.office.com/webhookb2/9a4c9b49-d3ee-40be-b073-b0aa8ea07057@65cb0346-9d88-41d9-8ca6-f72047670d0f/IncomingWebhook/225a21849fbb4776a1015d9e53ee9e25/4a8e84dd-07b4-4e85-9815-d00bee0f2296"
    };

    const notifyMSTeam = new tstdelNofifyMSTeamAsync(props);
    notifyMSTeam.notify(message, (err, notifyMSTeamresponse) => {
      if (err) {
        return callback(err);
      } else {
        return callback(null, notifyMSTeamresponse);
      }
    });
  } catch (error) {
    callback(error);
  }
}

// Usage example
sendmsgteam('test message', (err, response) => {
  if (err) {
    console.error('Notification failed:', err.message);
  } else {
    console.log('Notification success:', response.status);
  }
});