Skip to main content

Notifications

Building Copilot Studio Chatbots in Microsoft T...
Answered

Passing variables from PVA in Teams to Power Automate

Posted on by 54

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?

  • Jcook Profile Picture
    Jcook 7,765 on at
    Re: Passing variables from PVA in Teams to Power Automate

    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.

  • k1ng Profile Picture
    k1ng 50 on at
    Re: Passing variables from PVA in Teams to Power Automate

    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...?  

  • Jcook Profile Picture
    Jcook 7,765 on at
    Re: Passing variables from PVA in Teams to Power Automate

    Hi @gmurnock 

     

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

     

    Please try my solution above. Thanks

  • Verified answer
    Jcook Profile Picture
    Jcook 7,765 on at
    Re: Passing variables from PVA in Teams to Power Automate

    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

     

  • micchow Profile Picture
    micchow on at
    Re: Passing variables from PVA in Teams to Power Automate

    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. 

  • Jcook Profile Picture
    Jcook 7,765 on at
    Re: Passing variables from PVA in Teams to Power Automate

    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

  • gmurnock Profile Picture
    gmurnock 54 on at
    Re: Passing variables from PVA in Teams to Power Automate

    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.

Helpful resources

Quick Links

Welcome to the Power Platform…

We are thrilled to unveil the newly-launched Power Platform Communities!…

Getting Started…

Welcome to the Power Platform Community! We appreciate your visit…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 138,006

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,059

Leaderboard

Featured topics