[Question] LUIS Bot not working on Cortana
System Information (Required)
SDK Language: C# SDK Version: Bot Builder have upgraded to 3.8 Development Environment: Localhost
I have a simple Luis Bot and I got the following error when I invoked it without phrase(for example, ask smart) on Cortana, I have already overridden the LuisDialog.MessageReceived to handle without phrase but it seems doesn't work. Does anything else I missing to implement?
Error message
Uh oh, there is a problem with the skill you're selected. Please try again later. Code Example
Debug information from Cortana
{ "error": { "botId": "DebugProduction", "botRequest": { "type": "message", "id": "ELTVSEjfhzM", "timestamp": "2017-06-13T09:18:36.922161Z", "serviceUrl": "https://CortanaBFChannelWestUS.azurewebsites.net/", "channelId": "cortana", "from": { "id": "B2359B8BB8E8F21000551035EF9F9D1ABC1C52241D2C6D38FEF134A84B507721" }, "conversation": { "id": "fbb71176-c46b-42f0-a126-47fb2a616c0b" }, "recipient": { "id": "debugproduction" }, "locale": "en-US", "entities": [ { "type": "Intent", "name": "Microsoft.Launch" }, { "type": "DeviceInfo", "supportsDisplay": "true" } ], "channelData": { "skillId": "fd72d5ff-46be-455c-8b8a-682e3748bad3", "isDebug": true } }, "error": "Bot service failed with status code: InternalServerError" }, "traceId": "fe7f3448-2c1a-46bd-a996-31bdc0d39b9c" }
Here is my code: MessageController.cs
if (activity.Type == ActivityTypes.Message)
{
// Get User login data from bot state
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
BotData botData = await new BotState(activity.GetStateClient()).GetUserDataAsync(activity.ChannelId, activity.From.Id);
var userLoginData = new UserLoginData(botData);
if (activity.Text.ToLower().Contains("logout"))
{
activity.GetStateClient().BotState.DeleteStateForUser(activity.ChannelId, activity.From.Id);
Activity reply = activity.CreateReply($"Goodbye!! T_T");
await connector.Conversations.ReplyToActivityAsync(reply);
return Request.CreateResponse(HttpStatusCode.OK);
}
else
{
LogMessageToDb(activity, userLoginData?.UserName);
}
await Conversation.SendAsync(activity, () => new RootLuisDialog());
}
My Luis dialog
[LuisModel("XXX", "XXX")]
[Serializable]
public class RootLuisDialog : LuisDialog<object>
{
/// <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 (message.Text == null)
{
// Return the Help/Welcome
await Help(context, null);
}
else
{
await base.MessageReceived(context, item);
}
}
[LuisIntent("Help")]
public async Task Help(IDialogContext context, LuisResult result)
{
var response = context.MakeMessage();
response.Summary = "Hi! Try asking me things like 'search for hotels in Seattle', 'search for hotels near LAX airport' or 'show me the reviews of The Bot Resort'";
response.Speak = @"<speak version=""1.0"" xml:lang=""en-US"">Hi! Try asking me things like 'search for hotels in Seattle', "
+ @"'search for hotels near<break time=""100ms""/>"
+ @" <break time=""200ms""/>airport', or 'show me the reviews of The Bot Resort'</speak>";
response.InputHint = InputHints.ExpectingInput;
await context.PostAsync(response);
context.Wait(MessageReceived);
}
}
Expected Behavior

Actual Results

@andy51002000 did you resolve this or is it still an issue? Also, have you tried adding application insights to get more information?
I've resolved this issue.
It seems I accessed the null value in activity.Text result in this problem. So I added a checking to avoid this case:
if (!string.IsNullOrEmpty(activity.Text)
&& activity.Text.ToLower().Contains("logout"))
{ ... }