How to get userPrincipalName or user email

hello,
I have a workflow, which starts with a chat session. User can ask questions and retrieve answers from MYSQL database. I have to apply row level security because user A must not see info of user B. Forexample;

User A will ask; “how many vocation day do I have?”
And following query will run "SELECT remaining_day FROM user WHERE user = {{userA}}

When I start a chat, all information that I can see is;

[{
“sessionId”: “d569931a71b24892b0dd0bd6b2672db4”,
“action”: “sendMessage”,
“chatInput”: “how many vocation day do I have?”
} ]

I need to get userPrincipalName or email. How can I do this?

  • n8n version: 1.72.1
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker - Self hosted AI kit
  • Operating system: Windows

Hey @persefer , I would imagine you have to ask the user to provide his/her email address if that data is not available to you when the user starts using your application. Ideally, however, assuming the user has to log in to your app first, you already should have his email address handy. This topic is outside of n8n realm though.

You can detect if the email address is present in the string with the n8n method extractEmail(), for example.