microsoft / BotFramework-Composer

Dialog creation and management for Microsoft Bot Framework Applications
https://docs.microsoft.com/en-us/composer/
MIT License
870 stars 372 forks source link

[v1.1.1] Issue with Telegram channel #4030

Closed EPinci closed 4 years ago

EPinci commented 4 years ago

Describe the issue

Not sure if this is a Composer bug or not, but I'm short of ideas and I'll appreciate if you have any guidance in here.

My bot works fine locally, I can test it fine with the bot emulator. When I hook it up with the azure bot channel service I can validate it works fine with the web channel and skype channel as well. Telegram, however, errors out and I get the following (a bit cryptic) stack trace:

[14:13:19 ERR] Exception caught : System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.MultiLanguageRecognizer.RecognizeAsync(DialogContext dialogContext, Activity activity, CancellationToken cancellationToken, Dictionary`2 telemetryProperties, Dictionary`2 telemetryMetrics)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.CrossTrainedRecognizerSet.<>c__DisplayClass7_0.<<RecognizeAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.CrossTrainedRecognizerSet.RecognizeAsync(DialogContext dialogContext, Activity activity, CancellationToken cancellationToken, Dictionary`2 telemetryProperties, Dictionary`2 telemetryMetrics)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.RecognizerSet.RecognizeAsync(DialogContext dialogContext, Activity activity, CancellationToken cancellationToken, Dictionary`2 telemetryProperties, Dictionary`2 telemetryMetrics)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.OnRecognizeAsync(ActionContext actionContext, Activity activity, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.ProcessEventAsync(ActionContext actionContext, DialogEvent dialogEvent, Boolean preBubble, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.ProcessEventAsync(ActionContext actionContext, DialogEvent dialogEvent, Boolean preBubble, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.ProcessEventAsync(ActionContext actionContext, DialogEvent dialogEvent, Boolean preBubble, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.OnPreBubbleEventAsync(DialogContext dc, DialogEvent dialogEvent, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Dialog.OnDialogEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContainer.OnDialogEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.Adaptive.AdaptiveDialog.BeginDialogAsync(DialogContext dc, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogContext.BeginDialogAsync(String dialogId, Object options, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogManager.HandleBotOnTurnAsync(DialogContext dc, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Dialogs.DialogManager.OnTurnAsync(ITurnContext context, CancellationToken cancellationToken)   at Microsoft.Bot.Builder.Dialogs.DialogManager.OnTurnAsync(ITurnContext context, CancellationToken cancellationToken)   at BCBot.ComposerBot.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in /src/BCBot/Services/ComposerBot.cs:line 61
   at Microsoft.Bot.Builder.TelemetryLoggerMiddleware.OnTurnAsync(ITurnContext context, NextDelegate nextTurn, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.Integration.ApplicationInsights.Core.TelemetryInitializerMiddleware.OnTurnAsync(ITurnContext context, NextDelegate nextTurn, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.RegisterClassMiddleware`1.OnTurnAsync(ITurnContext turnContext, NextDelegate nextTurn, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.RegisterClassMiddleware`1.OnTurnAsync(ITurnContext turnContext, NextDelegate nextTurn, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.RegisterClassMiddleware`1.OnTurnAsync(ITurnContext turnContext, NextDelegate nextTurn, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.RegisterClassMiddleware`1.OnTurnAsync(ITurnContext turnContext, NextDelegate nextTurn, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.BotFrameworkAdapter.TenantIdWorkaroundForTeamsMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken)
   at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken)

Since I've been recently been working to move from an "en-us" bot to my local language, thanks to the last composer release, I'm leaning to think that the issue lies in there (?).

I have a composer generated bot that is set to have only the "it-it" locale and I set a default policy to fallback on it. I also use LUIS and the default language is set the same.

Might https://github.com/microsoft/botbuilder-dotnet/issues/4143 be related?

Version

v1.1.1

Browser

OS

EPinci commented 4 years ago

Further troubleshooting makes me think this is not Composer related. Closing this in favor of https://github.com/microsoft/botbuilder-dotnet/issues/4599

amolsangar commented 4 years ago

The issue still persists. Creating a bot on Composer and then deploying it Telegram channel results in the following error: Object reference not set to an instance of an object

Any solutions or fixes for this yet?

EPinci commented 4 years ago

Hey, this is not a composer issue, it's a bot framework issue (see the link above). It has already been fixed though I think this has not made it yet to a release.

If you need now a band-aid with composer you can:

   // Temporary fix for telegram channel
   turnContext.Activity.Locale = turnContext.Activity.Locale ?? "";

HTH.

amolsangar commented 4 years ago

@EPinci Thanks a lot for the quick reply. This definitely works now as expected.

I changed the file at '/runtime/core/ComposerBot.cs' as you mentioned. This really saved my time. Thanks again :)