Luis integrering kaster feil

stemmer
2

Jeg har begynt å integrere Luis inn i min BOT, den LUIS spørringen fungerer bra i nettleseren, men det ser ut når påberopes gjennom koden, noe som kommer tilbake fra LUIS GetResult kaster en feil.

Den LUIS søket er her

Kildekoden i dialogboksen:

 [LuisModel(2d3e39d8-632a-4e00-bf2f-d98ea4b2ed79&, subscription Key)]
    [Serializable]
    public class SupportDialog : LuisDialog<object>
    {

        [LuisIntent()]
        public async Task None(IDialogContext context, LuisResult result)
        {
            await context.PostAsync(Sorry, I dont understand what you need);
            context.Wait(MessageReceived);
        }


        [LuisIntent(OrderStatus)]
        public async Task OrderStatus(IDialogContext context, LuisResult result)
        {
            var returnMsg = You wanted to check the order status;
            var orderStatus = Dispatched;
            var deliveryDate = DateTime.Now.AddDays(3);

            var entities = new List<EntityRecommendation>(result.Entities);
            if(entities.Any((entity)=> entity.Type == Order))
            {
                var orderEntity = entities.Where((entity) => entity.Type == Order).FirstOrDefault();
                var resolutionStr = orderEntity.Resolution.FirstOrDefault().Value ?? null;
                if(!string.IsNullOrEmpty(resolutionStr))
                {
                    returnMsg = Your order  + resolutionStr +  status is  + orderStatus +  and expected to deliver by  + deliveryDate.Humanize();
                }
            }

            await context.PostAsync(returnMsg);
            context.Wait(MessageReceived);
        }

    }

MessageController Kildekode:

 internal static IDialog<object> MakeRoot()
        {
            return Chain.From(() => new SupportDialog());
        }

        [ResponseType(typeof(void))]
        public virtual async Task<HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity != null)
            {
                // one of these will have an interface and process it
                switch (activity.GetActivityType())
                {
                    case ActivityTypes.Message:
                        await Conversation.SendAsync(activity, MakeRoot);
                        break;

                    case ActivityTypes.ConversationUpdate:
                    case ActivityTypes.ContactRelationUpdate:
                    case ActivityTypes.Typing:
                    case ActivityTypes.DeleteUserData:
                    default:
                        Trace.TraceError($Unknown activity type ignored: {activity.GetActivityType()});
                        break;
                }
            }
            return new HttpResponseMessage(System.Net.HttpStatusCode.Accepted);
        }

Jeg får følgende feilmelding (bare delvis utdrag) i mitt BOT Emulator når du prøver å feilsøke:

> Exception: System.Net.Http.HttpRequestException: Response status code
> does not indicate success: 400 (Bad Request).\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Luis.LuisService.<Microsoft-Bot-Builder-Luis-ILuisService-QueryAsync>d__4.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Luis.Extensions.<QueryAsync>d__3.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.LuisDialog`1.<MessageReceived>d__7.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume`1.<Rest>d__4.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Wait`2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Frame`1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__7.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Fiber`1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__13.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n  
> at
> Microsoft.Bot.Builder.Internals.Fibers.Wait`2.Microsoft.Bot.Builder.Internals.Fibers.IAwaiter<T>.GetResult()\r\n
> at
> Microsoft.Bot.Builder.Dialogs.Chain.FromDialog`1.<ResumeAsync>d__3.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume`1.<Rest>d__4.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Wait`2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Frame`1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__7.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Fiber`1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__13.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n  
> at
> Microsoft.Bot.Builder.Internals.Fibers.Wait`2.Microsoft.Bot.Builder.Internals.Fibers.IAwaiter<T>.GetResult()\r\n
> at
> Microsoft.Bot.Builder.Dialogs.Chain.LoopDialog`1.<ResumeAsync>d__3.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.ThunkResume`1.<Rest>d__4.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Wait`2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Frame`1.<Microsoft-Bot-Builder-Internals-Fibers-IFrameLoop<C>-PollAsync>d__7.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Internals.Fibers.Fiber`1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__13.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IDialogStack-PollAsync>d__19.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.DialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__21`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.ReactiveDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.ExceptionTranslationDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__2`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.LocalizedDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__2`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.ScoringDialogTask`1.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__6`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__6`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n  
> at
> Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__6`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.SerializingDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__4`1.MoveNext()\r\n---
> End of stack trace from previous location where exception was thrown
> ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
> task)\r\n   at
> System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n   at
> Microsoft.Bot.Builder.Dialogs.Internals.PostUnhandledExceptionToUserTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__5`1.MoveNext()
Publisert på 21/09/2016 klokken 09:23
kilden bruker
På andre språk...                            


3 svar

stemmer
6

Fjern tegnet skilt i LuisModel.

Jeg antar du kopierte den fra nettadressen uhell.

Også endre abonnementsnøkkelen du lagt inne koden din, eller annet vi vil stjele den.

Svarte 21/09/2016 kl. 11:39
kilden bruker

stemmer
3

Dette nedenfor feilen kan også komme; når du publiserer LUIS appen under Staging sporet

Response status code does not indicate success: 400 (Bad Request)

Så alltid publisere LUIS appen under produksjon slot

Og selvsagt må du fjerne tegn ( & ) skilt fra LuisModel ID.

Svarte 31/03/2017 kl. 22:19
kilden bruker

stemmer
3

Det er en linje med kode som kan kaste en nullreferanse unntak:

var resolutionStr = orderEntity.Resolution.FirstOrDefault().Value ?? null;

Prøv å skrive det neste måte:

var resolutionStr = orderEntity.Resolution.FirstOrDefault()?.Value;
Svarte 21/09/2016 kl. 10:29
kilden bruker

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more