In this post, I’ll explain one method you can use to get Power Virtual Agent in Microsoft Teams send the same proactive message to everyone with the bot installed.

In a previous post, I’ve demonstrated the proactive messaging with Power Virtual Agents and Power Automate. You can check it out here. Proactive messaging means that your chatbot in Teams can send a message to a user based on a trigger (e.g. a tweet is posted, email received, new blog posted). The message will appear in the Teams chat between the bot and the user. I had an idea to create a chatbot for my colleagues that could send them updates on the latest Dynamics 365 and Power Platform news. It would be based on the flows here. However, rather than posting to the Flow Bot chat, it should post via my chatbot. Here’s an overview of how you can get this to work.

1) Create a Dataverse environment for your Team

If this is the first time you are building an app/chatbot for a particular Team, you will need to at least create a blank app first. Open the Power Apps app in Teams, and select the Team you’d like to create your chatbot in. Create a blank canvas app, name it, then just leave it. Doing this will give you to option to add other things, such as Dataverse tables, chatbots and flows in the Teams environment. So now if you go into the Build tab in the Power Apps Teams app, you have the See all option.

Power Apps in Teams: “See All” option in the Build tab

After clicking See all you will have an option to create a chatbot. This will direct you the Power Virtual Agents app for Teams.

2) Create your Power Virtual Agent chatbot in Teams

Within Teams, create the chatbot you want. Create any topics you want the bot to handle too. My one is simply just a custom greeting explaining how the bot works.

Create any topics you want for your bot in Power Virtual Agents Teams app

You will notice in the image above that the bot tells the user to join a particular Microsoft Team. This is because in order to for the user to be a recipient of the proactive message, we need to get their email address. You will need to be an admin of the Team in order to connect to it and get the user’s details. This will make more sense when we get to the flow coming up soon.

3) Publish your bot

Publish your bot, and select to make the bot available to others.

Publish your bot and make the bot available to others

Click on Availability options and select the Show to my teammates and shared users option. Once published here, the bot will be shown in the app catalog for colleagues to install.

Show the bot to teammates and shared users

4) Create your flow

The flows containing the proactive messages need to be created in the same environment as your chatbot. To do this, open the Power Apps app in Microsoft Teams and navigate to your Team that contains the bot. When you go into the See all area like we did earlier, you will have the option to create a new automated cloud flow.

You can now create your flow, using what ever trigger you like. In this example, I’m using the RSS Feed trigger: When a feed item is published. The flow will notify people when I create a new post on my blog.

Your action after the trigger should be from the Office 365 Groups connector: List group members. For the Group ID, select the Microsoft Team where your bot users would be in. This doesn’t need to be the same Team you created your bot in. However, you will need to be an admin of the Team. You can type 999 in the Top field. This is the max number of users it can look for.

Power Automate flow: Office 365 Groups List group members action

Next is the proactive message. Use the following details for this:

Action: Microsoft Teams- Post message in a chat or channel
Post as: Power Virtual Agents
Post in: Chat with bot
Bot: Select your bot
Recipient: Mail (this is dynamic content from the Office 365 Groups action)
Message: Enter the message you’d like to send

When you set the recipient field, the action will automatically be added in an Apply to Each control.

Power Automate flow: Microsoft Teams Post message in a chat or channel action

5) Test out your flow

You can save and test your flow once you are done.

Note: The flow will appear as a FAIL for every person in the Team (Office 365 Group) who does not have the bot installed. The proactive message will only be sent to those who both are a member of the Team (Office 365 Group) AND have the chatbot added.

Proactive message sent to chatbot

There are likely other methods to get this this work too- let me know if another solution worked for you. It is possible to also do this using Azure Security Groups, but this requires admin permission.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s