PVA Series – user context in Power Virtual Agent
Table of contents:
In my previous post you were able to learn how to authenticate user in Power Virtual Agent. This post is about getting and using context of the authenticated user.
Authentication in PVA
Authentication in PVA is quite simple. It is built out of the below steps basically.
- User enters communication with the Bot
- Bot display button to log in
- User provides credentials
- After is logged in, authentication provider (AAD in this case) returns validation code
- Validation code, once provided back in a chat window, generates and stores bearer token in the AuthToken variable.
Using the user’s context
To use now context of the user in your Power Automate, you have to use obtained bearer token as the authorization method.
Important! Power Automate flows having actions with a defined connection, authorized for different user, will not be executed using the context of the user from bot conversation.
To use context of a user you have to choose actions, that will authenticate on-the-go, for example HTTP (Premium). Then provide the token as the parameter in “Action” calling Power Automate:
And finally use the passed token from PVA as the “Raw” authentication method:
In result you will be able (in this example) to call Graph API using context of a user who is authenticated in the conversation with a bot.
And that’s it. I hope this will help you benefit from calling action with user context and therefore personalize user experience in your Power Virtual Agents conversations. If you have any questions post them in comments below!