Microsoft Teams: Monitor Channel


Your use of this download is governed by Stonebranch’s Terms of Use, which are available at


Microsoft Teams is a collaboration app that helps teams stay organized and have conversations. This Universal Extension provides the capability to monitor a Microsoft Teams channel for uploaded files and run job(s) and/or workflows accordingly.

Software Requirements

This integration requires a Universal Agent and a Python runtime to execute the Universal Task.

Requires Python 3.7.0 or higher. Tested with the Universal Agent bundled Python distribution.

Software Requirements for Universal Agent

Both Windows and Linux agents are supported:

  • Universal Agent for Windows x64 Version and later with python options installed.

  • Universal Agent for Linux Version and later with python options installed.

Software Requirements for Universal Controller

Universal Controller Version and later.

This Universal Task requires that Universal Controller property Web Service Default Response Content (uc.web_service.response.content.default) is set to JSON.

Network and Connectivity Requirements

Azure Active Directory Requirements

An application must be registered in the Azure Active Directory. See official instructions on Quickstart: Register an application with the Microsoft identity platform

  1. Use as "Supported account Types" option "Accounts in this organizational directory only".

  2. When registration finishes an Application (client) ID is generated (required as part of Extension Task configuration).

  3. Configure API permissions.

  • Assign the following Microsoft Graph API permissions.

    API / Permissions name





    Read user channel messages



    Sign in and read user profile

  • Grant admin consent.

4. Create a client secret -> Add client secret (client secret is required as part of Extension Task configuration)

Key Features

This Universal Extension provides the following main features:

  • Support authentication to Microsoft Teams with Oauth2 protocol for Grant Type Resource Owner Password Credentials (aka "Password Credentials").

  • For a specific Microsoft Teams Channel, periodically poll all the new messages since the last lookup.

  • For each fetched message having attachments, launch a task in Universal Controller with variables holding the list of attachments' SharePoint URLs, names and a message summary.

  • Support for up to 5 attached files (any additional files are skipped).

  • Ability to resume from the last read message on restart.

  • Different Log levels for the Universal task, with DEBUG level providing more information in case of issues.

  • Universal task instance must be stopped with Force Finish/Cancel command to avoid leaving a running monitor process.

The scope is to support exchange of files on a dedicated Microsoft Teams channel that will act as service channel.

To share a file, a conversation is created with the file being attached. It is not expected that anyone will react or reply to this message.

Known Issues

This extension is subject to the limitations of MS Graph API.

For more technical details, please refer to Microsoft Graph REST API v1.0 chatMessage: delta

  • Actions and replies on the channel conversations are not supported.

  • Only returns channel conversations within the last eight months.

  • Incremental read of new messages is relying on a delta token from the API. Its value, which is opaque, must be kept in a variable to allow for it to resume between runs. See how to configure the task in the example section below.

Import the Universal Template

To use this downloadable Universal Template, you first must perform the following steps:

  1. This Universal Task requires the Resolvable Credentials feature. Check that the Resolvable Credentials Permitted system property has been set to true.
  2. To import the Universal Template into your Controller, follow the instructions here.
  3. When the files have been imported successfully, refresh the Universal Templates list; the Universal Template will appear on the list.

Configure Universal Task

For the new Universal Task type, create a new task, and enter the task-specific details that were created in the Universal Template.

Input Fields

The input fields for this Universal Extension are described below.


Input type

Default value





Monitor Attachments


The action performed upon the task execution

Client Credentials




The credentials for the application registered in the Azure Active Directory.

They are comprised of:

  • Application (client) ID

  • Client secret : The client secret issued to the client during Application registration process

Resource Owner Credentials




The user's credentials for Microsoft 365.

They are comprised of:

  • username

  • password

Channel Identifier


Channel Link


The Type of identifier for the channel.

For example: Channel Link to provide the URL

Channel Link




The URL link of the required channel.

Required if Channel Identifier is "Channel Link".

Interval (seconds)




The Message Polling Interval in seconds.

Universal Controller URL




Universal Controller URL.

For example:

Universal Controller Credentials




The Universal Controller Credentials.

