PVA Series – add Power Virtual Agent to Teams
Table of contents:
With the fresh release of Power Virtual Agent and its general availability (2nd December 2019) a bunch of new features were added to the tool. One of them is the functionality that allows us to publish the bot and use it in Teams for example. Or Messenger. Or Slack. Or …
Where can PVA be published?
Today there are two kinds of Channels. First has an integration interface allowing to easily set up PVA as a chatbot. Second doesn’t and require a Azure Bot Service as a hosting provider.
If you want to publish your PVA bot to Teams or Messenger – this is fairly easy, just a matter of couple of steps to follow, to make the configuration working.
For other, currently existing channels, so Skype, Cortana, Slack, Telegram, Twilio, Line, Kik, GroupMe, Speech and Email you need to use Azure Bot Service (as described here: https://docs.microsoft.com/en-us/power-virtual-agents/publication-connect-bot-to-azure-bot-service-channels).
How to publish PVA to Teams?
You can go through the documentation obviously ( https://docs.microsoft.com/en-us/power-virtual-agents/publication-add-bot-to-microsoft-teams), however I found it a little confusing. So here’s my guide.
Step no 1 – PVA
Once in Power Virtual Agent tool, navigate to “Publish” (1) and next hit “Publish” button (2). After publishing is done, hit the “Go to channels” (3) hyperlink.
Next click “Microsoft Teams” (1) tile. In the blade click “Add” (2) button and then, once processing is completed and App ID is generated, click “Copy” (3) button.
Step no 2 – Microsoft Teams
If you’re not a Tenant Admin, ensure with them that company policies allows you to sideload apps to Teams. Ask if this setting is set to “Allow all apps”:
If not, convince them to change this setting 😉 Because your bot won’t get to the store, therefore the second option: “Allow specific apps and block others” is not a solution here, as it only allows to select apps present inside the store.
Next thing, check if you have “App Studio” add-in installed in your Teams. It will be needed to generate apps manifest and to add Bot to channels/ chat.
Click the ellipsis icon (1) and check if you see “App Studio” (2) there. If not, click “More apps” (3) link, then type in “App Studio” in search field (4) and finally click the “App Studio” (5) tile and in opened modal window – button “Add”. Finally, open the application.
Then click “Manifest editor” and “Create a new app”.
Now fill in details in the “App details” tab. Be sure to provide information for all required fields. And you can set up branding too.
Important! Unfortunately, branding will not work for Bot created this way. The icon will only be visible in the list view of applications added to Teams. As a bot avatar, however, unfortunately not.
Now navigate to “Bots” (1) settings. There click “Set up” (2). In the modal window click “Existing bot” (3). Then type in the name and App ID (4) copied from the Step 1, generated in the PVA “Channels” configuration. Lastly select Scopes (5) and “Save” (6) configuration.
Now go to “Domains and permissions” (1) section and input token.botframework.com as the “Valid domain” (2). Finally click “Add” (3).
And finally, open “Test and distribute” (1) section to “Install” (2) Bot in your Teams:
And that’s it! Now you can go either to your chat or specific Teams Channel and start conversation with you Power Virtual Agent.
Watch the below video to see a detailed step-by-step guide:
I realized that there is some sort of an issue with re-authentication. So because the Bot is not working in user context, even though when using Teams you are obviously authenticated, Bot has no access to that. Therefore, when you use the “Authentication” functionality in Bot (read more here) you will need to follow the process no matter what.
And that works once you authenticate for the first time. Unfortunately, once your bearer token expires, Bot is not prompting you to log in again. Instead is still using old token, what makes ex. Power Automate to fail, since it gets access denied on calls requiring that token.
There is a list of known limitations in that integration: https://docs.microsoft.com/en-us/power-virtual-agents/publication-add-bot-to-microsoft-teams#known-limitations however that one issues is not there. I hope it gets resolved soon.