Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the user name in from in new version #1321

Closed
rosskyl opened this issue Nov 7, 2018 · 7 comments · Fixed by #1682
Closed

Set the user name in from in new version #1321

rosskyl opened this issue Nov 7, 2018 · 7 comments · Fixed by #1682

Comments

@rosskyl
Copy link
Contributor

rosskyl commented Nov 7, 2018

I was able to set the user ID in the new version of web chat, but I can't figure out how to set the user's name. I've got some logic that relies on the user's name in a bot and need to set this before migrating to webchat v4. Is there a way to set this?

@compulim
Copy link
Contributor

compulim commented Nov 8, 2018

We obsoleted the user name in the UI and prefer using avatar initials.

Do you think a customizable timestamp will work for you?

@rosskyl
Copy link
Contributor Author

rosskyl commented Nov 8, 2018

Currently I set the user name to the logged in user's Azure AD username to pass this to the bot to use it in some searches. Basically I need a way to do that in the new version. I don't need it displayed just passed to the bot. I could pass it in the back channel but would prefer not to because that would require saving it.

Thinking about it a bit more I could probably use the user ID instead. Is there a reason not set that to a username such as "user@contoso.com"?

@compulim
Copy link
Contributor

compulim commented Nov 8, 2018

You mean why we don't set user ID to user@contoso.com?

This blog post explain about "tamper-proof user IDs", https://blog.botframework.com/2018/09/01/using-webchat-with-azure-bot-services-authentication/. The main idea is an unguessable and unforgeable user ID. Sorry it's so hidden in our docs.

@rosskyl
Copy link
Contributor Author

rosskyl commented Nov 9, 2018

So it seems the best way to get the user's email would be through the back channel then? And then in the bot save this and access the saved value when needed.

@compulim
Copy link
Contributor

compulim commented Nov 9, 2018

Your approach would work, using a database to associate Direct Line user ID and email.

When I code bot, I try to make them as stateless as possible (for cost cautious and latency). So I am throwing another approach so you can weigh between them.

The another approach, I am outlining in this sample is using Redux middleware to inject email in the activity sent from Web Chat. This is very similar to HTTP cookies and vulnerable to forgery. Be sure to protect it using signature.

Since this approach is similar to HTTP cookies, it will lower your server load with slightly bigger traffic.

I just baked this sample and it is still in PR.

This sample requires a little change in our existing code. So expect it to drop publicly in 4.2 (mid-December). You can always use our development build (after PR merged) if you need it quick, probably within a few days.

@corinagum
Copy link
Contributor

Closing due to inactivity

@compulim
Copy link
Contributor

compulim commented Feb 5, 2019

@rosskyl we fixed it in 4.2.1-master.0b60abf in #1682.

If you pass, username as a props to Web Chat, we will pass it to the bot as activity.from.name. We won't use this username to generate user initials, because of I18N reasons.

Hope this will help you in your project. :)

@compulim compulim closed this as completed Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants