Enable your Bot Framework Skills to support multi-tenant Power Virtual Agents
Tags: powerplatform, azure, botframework, bots
Published: 2020-08-07 00:13:43

Ever since Power Virtual Agents (PVA) have gone GA in December 2020, we've seen <a href="https://docs.microsoft.com/en-us/power-platform-release-plan/2019wave2/power-virtual-agents/planned-features">significant updates</a> to this total <strong>No-Code </strong>visual authoring canvas. As an avid Conversational AI enthusiast, I have been following and implementing all of these updates either in my solutions or the demos at work. Out of several other improvement areas, <a href="https://microsoft.github.io/botframework-solutions/overview/skills/">Bot Framework Skills</a> have been phenomenal both from the Framework perspective and also from the PVA support endpoint.

<!--more-->

Few month back, I <a href="https://www.arafattehsin.com/empower-your-existing-power-virtual-agents-with-bot-framework-skills-%F0%9F%A4%96/">wrote</a> about the extensibility of Power Virtual with Bot Framework Skills and how can you improve your customer experience without switching to any other conversational apps/channels. After observing the interests of people on forums, meetups and other platforms about this topic, I conducted a <a href="http://aka.ms/arafatskillswebinar">Skills Webinar</a> this month with my dear friend, <a href="https://twitter.com/chass">Mr. Charles Sterling</a> from the Power Platform team.
<blockquote>In this post, it's assumed that you are already aware of the basics of Bot Framework Skills i.e. publishing process on Azure and calling them from Power Virtual Agents. If you think you do not know about this then you may read <a href="https://www.arafattehsin.com/empower-your-existing-power-virtual-agents-with-bot-framework-skills-%F0%9F%A4%96/">this</a> for the reference.</blockquote>
The tenant I used for Webinar's demo was about to get expired and in that tenant, I opted for a lot of services which include Dynamics 365, AI Builder, Power Virtual Agents, Power Automate, Office 365 (for email!) and <strong>Azure ⚡. </strong>I knew at the end of the month (or two), I had to bid farewell to this but the thoughts of setting up the skills (esp. <em>the Azure trial</em>) in the new environment were scaring me. Why? Because, to add a skill to PVA, the user signed into PVA can only add a skill that is deployed on her/his tenant.

So! I sat back. Thought of something and then decided to do <em><strong>simple</strong></em> stuff. Nothing complex at all.

All my work (except for the test data - which I did not want for now) was packaged under solution. Even the PVA, yes! 👍

<img class="aligncenter size-large wp-image-30956" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/AMA-Solution-old-1024x651.jpg" alt="Old Trial Solution" width="1024" height="651" />

&nbsp;

I downloaded the above <strong>solution </strong>(or package) while I was setting up my another trial. What I did not sign up for this time was Azure. Why? Because you get most of the stuff for FREE for a year and it's super cool. But how could I run my Skill from this tenant to the other (new) one? <em><strong>That's the motive of this post!</strong></em>
<blockquote>If you want to work with Azure and you're just stuck because you do not have a credit card or anyway to sign up for FREE then please let me know - we at <a href="https://bit.ly/azuresydneyug">Azure Sydney User Group</a> can help you with some free credit vouchers. All you have to do is just to tell me <strong>why do you need it for! </strong></blockquote>
After setting up my new trial, I did opt for all other services again such as Dynamics 365, AI Builder, Power Virtual Agents and the Office 365 (this time it's more important!). Then I delightfully decided to import my solution into it and it did not fail but... it did not bring my Bot's assets. 🤦‍♂️

<img class="aligncenter size-large wp-image-30957" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/AMA-Solution-halfbaked-1024x387.jpg" alt="AMA Solution half-baked" width="1024" height="387" />Then I figured out you must have Power Virtual Agents solutions installed.

<img class="aligncenter wp-image-30958 size-full" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/AMA-PVA-NotPresent.gif" alt="Power Virtual Agents solutions not installed" width="1916" height="968" />

To achieve this in an easy way, just create a sample bot, for e.g. an <strong>AMA Demo Bot</strong> and then you will notice similar to the below image. You can then re-import your solution and you'll have everything listed successfully!

<img class="aligncenter size-full wp-image-30959" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/AMA-Solutions-PVA.jpg" alt="AMA-Solutions-PVA" width="606" height="374" />

&nbsp;
<h3>Coming to the point.. 🎯</h3>
Then I went to my PVA Portal and I could see that it brought everything successfully. I just had to re-connect my other Flows as they were not triggered (I do not know the reason why as it needs some more investigation).
<blockquote>Great work by the Product Team for this seamless import / export process. You can always follow this <a href="https://powervirtualagents.microsoft.com/en-us/blog/export-and-import-of-power-virtual-agents-bots-using-solutions/">blog post</a> for better understanding of import / export process!</blockquote>
The imported skill was pointing to my Azure tenant (which I secured for old trial) but as I sent a request to that, I got an error which was expected because Skill <strong>does not </strong>know my current PVA. One more thing to note is that this import process does not bring the <strong>Skill</strong> (as in <em>Bot Framework Skill that's hosted on Azure</em>) itself, rather it brings the Skills configuration which you see under the Skills section / topic's actions. Do give post-import docs a read <a href="https://docs.microsoft.com/en-us/power-virtual-agents/authoring-export-import-bots">here</a>.
<h4><strong>How will Skill know my current PVA? </strong></h4>
For that, you need to go to Skills sections, select <strong>Provide ID for Allow List </strong>and then add the same ID to your AllowedCaller's list in your Skill's <strong>appsettings.json </strong>file.

<img class="aligncenter size-full wp-image-30961" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/Get-ProviderID-PVA.png" alt="Get Provider ID" width="1012" height="616" />

&nbsp;

<img class="aligncenter size-full wp-image-30964" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/appsettings.json-1.png" alt="appsettings.json" width="575" height="232" />

Once you're done with this. Then you go to your active Azure portal (in my case, it was the one with my previous trial), add the new tenant's user in your Azure AD.

<img class="aligncenter size-large wp-image-30966" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/Azure-AD-1024x193.png" alt="Azure-AD" width="1024" height="193" />

Then go to your Subscriptions -&gt; Access Control and add this user as <strong>Owner</strong> and in Active Directory as <strong>Group Administrator.</strong>

<img class="aligncenter size-full wp-image-30965" src="https://www.arafattehsin.com/wp-content/uploads/2020/07/IAM.png" alt="Access Control" width="810" height="525" />

That's all what I did! Now if you try to call your skill from the PVA, you should get the expected response similar to mine.

<img class="aligncenter wp-image-30973 size-full" src="https://www.arafattehsin.com/wp-content/uploads/2020/08/AMABank-SkillShow.gif" alt="" width="1890" height="808" />

Until next time.