The Credentials must have “Web Service Access” Permissions.

Launch Task




The name of the Task to be launched in the Universal Controller.

The task will always be launched with the Task variable {attachment_urls} which contains the SharePoint URLs list of the attachments in JSON format.

Offset Token



Large Text

Tracker for the last read message from the channel.

It can be set to the previous instance run execution with the output parameter offset_token. By setting it, it allows it to resume from the last read message.

Skip MessagesOptional0IntegerThe number of messages to be skipped at the start of the Universal Task.

Launch Task Variables

The Variables that are passed to the launched task are described below.





Large Text (JSON)

The list of the attachment URLs (as SharePoint URLs), in JSON format.


Text (JSON)

The list of the attachment names (as listed on the message), in JSON format.


Text (JSON)

A summary of the message information in JSON format: modified date, sender, message id.

Example: attachment_urls

  "contentUrls": [ "" ]

Example: attachment_names

  "names": [ "my_file.txt" ]

Example: message_summary

  "lastModifiedDateTime": "2021-09-21T16:09:29.236Z",
  "id": "1632240161921",
  "from": {
    "user": {
      "displayName": "John Doe"

Task Output

Output Fields

The output parameters are set after every message processing. If they are 'preserved on re-run', they prevent a re-run of the task instance from restarting from scratch.

The output fields for this Universal Extension are described below.



Preserved on re-run


Last Modified Date Time



The last modified date time on the last modified message (the maximum value in case of 'Run forever').

Offset Token

Large Text


Tracker for the last read message from the channel.

Outstanding Message



Shows whether there are more messages to be read from the channel.

Launched Task



The sysID (32 char) of the last launched task as returned by UAC REST API.

Message Count



The number of fetched message since the start of the monitoring (task instance).

Task Count



The number of launched tasks since the start of the monitoring (task instance).

Exit Codes

The exit codes for this Universal Extension are described below.

Exit Code

Status Classification Code

Status Classification Description

Status Description



Bad Authentication data

AUTHENTICATION_ERROR: Incorrect username or password.



Insufficient Permissions

AUTHORIZATION_ERROR: The authorization credentials provided for the request are invalid.



Bad request to third party API

FOREIGN_API_REQUEST_ERROR: Bad request to Microsoft API.



Validation error response from third party API

FOREIGN_API_RESPONSE_ERROR: Microsoft API response validation error.



Error while launching a Task in UAC REST API

LAUNCH_TASK_EXEC_ERROR: Error while launching a task.

Task Examples

Follow the steps below to create a Task.

  1. Give the Task a name.

  2. Select an active agent of version or higher for the task to run on.

  3. Select the action.

  4. Set your Client Credentials.

  5. Set your Resource Owner Credentials.

  6. Set your Universal Controller Credentials.

  7. Select the Channel Identifier.

  8. Enter the required Channel Link. An easy way to retrieve this is from the Microsoft Teams UI:

  9. Enter the Launch Task name.

  10. Enter the Universal Controller URL.

  11. Enter the Offset Token from the previous instance execution.

  12. Enter the required Interval in seconds.

Example with the Usage of Offset Token in an Instance Re-run

Create a global variable from inside a Task.

Set the value of the global variable to be set, when the instance finishes, with the value of the task instance variable as below. ('ops_msteams_monitor_offset_token' is the task instance variable name for the tracker for the last read message from the channel.)


2. In the Task, set the global variable value in the Offset Token field.

The offset is kept between the task executions and allow to resume from the last read message on that channel.

Document References

This document references the following documents:




Universal Templates

Creating a Universal Template

User documentation for creating Universal Templates in the Universal Controller user interface.

Universal Tasks

Creating a Universal Task

User documentation for creating Universal Tasks in the Universal Controller user interface.



User Documentation for Credentials Details Field Description.

Launch a Task

Task Web Services

User Documentation for Launching a Task.

Force Finish/Cancel

Manually Running and Controlling Tasks

User Documentation for Cancelling a Task.

Azure Active Directory

Register an application with the Microsoft identity platform.



User Documentation for all Universal Controller properties.