Adam
Adam

Reputation: 483

Microsoft Bot Emulator "Sorry, my bot code is having an issue", how do I debug this?

I am having trouble with my MS.Bot.Framework + Luis + Azure

 await Conversation.SendAsync(activity, () => { return Chain.From(() => 
 new LUISDialog() as IDialog<object>); });

I have active Azure subscription, set up endpoint with subscription keys.

When running the MS Bot emulator I get error message "Sorry, my bot code is having trouble." Using breakpoint in debug mode, I have worked out that the "new LUISDialog" is not being triggered, it seems to skip over it.

using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using System.Threading;
using George;
using Microsoft.Bot.Connector;

namespace Geoge.Dialog
{
    [LuisModel("*****", "*****")]
    [Serializable]
    public class LUISDialog : LuisDialog<object>
    {

        [LuisIntent("Greeting")]
        public async Task GreetingIntent(IDialogContext context, 
            IAwaitable<IMessageActivity> activity, LuisResult result)
        {
            string message = $"Hello there";
            await context.PostAsync(message);
            context.Wait(this.MessageReceived);
        }

Can anyone help me with this? I have spend way to much time trying to debug and think I must be missing something simple.

Upvotes: 1

Views: 535

Answers (2)

Indi
Indi

Reputation: 1449

I faced the same issue though the particular code snippet was correct. It got fixed after I published my LUIS app on to Production. Also the error on emulator said - Bad Request

I thought this might help someone in the future.

Upvotes: 0

Nicolas R
Nicolas R

Reputation: 14619

What is strange is your initial code line:

await Conversation.SendAsync(activity, () => { return Chain.From(() => new LUISDialog() as IDialog<object>); });

If you want to use your LuisDialog, you should not have this Chain here but rather something like the following:

await Conversation.SendAsync(activity, () => new LUISDialog());

Upvotes: 1

Related Questions