Home

Awesome

<!-- omit in toc -->

goteamsnotify

A package to send messages to a Microsoft Teams channel.

Latest release Go Reference License go.mod Go version Lint and Build Project Analysis

<!-- omit in toc -->

Table of contents

Project home

See our GitHub repo for the latest code, to file an issue or submit improvements for review and potential inclusion into the project.

Overview

The goteamsnotify package (aka, go-teams-notify) allows sending messages to a Microsoft Teams channel. These messages can be composed of 🚫 deprecated legacy MessageCard or Adaptive Card card formats.

Simple messages can be created by specifying only a title and a text body. More complex messages may be composed of multiple sections (🚫 deprecated MessageCard) or containers (Adaptive Card), key/value pairs (aka, Facts) and externally hosted images. See the Features list for more information.

NOTE: Adaptive Card support is currently limited. The goal is to expand this support in future releases to include additional features supported by Microsoft Teams.

Features

Project Status

In short:

For more details, see the Releases section or our Changelog.

Supported Releases

SeriesExampleStatus
v1.x.xv1.3.1Not Supported (EOL)
v2.x.xv2.6.0Supported (until approximately 2026-01)
v3.x.xv3.0.0-alpha.1Planning (target 2026-01)
v4.x.xv4.0.0-alpha.1TBD

Plans: v2

TaskStart Date / VersionStatus
support the v2 branch with bugfixes and minor changes2020-03-29 (v2.0.0)Ongoing
add support & documentation for Power Automate workflow URLsv2.11.0-alpha.1Complete

Plans: v3

Early January 2026:

[!NOTE]

While the plan for the upcoming v3 series includes dropping support for the 🚫 deprecated MessageCard format and O365 connectors, the focus would not be on refactoring the overall code structure; many of the rough edges currently present in the API would remain in the v3 series and await a more focused cleanup effort made in preparation for a future v4 series.

Changelog

See the CHANGELOG.md file for the changes associated with each release of this application. Changes that have been merged to master, but not yet an official release may also be noted in the file under the Unreleased section. A helpful link to the Git commit history since the last official release is also provided for further review.

Usage

Add this project as a dependency

See the Examples section for more details.

Setup a connection to Microsoft Teams

Overview

[!WARNING]

Microsoft announced July 3rd, 2024 that Office 365 (O365) connectors within Microsoft Teams would be retired in 3 months and replaced by Power Automate workflows (or just "Workflows" for short).

Quoting from the microsoft365dev blog:

We will gradually roll out this change in waves:

Microsoft later changed some of the details regarding the retirement timeline of O365 connectors:

Update 07/23/2024: We understand and appreciate the feedback that customers have shared with us regarding the timeline provided for the migration from Office 365 connectors. We have extended the retirement timeline through December 2025 to provide ample time to migrate to another solution such as Power Automate, an app within Microsoft Teams, or Microsoft Graph. Please see below for more information about the extension:

Since O365 connectors will likely persist in many environments until the very end of the deprecation period this project will continue to support them until then alongside Power Automate workflows.

Workflow connectors

Workflow webhook URL format

Valid Power Automate Workflow URLs used to submit messages to Microsoft Teams use this format:

Example URL from the LinkedIn Bring Microsoft Teams incoming webhook security to the next level with Azure Logic App article:

How to create a Workflow connector webhook URL

[!TIP]

Use a dedicated "service" account not tied to a specific team member to help ensure that the Workflow connector is long lived.

The initial O365 retirement blog post provides a list of templates which guide you through the process of creating a Power Automate Workflow webhook URL.

Using Teams client Workflows context option
  1. Navigate to a channel or chat
  2. Select the ellipsis on the channel or chat
  3. Select Workflows
  4. Type when a webhook request
  5. Select the appropriate template
    • Post to a channel when a webhook request is received
    • Post to a chat when a webhook request is received
  6. Verify that Microsoft Teams is successfully enabled
  7. Select Next
  8. Select an appropriate value from the Microsoft Teams Team drop-down list.
  9. Select an appropriate Microsoft Teams Channel drop-down list.
  10. Select Create flow
  11. Copy the new workflow URL
  12. Select Done
