Microsoft Teams is the tool today for interaction with co-workers, but it can be overwhelming when the channels are popular, and people are active. So automating some tasks is essential to save you precious time. That’s where the “When a new channel message is added” trigger comes into play.

Let’s check how to use it.

Where to find it?

To find it, you can search for the “When a new channel message is added” trigger.

Otherwise, you can to the “Standard” tab and select “Microsoft Teams”.

Pick the “When a new channel message is added.”

Here’s what it looks like.

Pro Tip:
Power Automate tends to save the most common triggers in the main screen, so check there before going trough the full hierarchy. Also you can use the search to quickly find it.

Usage

There’s not much to configure on the “When a new channel message is added” trigger. You only need to point it to the Team and Channel, and it will start listening to

Outputs

The trigger returns a lot of information in a JSON format, although the conversion from JSON is done automatically for you. Here’s an example:

{
    "headers": {
        <redacted>
    },
    "body": {
        "@odata.type": "#microsoft.graph.chatMessage",
        "etag": "1633358608128",
        "messageType": "message",
        "createdDateTime": "2021-10-04T14:43:28.128Z",
        "lastModifiedDateTime": "2021-10-04T14:43:28.128Z",
        "importance": "normal",
        "locale": "en-us",
        "webUrl": "<redacted>",
        "id": "16",
        "from": {
            "user": {
                "id": "a10c6616-fe65-4f4d-acd6-9af1a991b9c4",
                "displayName": "Manuel Gomes",
                "userIdentityType": "aadUser"
            }
        },
        "body": {
            "contentType": "text",
            "content": "test message"
        },
        "channelIdentity": {
            "teamId": "10566946-2522-11ec-9621-0242ac130002",
            "channelId": "19:5c8@thread.skype"
        },
        "attachments": [],
        "mentions": [],
        "reactions": []
    }
}

The “When a new channel message is added” trigger will return quite some information. We’ll ignore the headers since it’s information that we don’t need, but the “body” produces a lot of helpful information like:

  1. The message was posted.
  2. The channel’s ID
  3. Attachments
  4. Mentions
  5. Reactions

It’s a lot and, depending on what you want to do, they can be more or less helpful.

I have a real case of this trigger into action on my “Add Attachments to Microsoft Planner from Teams” article.

I want for you to understand that:

  1. The trigger contains the added attachments when posted.
  2. The reactions field will only contain the reactions since the message was posted until the trigger fires. After that, it’s not of time, so you can consider the value empty most of the time.
  3. The attachments field will contain the URL to the attachment and not the contents.

Limitations

The trigger will only fire for messages, not replies. For example, if you do this:

Recommendations

Here are some things to keep in mind.

Don’t use it for “busy” channels.

Although Power Automate can cope with millions of triggers, your subscription won’t. So you’ll run through your quota quite fast, and that’s a problem. Also, if the channel is super busy with many messages, the Flow will trigger a lot so keep this in mind when using this trigger.

Keep it short

Since Teams can have a lot of messages, it’s good to keep the Flow as lean as possible. If the Flow runs frequently and takes a long time, you’ll have:

  1. A long list of running Flows
  2. If they update the same data source, you’ll have conflicts because you can’t guarantee who will edit it first.
  3. If you’re updating your systems, they will be under heavy load since Flow will trigger frequently.

Think constantly about what your Flow is doing and if the actions and systems you have can cope with frequent calls to avoid downtime in critical systems.

Never generate the Team or Channel ID.

You should never generate IDs manually. There isn’t even a good reason to do it since it’s a trigger, and there’s no logic that you can “calculate” before.

Tools change, and IDs change with them. So you should never have even to know what’s the ID of a Team or Channel.

Finally, having the IDs will make debugging harder because you don’t have the description of the Team to guide you. If you see “Sales” is a lot nicer than “9a9bcb24-f32c-4fe9-839c-9d709c10b4fe”.

Name it correctly

The name is super important in this case since we can get the trigger from anywhere and with anything. Always build the word so that other people can understand what you are using without opening the action and checking the details.

Always add a comment.

Adding a comment will also help to avoid mistakes. Indicate what you’re expecting, why the Flow should be triggered, and the data used. It’s essential to enable faster debugging when something goes wrong.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Trigger Reference.

Photo by Jason Leung on Unsplash

Manuel Gomes

I'm a Project Manager with experience in large projects and companies. I've worked in the past for companies like Bayer, Sybase (now SAP) and I'm currently working for Pestana Hotel Group.

View all posts by Manuel Gomes →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: