Reputation: 21
A bot is being developed using AAD authentication, in which we have chosen directline as our channel. Now, we have tried displaying the username of the authenticated person in the place of userid in the below snippet.
<script>
BotChat.App({
directLine: { secret: "***********" },
user: { id: 'userid' },
bot: { id: 'botid' },
resize: 'detect'
}, document.getElementById("bot"));
</script>
Upvotes: 1
Views: 431
Reputation: 27825
we have tried displaying the username of the authenticated person in the place of userid in the below snippet
I assume that you are a .NET developer and you'd like to dynamically pass user identity to BotChat, you can try the following approach:
userid
when you initiate your BotChat. The following code snippet is for your reference.In controller:
public ActionResult Chat()
{
ViewBag.userinfo = User.Identity.GetUserName();
return View();
}
In view:
<script>
$(function () {
var userid = '@(ViewBag.userinfo)';
//alert(userid);
BotChat.App({
directLine: { secret: "{directline_secret}" },
user: { id: userid},
bot: { id: 'fehanbotdg' },
resize: 'detect'
}, document.getElementById("bot"));
})
</script>
Test result:
Upvotes: 1
Reputation: 14619
Change
user: { id: 'userid' },
To
user: { id: yourUserIdFromAad },
You can even add user: { id: yourUserIdFromAad, name: yourUserDisplayName },
Upvotes: 2