Using Teams client app
  1. Open Workflows application in teams
  2. Select Create across the top of the UI
  3. Choose Notifications at the left
  4. Select Post to a channel when a webhook request is received
  5. Verify that Microsoft Teams is successfully enabled
  6. Select Next
  7. Select an appropriate value from the Microsoft Teams Team drop-down list.
  8. Select an appropriate Microsoft Teams Channel drop-down list.
  9. Select Create flow
  10. Copy the new workflow URL
  11. Select Done
Using Power Automate web UI

This template walks you through the steps of creating a new Workflow using the https://make.powerautomate.com/ web UI:

  1. Select or create a new connection (e.g., user@example.com) to Microsoft Teams
  2. Select Create
  3. Select an appropriate value from the Microsoft Teams Team drop-down list.
  4. Select an appropriate Microsoft Teams Channel drop-down list.
  5. Select Create
  6. If prompted, read the info message (e.g., "Your flow is ready to go") and dismiss it.
  7. Select Edit from the menu across the top
    • alternatively, select My flows from the side menu, then select Edit from the "More commands" ellipsis
  8. Select When a Teams webhook request is received (e.g., left click)
  9. Copy the HTTP POST URL value
    • this is your private custom Workflow connector URL
    • by default anyone can POST a request to this Workflow connector URL
      • while this access setting can be changed it will prevent this library from being used to submit webhook requests

O365 connectors

O365 webhook URL format

[!WARNING]

O365 connector webhook URLs are deprecated and scheduled to be retired on 2024-10-01.

Valid (deprecated) O365 webhook URLs for Microsoft Teams use one of several (confirmed) FQDNs patterns:

Using an O365 webhook URL with any of these FQDN patterns appears to give identical results.

Here are complete, equivalent example webhook URLs from Microsoft's documentation using the FQDNs above:

All of these patterns when provided to this library should pass the default validation applied. See the example further down for the option of disabling webhook URL validation entirely.

How to create an O365 connector webhook URL

[!WARNING]

O365 connector webhook URLs are deprecated and scheduled to be retired on 2024-10-01.

  1. Open Microsoft Teams
  2. Navigate to the channel where you wish to receive incoming messages from this application
  3. Select β‹― next to the channel name and then choose Connectors.
  4. Scroll through the list of Connectors to Incoming Webhook, and choose Add.
  5. Enter a name for the webhook, upload an image to associate with data from the webhook, and choose Create.
  6. Copy the webhook URL to the clipboard and save it. You'll need the webhook URL for sending information to Microsoft Teams.
    • NOTE: While you can create another easily enough, you should treat this webhook URL as sensitive information as anyone with this unique URL is able to send messages (without authentication) into the associated channel.
  7. Choose Done.

Credit: docs.microsoft.com, gist comment from shadabacc3934

Examples

Basic

This is an example of a simple client application which uses this library.

Specify proxy server

This is an example of a simple client application which uses this library to route a generated message through a specified proxy server.

User Mention

These examples illustrates the use of one or more user mentions. This feature is not available in the legacy 🚫 deprecated MessageCard card format.

CodeBlock

This example illustrates the use of a CodeBlock. This feature is not available in the legacy 🚫 deprecated MessageCard card format.

Tables

These examples illustrates the use of a Table. This feature is not available in the legacy 🚫 deprecated MessageCard card format.

Set custom user agent

This example illustrates setting a custom user agent.

Add an Action

This example illustrates adding an OpenUri (🚫 deprecated MessageCard) or OpenUrl Action. When used, this action triggers opening a URL in a separate browser or application.

Toggle visibility

These examples illustrates using ToggleVisibility Actions to control the visibility of various Elements of an Adaptive Card message.

Disable webhook URL prefix validation

This example disables the validation webhook URLs, including the validation of known prefixes so that custom/private webhook URL endpoints can be used (e.g., testing purposes).

Enable custom patterns' validation

This example demonstrates how to enable custom validation patterns for webhook URLs.

Used by

See the Known importers lists below for a dynamically updated list of projects using either this library or the original project.

References

<!-- TODO: Refresh/replace these ref links after 2024-10-01 when O365 connectors are scheduled to be retired. --> <!-- Footnotes here --> <!-- []: PLACEHOLDER "DESCRIPTION_HERE" -->