1
votes

I didn't change any of my code and the method throws an LUIS.Runtime.Models.APIErrorException

_services.LuisServices[LuisConfiguration].RecognizeAsync(turnContext, cancellationToken);

I tried to use a different LUIS model and an old version of my bot that definately worked. It seems like something was changed in the BotBuilder and I can't figure out what. This is the stacktrace:

       Exception caught : Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models.APIErrorException: Operation returned an invalid status code 'Forbidden'
        at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Prediction.ResolveWithHttpMessagesAsync(String appId, String query, 
        Nullable`1 timezoneOffset, Nullable`1 verbose, 
        Nullable`1 staging, Nullable`1 spellCheck, String bingSpellCheckSubscriptionKey,
 Nullable`1 log, Dictionary`2 customHeaders, CancellationToken cancellationToken)
                 at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.PredictionExtensions.ResolveAsync(IPrediction operations, String appId, String query, 
    Nullable`1 timezoneOffset, Nullable`1 verbose, 
    Nullable`1 staging, 
    Nullable`1 spellCheck, 
    String bingSpellCheckSubscriptionKey, Nullable`1 log, CancellationToken cancellationToken)
                 at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer
    .RecognizeInternalAsync(ITurnContext turnContext, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder.AI.LUIS
    \LuisRecognizer.cs:line 421
                 at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer
    .RecognizeAsync(ITurnContext turnContext, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder.AI.LUIS
    \LuisRecognizer.cs:line 112
                 at NLPMortBot.BasicBot.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in nlpmortbot\NLPMortBot\BasicBot.cs:line 121
                 at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, 

CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder\MiddlewareSet.cs:line 55 at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) in D:\a\1\s\libraries\Microsoft.Bot.Builder\BotAdapter.cs:line 167

Thanks in advance guys !

1
Are you using the starter key? (the starter key has a low limit) or have you setup a subscription key? docs.microsoft.com/en-us/azure/cognitive-services/luis/…Eric Dahlvang
Hi. Thank you for your help. It worked. I found it strange as I created a new LUIS model using a different account and it didn't work.sala96
Could you please edit your question and make the exception more readable and eventually add your findings as your own reply?Ferdinand Fejskid

1 Answers

0
votes

This can happen if you are using the Starter Key instead of an actual Subscription Key from an 'endpoint runtime resource in Azure'. More information can be found here: https://docs.microsoft.com/en-us/azure/cognitive-services/luis/luis-how-to-azure-subscription

After creating the LUIS Azure Resource Key, it can be assigned within the LUIS Portal:

enter image description here

More information can be found here: https://docs.microsoft.com/en-us/azure/cognitive-services/luis/get-started-portal-deploy-app#assign-the-resource-key-to-the-luis-app-in-the-luis-portal