Extend Power Virtual Agent with Azure Cognitive Services
Tags: azure, powervirtualagent, lowcode
Published: 2022-12-03 13:36:02

---
title: Extend Power Virtual Agent with Azure Cognitive Services
published: true
series: 101 - Power Virtual Agents
date: 2022-12-03 13:02:17 UTC
tags: azure, powervirtualagent, lowcode,
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvbz2jkxzzxvuqnp457x.jpg
canonical_url: https://the.cognitiveservices.ninja/extend-power-virtual-agent-with-azure-cognitive-services-eab95018b7f6
---
Photo by <a href="https://unsplash.com/@sebbill?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Sebastian Bill</a> on <a href="https://unsplash.com/photos/FEqy73bRuRQ?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
  
#### a step-by-step Kickstarter to Power Virtual Agent and Azure Cognitive Service for Language

Power Virtual Agent (PVA) is getting better and better from Release to Release, but there are situations where you want to use Azure Services to improve your user’s experience.

Why not combine Azure Cognitive Services for Language with PVA to add missing elements?

> **Imagine** serving your customers and employees immediately in their native language without extra effort and without investing time in translating and maintaining your QnA in other languages.
**Imagine** there is no need for additional resources, but your customers and employees will feel more directly addressed. 
**Imagine** your employees can refocus on delivering value to your customers instead of being a voice interface of a QnA collection.
Microsoft Power Virtual Agents are perfect for automating customer service, and when combined with Azure Cognitive Services, they are almost infinitely extensible.
**How easy is that?**
A simple Power Automate flow helps your Power Virtual Agent serve your customers in over ninety languages.

PVA has a built-in topic that can serve as a hook to the outside world, the “Fallback” system topic.

#### Activate the “Fallback” topic

