Showing results for 
Search instead for 
Did you mean: 

Getting User Details To Use In Power Virtual Agents In Teams




Things to Know

This examples is based on building a Virtual Agent in Microsoft Teams.
We will be using the ‘Only for teams’ Authentication on the bot.




By default PVA in Teams has some valuable variables handy, like ‘bot.UserDisplayName‘. This is awesome, but what if we want more information about the logged in user?

This post will show both scenarios, on using the 'bot.UserDisplayName' variable as well as getting all the user details that are stored in Office365 like:
– Email Address
– First Name
– Last Name
– Job Title
– Etc.

We can also use this in the Greetings Topic to address the user by their first name, rather than their display name. (Keep in mind this might affect performance by a couple seconds)



Bot Setup

Once you have your Bot created, make sure the Authentication is set to ‘Only for teams’. To check click
Manage > Security, Authentication



For this example we will be using the ‘Only for Teams’ option. This will work for ‘Manual’ as well, but will require additional steps to setup a App Registration in Azure.

Select ‘Only for Teams






Customize Greeting Scenario 1 (DisplayName)

After enabling the Authentication, you will now have access to Two variables,

Now lets customize our greeting.

Navigate to ‘Topics’ and select the ‘Greeting’ Topic', this is under ‘System Topics’. Click on the Authoring Canvas button.



Inside the message under the Trigger, you can customize the greeting message to include the variable 'bot.UserDisplayName'



Testing this, the Bot now knows my Display Name. This variable can be used in any topic. Which gives the Bot more of a human type feel.



To get all the user details from Office365, scenario 2 will cover this




Customize Greeting Scenario 2 (Office365)

Navigate to ‘Topics’ and select the ‘Greeting’ Topic', this is under ‘System Topics’. Click on the Authoring Canvas button.

Under the ‘Trigger Phrases’ and select ‘Call an action’. We will now build a new Flow to get the user details we want.



Select Create a flow



You will now be navigated to a new screen where you will build your Flow.
Select the Basic PVA Flow Template




First give the Flow a meaningful name. Mine is:
Power Virtual Agents – Get User Info

Add a Text Input to pass in the Display Name variable



Next add a ‘Search for users‘ action from office365 connector, and pass in the PVA dynamic value from the trigger



Now we have all the user details. The results are returned as an Array. To get around this.
We can add a ‘Get user profile‘ action and pass in the first User Principal Name(UPN)


We have to use the first() expression, so we don’t get put into an Apply to each loop, my expression:




Lastly in the Return values to PVA action, add all the values you want from ‘Get user profile‘ dynamic content



Click Save, and close on top right of the screen. Back at the PVA Canvas screen, add your Flow



Pass in the bot.UserDisplayName variable



Now we can customize our greeting to only address the user by first name



As a test I created a Topic called User Details which showcases all the output values that I passed in to PVA from Power Automate






Getting user details from Office365 opens the door to so many use cases which involves people data.

This can be a great way to give your bot more personality. Do keep in mind that this may affect performance.


Cross Posted from:



Hi @Jcook ,


Thanks for the solution to get user's details!


My use case is the following: when a ticket is created on freshdesk with the urgent status, an adaptive card is sent to a channel in teams.
On this card, I would like to retrieve the name or the email I have in the Office 365 variables as you explained : bot.Lastname, bot.Mail ....

But, I don't see them appear in "dynamic variable"; do you know how to do?  Should I add the step "get user profile" or it's not necessary?


thank you so much




Hi @aurlho 


This blog post is for using Power Virtual Agents trigger. Check out the Power Automate Community for answers on your question. You could also create a post if you cannot find your answer.

PA Community


What should I do if there are several people in the organization with the name Josh Cook?

@GRoman it will return the person chatting with the bot at that moment.

Update : Solved. I removed the 'search for user' step and provided bot.UserId as input directly in 'Get User profile'. It gave me all the similar fields including email.

This is such a great solution but I somehow could not get it to work. Getting this error - 
"The 'inputs.parameters' of workflow operation 'Get_user_profile_(V2)' of type 'OpenApiConnection' is not valid. Error details: The resolved string values for the following parameters are invalid, they may not be null or empty: 'id'


I'd very much appreciate if you could you please help!



Hey @GauravAgarwal11.

thank you!


So you are all good?

It seems like your Search user action is not finding anyone. Glad you found a way around that.

Hi @Jcook,

Thanks a lot for this solution - it helps a lot!


May I also get the information of the office 365 account (for example from



I am trying to add this bot in teams meeting chat, now in meeting there will be mutiple users who can call the bot by just @mention, Is it possible to train our bot so that our bot also reply to that same person by mentioning his/her name in the chat window 

@PowerUser0 - Could you please share how are you adding BOT to teams chat? That is great!



Your guidance on this topic helped me to solve my issue.

Here it is if you are interested!

Solved: Re: Identify a Teams user by chatbot - Power Platform Community (


Many thanks!



exactly what I need but there's an issue with the get data formula for me. 

PVA Returns "There's a problem with Get User Info in Untitled. If the issue persists, check your flow's setup and run history."

So in the flow it's set up exactly the same apart from in the Get User Flow 


It doesn't allow me to convert to a formula like the original post is which i'm guessing why the flow is failing. 


Any help would be appreciated. 🙂 


Hi, @Jcook 

I found now I can't get user details. Does there has any change in Power Virtual Agents?


Please help to confirm. I wish your reply.

Thanks a lot.


How to get the current user from Power Virtual Agent integration in SharePoint?

Hi @Jcook . I set the authentication of my PVA to "only teams" but I am still able to access those variables.

@Simran1607 but where do you host your PVA? On a SharePoint page?

@khhaj there is no need to add any data source to get the user credentials

@Simran1607 I would like to show my PVA webpart on a SharePoint page. Which authentication type do I need to make it work with authenticated users to get the current user.