Bots Cortana机器人框架返回一些自动生成的ID
我正在为bot框架应用程序进行Cortana通道集成。 我已启用Cortana的调试信息。我已使用使用Gmail Id创建的Microsoft帐户登录Cortana笔记本。 我想在我的BOT应用程序中捕获我的Gmail id,但是当我调试BOT时,我会得到一些自动生成的id,如下所示Bots Cortana机器人框架返回一些自动生成的ID,bots,botframework,cortana,cortana-skills-kit,Bots,Botframework,Cortana,Cortana Skills Kit,我正在为bot框架应用程序进行Cortana通道集成。 我已启用Cortana的调试信息。我已使用使用Gmail Id创建的Microsoft帐户登录Cortana笔记本。 我想在我的BOT应用程序中捕获我的Gmail id,但是当我调试BOT时,我会得到一些自动生成的id,如下所示 { "botId": "SpeechBot1", "botRequest": { "type": "message", "id": "GYobtdHWUXY", "timestamp
{
"botId": "SpeechBot1",
"botRequest": {
"type": "message",
"id": "GYobtdHWUXY",
"timestamp": "2017-11-08T10:17:06.2836473Z",
"serviceUrl": "https://CortanaBFChannelWestUS.azurewebsites.net/",
"channelId": "cortana",
"from": {
"id": "D65148253A8E11E86BAEF4C3FB964163E6028E4E9FC6DE221F88CA1A37DD4AF4"
},
}
提前感谢。为了在bot通信期间从cortana接收用户的电子邮件地址,您需要请求用户访问该信息。这可以通过bot-dev门户完成:在底部附近,您将看到一个标题为“请求用户配置文件数据”的部分: 我请求User.Info.Email并将其命名为UserEmail。保存后,Cortana将请求用户允许提供其电子邮件地址: 一旦用户同意,类型为“UserInfo”的实体将在botRequest中包含“UserEmail”属性:
{
"botId": "testcortanabotx2",
"botRequest": {
"type": "message",
"id": "ArL21qrKN1",
"timestamp": "2017-11-09T00:51:36.1278058Z",
"serviceUrl": "https://CortanaBFChannelWestUS.azurewebsites.net/",
"channelId": "cortana",
"from": {
"id": "BBFF225566992B987D49552D3457A129914957CCDD74A95F613C60F0996"
},
"conversation": {
"id": "c9879863a-78ca-4107-de18-9187443681d3"
},
"recipient": {
"id": "testcortanabotx2"
},
"locale": "en-US",
"entities": [
{
"type": "Intent",
"name": "Microsoft.Launch"
},
{
"type": "UserInfo",
"UserEmail": "MyPersonalEmailAddress@gmail.com"
},
{
"type": "DeviceInfo",
"supportsDisplay": "true"
}
],
"channelData": {
"skillId": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
"skillProductId": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
"isDebug": true
}
}
}
可以在.net bot中使用Newtonsoft.json访问此文件,如:
string userEmailAddress = string.Empty;
if (message.ChannelId == ChannelIds.Cortana)
{
if (message.Entities != null && message.Entities.Any())
{
var info = message.Entities.FirstOrDefault(e => e.Type == "UserInfo");
if (info != null)
{
userEmailAddress = (string)info.Properties["UserEmail"];
}
}
}
为了在bot通信期间从cortana接收用户的电子邮件地址,您需要请求用户访问该信息。这可以通过bot-dev门户完成:在底部附近,您将看到一个标题为“请求用户配置文件数据”的部分: 我请求User.Info.Email并将其命名为UserEmail。保存后,Cortana将请求用户允许提供其电子邮件地址: 一旦用户同意,类型为“UserInfo”的实体将在botRequest中包含“UserEmail”属性:
{
"botId": "testcortanabotx2",
"botRequest": {
"type": "message",
"id": "ArL21qrKN1",
"timestamp": "2017-11-09T00:51:36.1278058Z",
"serviceUrl": "https://CortanaBFChannelWestUS.azurewebsites.net/",
"channelId": "cortana",
"from": {
"id": "BBFF225566992B987D49552D3457A129914957CCDD74A95F613C60F0996"
},
"conversation": {
"id": "c9879863a-78ca-4107-de18-9187443681d3"
},
"recipient": {
"id": "testcortanabotx2"
},
"locale": "en-US",
"entities": [
{
"type": "Intent",
"name": "Microsoft.Launch"
},
{
"type": "UserInfo",
"UserEmail": "MyPersonalEmailAddress@gmail.com"
},
{
"type": "DeviceInfo",
"supportsDisplay": "true"
}
],
"channelData": {
"skillId": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
"skillProductId": "xxxxxx-xxxx-xxxx-xxxx-xxxxxx",
"isDebug": true
}
}
}
可以在.net bot中使用Newtonsoft.json访问此文件,如:
string userEmailAddress = string.Empty;
if (message.ChannelId == ChannelIds.Cortana)
{
if (message.Entities != null && message.Entities.Any())
{
var info = message.Entities.FirstOrDefault(e => e.Type == "UserInfo");
if (info != null)
{
userEmailAddress = (string)info.Properties["UserEmail"];
}
}
}
谢谢你,埃里克,给出了这个详细的答案。:-)谢谢你,埃里克,给出了这个详细的答案。:-)