![Figure 2: Activate the “Fallback” topic](https://cdn-images-1.medium.com/proxy/1*WCfGcNCa13Fr8UjW4XLU-Q.png)
<figcaption>Figure 2: Activate the “Fallback” topic</figcaption>

To activate the “Fallback” system topic, go to Settings within the editing canvas (click on the cog symbol), then System fallback, and then “+Add”.

After activating the topic, you will find it within “topics”.

![Figure 3: activated fallback topic](https://cdn-images-1.medium.com/proxy/1*z2kfXfQmh3Yb5Dt4DPOhUw.png)
<figcaption>Figure 3: activated fallback topic</figcaption>

The “Fallback” topic is ready to connect with the outside world, as everything not recognized by our already in-place topics will end up here as “unrecognized user input”.

#### Extend Power Virtual Agent to a multilingual QnA Resolver

> If you have no PVA bot handy, try my [“Power Virtual Agent in a Day”](https://the.cognitiveservices.ninja/build-your-first-voice-bot-with-microsoft-power-virtual-agent-3e71f8531c3a) Example as a starter.

This example will integrate a FAQ Database on “growing chilies”. Data from a random web page, “Greenhouse Garden Shop — [Growing Chillies FAQ](https://www.greenhousesensation.co.uk/growing-chillies-faq/) will be used.

> I´m not related to this shop but let´s respect their knowledge of growing chilies and use their questions and answers here!!  
> Following my slogan:

> “Sriracha on everything!”

> Chilies are the main ingredient of [Sriracha](https://en.wikipedia.org/wiki/Sriracha). :)

#### Custom question answering

We created a new project on Azure language [Language Studio — Microsoft Azure](https://language.cognitive.azure.com/home)) and chose “Custom Question Answering”.

![Figure 4: Create a new Custom Question Answering Project](https://cdn-images-1.medium.com/proxy/1*38bD6R7edS-VuKsI2Y-GSw.jpeg)
<figcaption>Figure 4: Create a new Custom Question Answering Project</figcaption>

- Choose the option “I want to set the language for all projects created in this resource” > select English > Select Next.
- Enter a project name, “PVAinaDay-CQA”, a description, and leave the default answer with a setting of “No answer found”.
- Review your choices and select Create project
- From the Manage sources page, select Add source > URLs. Select Add URL, enter the following values, and then select Add all:

URL Name: URL Growing Chillies [https://www.greenhousesensation.co.uk/growing-chillies-faq/](https://www.greenhousesensation.co.uk/growing-chillies-faq/)

![Figure 5: Add URL of FAQs](https://cdn-images-1.medium.com/proxy/1*fKilXwRDE5DlIILehZ1ljw.jpeg)
<figcaption>Figure 5: Add URL of FAQs</figcaption>

Language Studio will now import your FAQs into the project and gives you single and multiturn Question and Answer pairs.

![Figure 6: Question and Answer pairs in Knowledge Base](https://cdn-images-1.medium.com/proxy/1*iCCAB5dY5XBSpSZqOQG-WA.jpeg)
<figcaption>Figure 6: Question and Answer pairs in Knowledge Base</figcaption>

To use the imported content, we need to clean up the answers and make them usable for a bot. We must remove pictures and links if our bot is a voice bot.

![Figure 7: Add alternate phrases](https://cdn-images-1.medium.com/proxy/1*Lh9ltt_UpeKDe3gWXRropg.jpeg)
<figcaption>Figure 7: Add alternate phrases</figcaption>

To make the Answering more fluent, we will add variations to each question.

And deploy the knowledge base.

![Figure 8: Select “Deploy” on the left side and press “deploy” on top to deploy](https://cdn-images-1.medium.com/proxy/1*ePvlV4teSuXQlksVc8UnFw.jpeg)
<figcaption>Figure 8: Select “Deploy” on the left side and press “deploy” on top to deploy</figcaption>

After deploying the knowledge base, we press “Get prediction URL”, and we note down the Site URL(Red) and the Account Key (Yellow); we will use both later in Power Automate.

![Figure 9: Retrieve the Site URL and Account Key](https://cdn-images-1.medium.com/proxy/1*ozhxxwfM0RB06N-UO5aU_Q.jpeg)
<figcaption>Figure 9: Retrieve the Site URL and Account Key</figcaption>

#### Integrate Custom Question Answering and Microsoft Translator into Power Virtual Agent via Power Automate

We jump back into your newly created “Fallback” Topic and remove the “Escalate” and the “Message” node.

After deleting the nodes, we create a new “Call an action” node.

![Figure 10: Create a new Call an action node](https://cdn-images-1.medium.com/proxy/1*krU0VjfXOrqHMQ4ZCeHmkg.png)
<figcaption>Figure 10: Create a new Call for an action node</figcaption>

Power Automate will open, and we can create a new flow.

First, we rename the flow and define the input.

![Figure 11: Define Input](https://cdn-images-1.medium.com/proxy/1*jcq1SUxvdNacNG1e1IcysA.png)
<figcaption>Figure 11: Define Input</figcaption>

To determine the language of the question, we will initialize a new variable, “QuestionLanguage”. We will use it to store the language code.

![Figure 12: Initialize variable](https://cdn-images-1.medium.com/proxy/1*UeF_TY8a7LVF61D1qddsoA.png)
<figcaption>Figure 12: Initialize variable</figcaption>

Create a new node by searching “Microsoft Translator V2” and selecting “Detect language”, and set Text to the content of the variable “UnrecognisedUserInput”.

![Figure 13: Create Detect Language Node](https://cdn-images-1.medium.com/proxy/1*p2sJ3P4GcaIBTF93J1p0kw.png)
<figcaption>Figure 13: Create Detect Language Node</figcaption>

We use a set Variable Node to store the output of “detect language” into the “QuestionLanguage” Variable

![Figure 14: Initialize Variable QuestionLanguage](https://cdn-images-1.medium.com/proxy/1*BPZRTXYNsSj3jSNjFi8eEQ.png)
<figcaption>Figure 14: Initialize Variable QuestionLanguage</figcaption>

with a translate text node (Microsoft Translator V2), we translate the content of “UnrecognizedUserInput” to English.

![Figure 15: Translate to English](https://cdn-images-1.medium.com/proxy/1*t9FG_Me0QwnfrzbTIC8fqA.png)
<figcaption>Figure 15: Translate to English</figcaption>

Create a new node by searching “Language — Question Answering” and selecting “Generate answer from Project”.

![Figure 16: Create Node](https://cdn-images-1.medium.com/proxy/1*_-0YC4vriJi6gre_PN_X8A.png)
<figcaption>Figure 16: Create Node</figcaption>

We noted the account Key and Site URL earlier in this guide; we use the values now.

Set “Question” to the output of the translation node.

![Figure 17: Generate Answers from Project](https://cdn-images-1.medium.com/proxy/1*STJVTL8bTGQJsFeEtfzMxQ.png)
<figcaption>Figure 17: Generate Answers from Project</figcaption>

Next, Initialize a new variable with a name, e.g., “CQA\_Answer”

![Figure 18: Initialize Variable CQA_Answer](https://cdn-images-1.medium.com/proxy/1*5IB1iwtTlI0mPuXS_lf3lQ.png)
<figcaption>Figure 18: Initialize Variable CQA_Answer</figcaption>

A “Apply to each” node with a “Translation” and a “set Variable” action will translate back to the language the question was asked in.

![Figure 19: Apply to each Node with two actions](https://cdn-images-1.medium.com/proxy/1*DU6BUoDi49W8VlzxZnHp9Q.png)
<figcaption>Figure 19: Apply to each Node with two actions</figcaption>

Finally, we adjust the Return Value to the content of the “CQA\_Answer” Variable.

![Figure 20: Return Value with Content of CQA_Answer Variable](https://cdn-images-1.medium.com/proxy/1*SCnPRBHvtqnFKv-lTaD9vQ.png)
<figcaption>Figure 20: Return Value with Content of CQA_Answer Variable</figcaption>

After saving the flow, we can select the flow in the action node, adjust the input, and create a message node to display the output of the flow.

![Figure 21: Complete Topic with Power Automate Flow](https://cdn-images-1.medium.com/proxy/1*2kDHDS7KDBjp6jDp_hvX1g.png)
<figcaption>Figure 21: Complete Topic with Power Automate Flow</figcaption>

The flow will result in the following:

A question asked to the bot without a topic in PVA will end up in the “Fallback” topic. Custom Question Answering will help with the answer, even to a question not asked in English.

![Figure 22: Result: multilingual QNA](https://cdn-images-1.medium.com/proxy/1*GSp54WGvLYq4WM1C6N0Yaw.png)
<figcaption>Figure 22: Result: multilingual QNA</figcaption>

#### Additional Information

- Custom Question Answering — [documentation](https://learn.microsoft.com/en-us/azure/cognitive-services/language-service/question-answering/language-support) [successor of QnA Maker]
- Conversational Language Understanding — if you would like to make the next step — [documentation](https://learn.microsoft.com/en-us/azure/cognitive-services/language-service/conversational-language-understanding/overview) [successor of LUIS]
- Power Automate Connectors — [documentation](https://learn.microsoft.com/en-us/connectors/connector-reference/connector-reference-powerautomate-connectors)