botframeworkazure-language-understandingcortanacortana-skills-kit

My Cortana skill shows InternalServerError after updating my code on Azure


I wrote a simple cortana skill using bot framework and LUIS, deployed it, and everything worked fine.

Earlier I updated the code and uploaded to Azure, then I got this InternalServerError when Cortana tried to launch the skill. Then I switched back to the previous code but still got the same error.

However the Chat window of the Bot Framework portal works fine with both versions. The emulator works fine as well.

Can anyone help? Thanks in advance.

Here's the detailed error message.

{
  "error": {
    "botId": "dumbot_carina",
    "botRequest": {
      "type": "message",
      "id": "Dxu2FN06OUb",
      "timestamp": "2017-08-24T10:11:57.8258747Z",
      "serviceUrl": "https://CortanaBFChannelWestUS.azurewebsites.net/",
      "channelId": "cortana",
      "from": {
        "id": "9057CB40B3D426035920CA7B7E2995332082556FE830F719B877D774D2790155"
      },
      "conversation": {
        "id": "46191e3e-57b6-48b2-b804-164d6afc3840"
      },
      "recipient": {
        "id": "dumbot_carina"
      },
      "locale": "en-US",
      "entities": [
        {
          "type": "Intent",
          "name": "Microsoft.Launch"
        },
        {
          "type": "DeviceInfo",
          "supportsDisplay": "true"
        }
      ],
      "channelData": {
        "skillId": "abec8214-0a15-4e47-aa7a-37db6faf2cd3",
        "skillProductId": "3c2f525c-1917-4f5f-8275-6173a37bb1ee",
        "isDebug": true
      }
    },
    "error": "Bot service failed with status code: InternalServerError"
  },
  "traceId": "0f0bb690-ee99-4c92-bf2e-067ff41dfa32"
}

Solution

  • I've found the problem, its because my app cannot handle empty messages, so when I say "ask dumbot something" it will work, but only "ask dumbot" will fail. But because the emulator and the chat window won't allow empty messages so they're fine.

    It's one of the known issues for Bot Framework Skills.

    LuisDialog fails on skill Launch

    When a skill is launched without an utterance (i.e. "Open ", "Ask "), the activity.Text value is null. When this is passed into the LuisDialog, it throws an error. To address this you can override the MessageRecieved method and add a null check as shown below.

    /// <summary>
    /// Need to override the LuisDialog.MessageReceived method so that we can detect when the user invokes the skill without
    /// specifying a phrase, for example: "Open Hotel Finder", or "Ask Hotel Finder". In these cases, the message received will be an empty string
    /// </summary>
    /// <param name="context"></param>
    /// <param name="item"></param>
    /// <returns></returns>
    protected override async Task MessageReceived(IDialogContext context, IAwaitable<IMessageActivity> item)
    {
        // Check for empty query
        var message = await item;
        if (string.isNullOrEmpty(message.Text))
        {
            // Return the Help/Welcome
            await Help(context, null);
        }
        else
        {
            await base.MessageReceived(context, item);
        }
    }