Take time back out of your busy day and learn how to set up automated messages in teams! Why take the time to send messages in #MicrosoftTeams that are so routine you could automate them with #PowerAutomate!
With the help of this video and Pluralsight course, you’ll learn basic and advanced ways to leverage this technique in a DEMO!
Video Summary
Here are the key points from the video:
- Creating a Flow: The demo starts by creating a new flow in Power Automate to send messages in Microsoft Teams, using an instant cloud flow for easy testing.
- Posting Messages: It demonstrates how to post a message in a Teams channel using the Flow bot, including selecting the team and channel and composing a simple message.
- Mentioning Users: The demo shows how to mention a user in a message by getting the mention token and posting it in a chat, ensuring the user is notified.
- Creating Group Chats: It covers creating a group chat with multiple users, adding a title, and sending a message within that chat.
- Practical Applications: The demo highlights practical uses of these techniques, such as sending notifications for overdue book returns, posting news updates, and leveraging these functions in approval workflows.
For more information, read the transcript blog below, or watch the video above!
Video Transcript
Let’s head over to the lab and see how we can send Microsoft Teams messages directly from Microsoft Power Automate. We are now in the lab environment. Let me open up the browser over here and let’s create a brand new flow. The goal will be to see how we can just send Teams messages to users. So, we will just do an instant cloud flow. This makes it a lot easier to test. I’ll call it “Teams Message Flow” and let’s just do a manually triggered flow button. I will click on “Create.”
Now, let’s do a new step. I’ll go here, add a new step, and add an action. Let me just search for Teams here. We will filter on the Teams connector, and as you can see, we have quite a few options from Teams, from adding a member to a team, creating a Teams meeting, creating a chat, creating a team, getting the details from a specific message, getting messages, being able to look through multiple messages, even asking a choice of options as the Flow bot to a user, and many more. But let’s start with a simple one. Let’s simply search for “message” and what we will do is post a message in a chat or a channel.
Now, it will ask me who I want to post as: either the Flow bot, the user under which the connection runs, or Power Virtual Agents, which is in preview at the moment. But since this course is not about Power Virtual Agents, we will not really dive into Power Virtual Agents. There is a course on Pluralsight called “Creating Power Virtual Agent Chatbots for Microsoft Teams” if you want to learn more about Power Virtual Agents. But we’ll really focus on the first two for now. Let me pick the Flow bot here. We will take a look at what the experience looks like in Teams as we run it. Then we can choose where we want to post it: either in a channel, in a chat with the Flow bot, or in a group chat. Let’s go in a channel over here.
It will show me all the different teams that I have access to. Let me take the Book Club over here, and now I need to select the channel, of course. Let me select the “Check-in Checkout” channel. Here, let’s add a simple message: “Hello, don’t forget to check in and check out the books you get from our library.” Let’s actually go and run it just like that so we can see the result. We will do something we haven’t done before. At the top right over here, you see we have a “Test” button. I will click on it. This is super cool for instant flows, especially because you can just manually perform the starting action to trigger it. In this case, it’s just a button, so I can just click on “Continue” here and run the flow. This will still run the flow, but what will happen is that if I go inside my flow, instead of showing “Succeeded,” it differentiates that it’s a test. So, I see here “Test Succeeded,” not only “Flow Succeeded.” This way, when you look at the history, you can see the difference between your tests and your production flows.
Great! Now, if we open up Microsoft Teams here, you see we have a notification in the “Check-in Checkout” channel. You see we have Vlad Katrineska via Power Automate, so it doesn’t show up from me. It shows up from Vlad Katrineska via the Flow bot, which is Power Automate, and I have my message: “Hello, don’t forget to check in and check out the books you get from the library.”
Now, we can also take it to the next level. Let me go back to edit over here. I can add a new step. Let’s say we want to notify somebody that their book return is late. Maybe you save the information to SharePoint, you have a scheduled flow that runs, and if we’re past the due date, you want to tag them in a message. I can do that. Let’s go to Teams here, first of all, select Teams, and then I will search for “mention.” If we want to mention a user, the first thing we need to do is get the @mention token for a user. Let me select that here and get the token for Vanessa Lee at globomantics.org. Here, we’ll see if it asks me to find a user. No, so we will leave it like that. Great!
Now, what I will do is a new step again. Let’s have a chat again. I’ll just go in Teams here, let’s do a chat over here, and we will use the “Post a message in a chat or a channel.” So, let’s go here, select this, post as the Flow bot again, or I can post it as myself as well, but I usually prefer to do it with the Flow bot, especially if this flow will be used by multiple people or it’s an official flow. Maybe the user one makes more sense for more personal flows that only you use. Now, what I will do is post it in a chat with the Flow bot. Let me select it here. Then you gotta wait one or two seconds, and then the options will appear. Depending on what you choose, you will have different options. If I switch to “Channel” here, it will take a few seconds, and then the channel options should appear. It’s really important that you wait a few seconds here. It takes anywhere from one second to five or ten seconds, so you have to be a bit patient.
Okay, let’s go back to the chat with the Flow bot here. We will wait again. Come on, select “Chat with the Flow bot” for me. Let’s wait. We will add the recipient too, like search for Vanessa Lee at globomantics.org. Then I forgot to select the user. Let’s just go here. I always forget to do that sometimes, and the flow fails. You see, we have the username that popped up. I will select it to make sure it sends it to the right person. Now we can add our message. Let’s say here, “Hello,” and I can take the mention token for the user and then I can say, “Your book is late.” Great!
If we want to test it in a channel as well, let me move the “Get mention” above so I can also go in here and add the mention in the channel message as well. I will click on “Save” here. Let’s wait for it to save. Let’s run the test right away, run the flow, and now I will go in as Vanessa so we see what happens. As you can see, a lot of notifications. If we go inside the notification, we see Power Automate mentioned you, and as you can see, it’s an actual mention. So, that user got mentioned directly. In the chat here as well, I have “Hello Vanessa Lee, your book is late.”
You can also do many other things. I’ll go back to my flow here. I can also create a chat, for example. Let’s say one more demo here. Let’s go to Teams here, Microsoft Teams, let’s go to “Chat,” create a chat, and inside, let’s add Vanessa Lee at globomantics.org again. After that, let me just double-check. We have to separate the users by semicolons, so let me also add John Smith in there. There we go. I copy-pasted John Smith’s username in there. Now we can add a title, and we can call it “Book Returns.” Then I can add a message to that chat. Let’s go to Microsoft Teams here again. I will search for “Chat,” and post a message in a chat or channel. Let me select that, post as the user here or the Flow bot. Let’s do the Flow bot. Now, let’s select a group chat over here, and then it will ask me which group chat I want to select. I will enter a custom value, and then I can get the conversation ID from the chat that I just created. I will simply add a “Hello” message over here just to make sure that it works. So, I will click on “Save” and let’s run this test again. I will test it manually, and run the flow, done.
Now, of course, Vanessa will get notified multiple times again, but I also have a brand new chat that got created called “Book Returns.” We can see the members inside are John Smith, Vanessa, and Vlad. It automatically adds the user under which the connection is added in there, so that’s why Vlad is in there. I have the Flow bot that says “Hello.” This is it for this quick demo in which we have seen how we can send messages in Microsoft Teams by using Power Automate. We can mention users, send messages to a team, send messages to a channel in a team, to a private chat, or a group chat. We can also create a group chat if needed. While this was shown in a simple instant flow, you can leverage these techniques in your approval workflows, in your news notifications from your intranet when a new news item is posted, and more. As more people spend time in Teams, leveraging these functionalities will be appreciated by your users. We’re not done with Microsoft Teams features yet. Let’s head back to the slides and learn about adaptive cards in Microsoft Teams.