cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gmurnock
Advocate I
Advocate I

Passing variables from PVA in Teams to Power Automate

Do we have the ability to pass variables from a PVA in Teams to "Call and action" Power Automate?  Or is this version in Teams a very basic BOT?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @gmurnock 

 

Here is a quick demo on how to achieve this:

 

First make sure your authentication is set to "Only for Teams"

Jcook_0-1603813221000.png

 

Now inside a Topic, you want to call an action, and create a Flow. In the Flow you want to have an Input for the User Display name

Jcook_1-1603813463930.png

 

Next use a 'Search for users' action, and pass in the User input

Jcook_2-1603813532170.png

 

The outputs of this action are an array which makes it hard to pass back into PVA or any other system. So to get around this, add a 'Get user profile' action and use the first() expression to only take the first 'UserPrincipalName' from the 'Search for users' action

Here is my expression:

first(outputs('Search_for_users_(V2)')?['body/value'])?['UserPrincipalName']

GetUserProfile.png

 

Now we have all the users details, I am passing some info back to PVA to test:

PVA-Outputs.png

 

Save, and go back to the PVA canvas, next add an Action and select the Flow you created.

For the User input, select 'bot.UserDisplayName' this is available to us from the Authentication we set above. 

PVA-ActionFlow.png

 

Next I am adding a Message block, to test out the Flow.

PVA-ShowMessageUserDetails.png

 

Testing the Bot:

Success-Run.png

 


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

7 REPLIES 7
gmurnock
Advocate I
Advocate I

Guess I should elaborate more.  Do we have the ability to access the logged in user, User(), function from 365?  Seems crazy to have a user type in their name and email and other information when I can get it from their AzureActiveDirectory login.  Also asking the user questions in the BOT to just re-ask the same question in power Automate is NOT a very good UX.

Hello @gmurnock 

 

You can use the authentication, to get user details. Which can be passed to power automate, 

than you can use a get user action to get all the details for the user:

https://docs.microsoft.com/en-us/power-virtual-agents/advanced-end-user-authentication


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Hi Jcook, for bots created in PVA Teams app, you get the end user's name and ID directly because the authentication is set to 'Only for Teams' by default:

https://docs.microsoft.com/en-us/power-virtual-agents/advanced-end-user-authentication

 

For email, you could use the ID and call a PAuto flow with Office 365 connector to retrieve it. 

Hi @gmurnock 

 

Here is a quick demo on how to achieve this:

 

First make sure your authentication is set to "Only for Teams"

Jcook_0-1603813221000.png

 

Now inside a Topic, you want to call an action, and create a Flow. In the Flow you want to have an Input for the User Display name

Jcook_1-1603813463930.png

 

Next use a 'Search for users' action, and pass in the User input

Jcook_2-1603813532170.png

 

The outputs of this action are an array which makes it hard to pass back into PVA or any other system. So to get around this, add a 'Get user profile' action and use the first() expression to only take the first 'UserPrincipalName' from the 'Search for users' action

Here is my expression:

first(outputs('Search_for_users_(V2)')?['body/value'])?['UserPrincipalName']

GetUserProfile.png

 

Now we have all the users details, I am passing some info back to PVA to test:

PVA-Outputs.png

 

Save, and go back to the PVA canvas, next add an Action and select the Flow you created.

For the User input, select 'bot.UserDisplayName' this is available to us from the Authentication we set above. 

PVA-ActionFlow.png

 

Next I am adding a Message block, to test out the Flow.

PVA-ShowMessageUserDetails.png

 

Testing the Bot:

Success-Run.png

 


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

Hi @gmurnock 

 

Could you let us know if you issue has been solved?

 

Please try my solution above. Thanks


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





k1ng
Helper I
Helper I

So you mean @Jcook that you can't pass an array back to pva?  "The outputs of this action are an array which makes it hard to pass back into PVA or any other system.

 

I am trying to make a simple search address book from o365 but I wanted to have multiple queries...?  

Hi @k1ng 

That’s a great use case!


You can pass multiple fields to PVA for a multi query in the O365 Users connector. What I was saying is that you cannot pass back a data type of Array. In my solution above I explain the workaround to pass an Array type, by converting the array to a string.


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Center-of-Excellence-Starter-Kit-cropped 768x460.png

The Total Economic Impact™ of Power Virtual Agents

Read this 2021 commissioned study, conducted by Forrester Consulting.

Top Solution Authors
Top Kudoed Authors
Users online (1,222)