Skip to content

SendToTeamsWebHook (Microsoft Teams)

ts
function SendToTeamsWebHook(
  webhookURL: string,  // required
  message:    string   // required
): boolean;

NOTE

This function is available as of Syncplify Server! v7.1.1. If you are running an older version, upgrade to v7.1.1 or later to use it.

Posts a plain-text notification to a Microsoft Teams channel using an Incoming Webhook connector. Returns true if the message was delivered successfully, false otherwise.

The message payload uses the simple {"text": "..."} format, which renders as a basic card in the Teams channel. For richer cards (Adaptive Cards, etc.), consider posting directly via HttpCli.

ParameterTypeRequirementExplanation
webhookURLstringrequiredThe full incoming webhook URL obtained from the Teams channel connector settings
messagestringrequiredPlain-text message body
Return valueExplanation
trueTeams accepted the message (HTTP 200 returned)
falseThe HTTP request failed or Teams returned an error

Example

ts
SendToTeamsWebHook(
  GetSecret('teams-webhook-ops'),
  'Nightly transfer completed: 1 247 files processed.'
);

Sending notifications to multiple channels

ts
function notifyAll(msg) {
  var ok = true;
  if (!SendToSlackWebHook(GetSecret('slack-ops'), msg, 'TransferBot', ':robot_face:')) {
    ok = false;
  }
  if (!SendToTeamsWebHook(GetSecret('teams-webhook-ops'), msg)) {
    ok = false;
  }
  if (!NotifyViaTelegramBot(msg)) {
    ok = false;
  }
  return ok;
}

notifyAll('Nightly export complete: ' + fileCount + ' files.');

TIP

Store the webhook URL in the Secret store with GetSecret rather than hardcoding it in your script. This keeps credentials out of the source code and allows rotating the URL without editing scripts.