【发布时间】:2018-01-18 17:36:29
【问题描述】:
我正在使用Microsoft Bot Framework 和directLine 频道。我的机器人是公司客户门户的一部分,我从中获取一些用户信息并使用stateClient 将其存储在BotState 中,如下所示
public ActionResult Index()
{
var userId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
GetTokenViaBootStrap().Wait();
var botCred = new MicrosoftAppCredentials(
ConfigurationManager.AppSettings["MicrosoftAppId"],
ConfigurationManager.AppSettings["MicrosoftAppPassword"]);
var stateClient = new StateClient(botCred);
BotState botState = new BotState(stateClient);
BotData botData = new BotData(eTag: "*");
botData.SetProperty<string>("UserName", result.UserInfo.GivenName + " " + result.UserInfo.FamilyName);
botData.SetProperty<string>("Email", result.UserInfo.DisplayableId);
botData.SetProperty<string>("GraphAccessToken", UserAccessToken);
botData.SetProperty<string>("TokenExpiryTime", result.ExpiresOn.ToString());
stateClient.BotState.SetUserDataAsync("directline", userId, botData).Wait();
var UserData = new UserInformationModel
{
UserId = userId,
UserName = result.UserInfo.GivenName + " " + result.UserInfo.FamilyName
};
return View(UserData);
}
作为directLine 频道,我正在使用javascript 中的秘密连接我的机器人,如下所示:
BotChat.App({
bot: { id: 'my_bot_id', name: 'my_bot_id' },
resize: 'detect',
sendTyping: true, // defaults to false. set to true to send 'typing' activities to bot (and other users) when user is typing
user: { id: UserData.UserId},
directLine: {
secret: "my_bot_secret"
}
}, document.getElementById('my_bot_id'));
我正在访问MVC站点中捕获的Node js Bot中的用户信息数据,如下所示:
function sessionUserCapture(session) {
switch (session.message.address.channelId) {
case 'skypeforbusiness':
// some code
break;
case 'directline':
userName= session.userData.UserName;
userEmail= session.userData.Email;
//some code
break;
case 'slack':
// some code
}
}
我参考了微软的Save state data from Manage state data 获取上述代码,然后我使用session 中的userData 在我的Node.JS Bot 中访问这些数据。
由于 StateClient 已弃用,我建议 this 将 stateclient 替换为 Azure Table storage。但是,我无法理解如何将上述数据存储在Table Storage 中。
谁能推荐任何我可以参考的文章来解决这个问题?
我的机器人在 NodeJs 中,而我在 C# MVC application 中使用 directLine 频道。
【问题讨论】:
-
请澄清这是否正确:您有一个内置在 node.js 中的机器人,它将状态存储在 azure 表存储中。您想从 mvc 站点中检索此状态。
-
我在客户门户上有我的聊天机器人。我正在从 MVC 站点的登录会话中收集用户的标识信息。我想将此用户信息从 MVC 站点发送到节点 js 中的机器人,以进一步处理它以获得对用户在 directLine 频道上提出的问题的响应。我想在 node js bot 中访问这些信息。
-
@Eric,我已经更新了问题以便更清楚。
标签: c# node.js botframework azure-table-storage direct-line-botframework