Azure / semantic-kernel-bot-in-a-box

Extensible Semantic Kernel Bot Solution Accelerator
MIT License
55 stars 12 forks source link

Error on Teams bot #6

Closed c-nova closed 11 months ago

c-nova commented 1 year ago

When I tried to connect to this solution in Teams, I got an error and finished. I set up a Teams channel and just typed Hello after the first greeting message appeared.

After the system receives the message in Teams, it appears to be giving an error because the URI is NULL when trying to execute the function of file upload.

Bot Message: The bot encountered an error or bug. To continue to run this bot, please fix the bot source code.

The error message in the debug console is as follows.

Value cannot be null. (Parameter 'uriString') at System.ArgumentNullException.Throw(String paramName) at System.Uri..ctor(String uriString) at Microsoft.BotBuilderSamples.SKBot.HandleFileUpload(ConversationData conversationData, ITurnContext1 turnContext) in /Users/c-nova/Library/CloudStorage/OneDrive-Microsoft/Sources/demo/OpenAI/semantic-kernel-bot-in-a-box/src/Bots/SKBot.cs:line 122 at Microsoft.BotBuilderSamples.SKBot.ProcessMessage(ConversationData conversationData, ITurnContext1 turnContext) in /Users/c-nova/Library/CloudStorage/OneDrive-Microsoft/Sources/demo/OpenAI/semantic-kernel-bot-in-a-box/src/Bots/SKBot.cs:line 97 at Microsoft.BotBuilderSamples.StateManagementBot.OnMessageActivityAsync(ITurnContext`1 turnContext, CancellationToken cancellationToken) in /Users/c-nova/Library/CloudStorage/OneDrive-Microsoft/Sources/demo/OpenAI/semantic-kernel-bot-in-a-box/src/Bots/StateManagementBot.cs:line 53 at Microsoft.Bot.Builder.ActivityHandler.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) at Microsoft.BotBuilderSamples.StateManagementBot.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in /Users/c-nova/Library/CloudStorage/OneDrive-Microsoft/Sources/demo/OpenAI/semantic-kernel-bot-in-a-box/src/Bots/StateManagementBot.cs:line 30 at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken)

MarcoABCardoso commented 1 year ago

Hello @c-nova!

It seems Teams in currently incompatible with the latest version of the Upload plugin. I have a fix ready and am working to push this out later today as soon as validations are complete.

Thank you for pointing out this error and for your interest in the project!

Marco

c-nova commented 12 months ago

Hi @MarcoABCardoso !

My colleage found the mitigate plan for this issue.

public override async Task ProcessMessage(ConversationData conversationData, ITurnContext turnContext) { // Handle file uploads if (turnContext.Activity.Attachments?.Any(x => x.ContentUrl != null) == true) { if (!_config.GetValue("DOCINTEL_API_ENDPOINT").IsNullOrEmpty()) return await HandleFileUpload(conversationData, turnContext); else return "Document upload not supported as no Document Intelligence endpoint was provided"; }

Origianl code is wrote with "if (turnContext.Activity.Attachments?.Count > 0)", new one is changed to "if (turnContext.Activity.Attachments?.Any(x => x.ContentUrl != null) == true)". It seems mitigate miss route to file upload handler, but Teams upload is not to be able.

I hope you find it helpful.

MarcoABCardoso commented 12 months ago

Hey @c-nova!

There's an update out now to specifically target pdf attachments, as they're the only ones supported by the UploadPlugin. Please drop a comment if you're still having issues after the latest commit as of today.

On a side note, the actual file upload feature is still not supported on Teams, but it should stop interfering with regular messages now.

Thank you!

c-nova commented 11 months ago

@MarcoABCardoso , The issue wad resolved because of new one. Thank you so much!