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.
I’m Tomasz Poszytek, Microsoft Business Applications MVP. From more than 8 years now I’m being involved in projects, which aim is production of various applications using SharePoint as a platform. My adventure started absolutely without a purpose, when in the beginning of 2000 I was given FrontPage installation disc and started experimenting with this WYSWIG tool.
Currently I’m focusing on self development in “cloud” area, where I’m trying to get acquainted with Office 365 features and applications. I’m professionally and personally very much interested in automation of processes, digital transformation, digital workplaces and all tools that helps employees in that area.
From more than a year I’m working with the platform for processes automation – Nintex. I’m also the Nintex Certified Partner and Nintex Virtual Technical Evangelist (Nintex vTE).
Poszytek, T. (2020). PVA Series – User Context in Power Virtual Agent. Available at: https://poszytek.eu/en/microsoft-en/office-365-en/pva-en/pva-series-user-context-in-power-virtual-agent/ [Accessed: 10th April 2020].
Find more great Power Platform content here.