Create Teams Chat Autoreply with Power Automate

Create Teams Chat Autoreply with Power Automate

Create Teams Chat Autoreply

Here is a great example of why you would want to Create Teams Chat Autoreply with PowerAutomate. Your organization has an email address that forwards to several people. If you work in any form of a support group, this is common. The only thing is that it renders MS Teams on that account useless. You need Teams though because you are probably using the phone functionality on that account.

Nobody logins directly into the forwarded account so if anyone sends a chat message withing the organization you will only hear about it later in an email. By that time the person is probably wondering why they haven’t received support yet. If you use Power Automate (Microsoft Flow) it is more secure.

Why You Can’t set an Out of Office Message

It is an account that is not directly accessed so why not just send an out of office reply to incoming message. It works for Teams, right. Well, the problem here is that Outlook and Teams go hand in hand. With an OOO set up whatever goes to Outlook will also go to Teams and vice versa.

It would be hilarious if your support email sent out a reply that this this channel is not monitored! Here’s how you set up an autoreply in MS Teams.


Steps To Use Power Automate (Microsoft Flow) to Create Teams Chat Autoreply

  1. Go to https://make.powerautomate.com/ and sign in as the email account that is forwarded to your group if you are not already.
  2. On the left-hand side click “+Create”
  3. Choose Automated Cloud flow.
  4. Give your flow a name and search and choose the trigger “When a new chat message is added”.
  5. Click Create.
  6. You will be presented with a screen like this:
Create Teams Chat Autoreply

From Here you will add a step at a time by clicking on New Step. I will explain the flow in the next screenshots.

How the Flow Works

Power Automate can take almost anything you can do manually in M365 and automates it. A good example is when you Create Teams Chat Autoreply. The problem is that there is so much information you can automate is it hard to find documentation. Essentially the Output of a flow is an input to the next flow.

If the output from a flow has several values (like a search), it applies a “apply to each” step and will perform an iteration for you. My example only has one value. Creating the initial is ok, if you must go back and edit it, the “apply to each” becomes nested and it is a real pain. The flow I created is short, so I just recreate it every time in need to edit it. There is a way to remedy this but can show you in a future blog post.

Remember Each Output of one step is the input of the next.

Parse The Users Email Address (ObjectID)

The step in the screenshot below takes its input from the initial step of the flow (When a chat message is added). There are several possible items (Dynamic Content) you can pick from the message. The item you need to pick for this step is “Message Link”.

Create Teams Chat Autoreply

The next screenshots show how to parse the ObjectID’s from the Message Link Dynamic Content:

Create Teams Chat Autoreply

first(split(outputs(‘GetMessageLink’),’@unq’))

Create Teams Chat Autoreply

first(split(outputs(‘Parse2′),’_’))

Create Teams Chat Autoreply

last(split(outputs(‘Parse3′),’19:’))

Now we have the 2 possible Object ID’s to parse out of the message link content:

Here is an example of data is trying to get at:

Create Teams Chat Autoreply

It is grabbing the info between “19:” and “_”. That is the ObjectID you will need in the following steps.

The thing is depending on how teams register the chat in the message link it will either be what you parsed or not. The good news is the chat is only between two users (The MS Teams account set up as and autoreply through flow and the user). So, you will have to set up a condition but first we need to determine what the account set up for autoreply’s Object ID is….

Getting Object ID to Create Teams Chat Autoreply Account

This can be easily accomplished by going to admin.microsoft.com and search for the user you want to use for the autoreply and then export the information to a CSV file:

Using Condition in Teams Chat Autoreply Account

Create Teams Chat Autoreply

Then look at the ObjectID field. You need to use that in your condition:

Create Teams Chat Autoreply

If the ObjectID you parsed is the Autoreply account ID you will need to go back a reparse to get the other ID:

Create Teams Chat Autoreply

last(split(outputs(‘Parse2′),’_’))

Then you can get the user profile. “Get User Profile” takes it input from the results of all the Parse4.

Create Teams Chat Autoreply

Now that you have this information, you can send an email to the user who tried to chat the Autoreply’s Teams Account. It grabs all the information based on the lookup from the Object ID and all you must do is select the Mail field dynamic content from the lookup, add your subject and autoreply message you would like to send. You can use the WYSIWYG editor or if you know HTML code you can add the message formatted that way.

Create Teams Chat Autoreply

If the Object ID does not match what you parsed from GetFirstID, then you have the correct Object ID and the flow will follow the “No” branch of the condition:

Create Teams Chat Autoreply

last(split(outputs(‘Parse3′),’19:’))

Create Teams Chat Autoreply

Now that you have this information, you can send an email to the user who tried to chat the Autoreply’s Teams Account. It grabs all the information based on the lookup from the Object ID and all you must do is select the Mail field dynamic content from the lookup, add your subject and autoreply message you would like to send. You can use the WYSIWYG editor or if you know HTML code you can add the message formatted that way.

Create Teams Chat Autoreply

Test The Flow

Once the flow is created, save it. Then, use the flow checker to make sure there are no errors:

Create Teams Chat Autoreply

Lastly you can test it by clicking the test button. You have the choice to manually test or automatic. The flow is triggered by a chat event in production so just choose  “manual” and it will then sit and wait for an event that you will send immediately!

Use another Teams account to send a chat to the account where you set up the flow and the test account will get an email with the subject and the message you specified in the previous steps.

Result of Create Team’s chat autoreply.

  1. You have an email address that is not directly accessed but sent to several other email addresses.
  2. MS Teams chat is not monitored but needed for another reason (phone functionality).
  3. You can’t set an OOO on the outlook account because it defeats the purpose of having the email address in the first place!
  4. Someone sends a chat to this account.
  5. Using Power Automate, a flow has been set up that replies to the message in an email that the account is not in use and probably suggests other ways to get in contact with the group.

Easy peesie, right? With a little help from Power Automate you can Create Teams Chat Autoreply!

Quick IT TIps!

Don’t miss these tips!

We don’t spam! Read our privacy policy for more info.

Avatar photo

I am an IT professional with over twenty years experience in the field. I have supported thousands of users over the years. The organizations I have worked for range in size from one person to hundreds of people. I have performed support from Help Desk, Network / Cloud Administration, Network Support, Application Support, Implementation and Security.

Pin It on Pinterest