You are currently viewing How to get Chat bot logged user name in PVA/ Copilot ?
Copilot Studio logged user

How to get Chat bot logged user name in PVA/ Copilot ?

In this blog post, we will learn how to authenticate Power Virtual agent “Microsoft Copilot Studio” and get Chat bot logged user name.

pVA authentication / Copilot

Microsoft Power Virtual agent become now Microsoft Copilot Studio

Microsoft Copilot is Microsoft Power Virtual agent before and it is a Microsoft service that allows you to create chatbots with little to no code.

Microsoft Copilot Stodio “PVA” supports various identity providers for authentication. Includes Azure Active Directory (Azure AD), Microsoft account, and others. You can configure your bot to require users to sign in using one of these identity providers before they can interact with the bot.

Authenticate Copilot Bot

  • Open your Bot, from the left navigation in the Settings select Security
Chat bot logged user
  • Choose Authentication
bot2 | Power Platform Geeks
  • Choose your Authentication type that you want to use inside your Bot
    You will find 3 Authentication type in your Copilot Bot to choose from
boot3 | Power Platform Geeks
  1. No authentication, In some cases, you might connect to a service that doesn’t require authentication. For example, if you’re building a bot that simply responds to FAQs and doesn’t need to access any external services, in this case authentication may not be necessary.
    “No authentication “is the standard configuration for bots that aren’t created from Teams”
  2. Only for Teams and PowerApps, when you select this option all channels except the Teams channel will be disabled.
    Copilot studio “Power Virtual Agents” supports authentication through identity providers such as Azure Active Directory (Azure AD) and Microsoft account. You can configure your bot to require users to sign in using one of these identity providers.
channel | Power Platform Geeks
  1. Manual (for custom website) including Teams, for example if you want to embed your bot in your mobile app or any of the channel and required the user to login. This will open all the channels including Teams.
    • If the service provider is either Azure Active Directory or Microsoft Entra ID, you can turn on Require users to sign in to control who in your organization can chat with the bot using bot sharing.
    • If the service provider is Generic OAuth2, you can turn Require users to sign in on or off. When it’s turned on, a user who signs in can chat with the bot. You can’t control which specific users in your organization may chat with the bot using bot sharing.

Get Chat bot logged user

After you choose your authentication type , you can get the user details inside your bot , for example you can welcome the logged in user using his/ her name.

In the insert variable “{X}” select System search for User and you will find some new properties for users that you can use inside your bot such as User Id , First Name , last name , DisplayName, Email,… and so on.

bot3 | Power Platform Geeks
bot4 | Power Platform Geeks

Include the system variable that you want your bot welcome the user with and also you can use to bas these variable to external sources to retrieve data based on the logged in user.

So this is how to get the chat bot logged user in Copilot Studio, enable authentication and get the user system variable to your bots.

See Also
Join us
Need Help
  • Have a related question? Please ask it at Community.

Heba Kamal

Microsoft MVP, MCT, Technical Speaker, Blogger, and Microsoft 365 and Power Platform Consultant.