botsbotframeworkcortanacortana-skills-kit

Cortana BOT Framework return some auto generated ID


I am working on Cortana channel integration for bot framework application. I have enabled debug information for Cortana.I have logged into Cortana NoteBook with my Microsoft account which was created using Gmail Id. I want to capture my Gmail id in my BOT app, but when i debug the bot i am getting some auto generated ID as shown below.

{
  "botId": "SpeechBot1",
  "botRequest": {
    "type": "message",
    "id": "GYobtdHWUXY",
    "timestamp": "2017-11-08T10:17:06.2836473Z",
    "serviceUrl": "https://CortanaBFChannelWestUS.azurewebsites.net/",
    "channelId": "cortana",
    "from": {
      "id": "D65148253A8E11E86BAEF4C3FB964163E6028E4E9FC6DE221F88CA1A37DD4AF4"
    },
}

Thanks in advance.


Solution

  • In order to receive the user's email address from cortana during bot communication, you'll need to request access to that information from the user. This can be done from the bot dev portal: https://dev.botframework.com/bots/channels?id=YourBotId&channelId=cortana Near the bottom you'll see a section titled "Request user profile data":

    enter image description here

    I requested User.Info.Email and named it UserEmail. Once this is saved, Cortana will ask the user for permission to provide their email address:

    enter image description here

    Once the user consents, the Entity of type "UserInfo" will contain a "UserEmail" property in botRequest:

    {
      "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
        }
      }
    }
    

    This can be accessed in a .net bot using Newtonsoft.json like:

    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"];
            }
        }
    }