Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TeamsInfo.GetMemberAsync(...) doesn't work properly in Skill Bot scenario, it returns http 405 error. #6432

Closed
ramfattah opened this issue Aug 5, 2022 · 1 comment · Fixed by #6443
Assignees
Labels
bug Indicates an unexpected problem or an unintended behavior. customer-reported Issue is created by anyone that is not a collaborator in the repository.

Comments

@ramfattah
Copy link
Contributor

ramfattah commented Aug 5, 2022

[Summary]
Severity 3 = Urgent or High business impact, no SLA impact

[GENERAL INFO]
The TeamsInfo.GetMemberAsync() doesn't work properly in the Skill Bot scenario, it returns http 405 error. I can replicate the same issue on my lab,

[PROBLEM DESCRIPTION]

I used 80.skills-simple-bot-to-bot to reproduce this issue,

https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot

There are bot projects in the sample, one is root bot (SimpleRootBot) and another one is skill bot (EchoSkillBot). I use TeamsInfo.GetMemberAsync() in the EchoSkillBot.

  • It worked fine when I chat with EchoSkillBot directly with Teams channel. This method can return Teams account information.
  • It returned bot encounterred error when I started to chat with SimpleRootBot and handoff conversation to EchoSkillBot

image

Noted,

weyao-SkillBot is SimpleRootBot

weyao-EchoBot is EchoSkillBot

I can see the 405 error in the application's trace log

. I replicated the same issue on a simple SkillBot.

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]

      Request starting HTTP/1.1 GET [http://f74f-167-220-255-106.ngrok.io/api/skills/v3/conversations/c0d9e65e-4333-4f99-8692-183708b871a5/members/29:1Cxm-gcZsC9F-g2a-eGy5UcNCWddONWz0ZCWeicK8s24sbZBsss0FuWJY0ElL8r380i6Bn3ifRhh5oPdEuFeeJQ](https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Ff74f-167-220-255-106.ngrok.io%2Fapi%2Fskills%2Fv3%2Fconversations%2Fc0d9e65e-4333-4f99-8692-183708b871a5%2Fmembers%2F29%3A1Cxm-gcZsC9F-g2a-eGy5UcNCWddONWz0ZCWeicK8s24sbZBsss0FuWJY0ElL8r380i6Bn3ifRhh5oPdEuFeeJQ&data=05%7C01%7CWei.Yao%40microsoft.com%7C227d0470e5a1477c48b108da74286c10%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637950014330398888%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=npVjSKJCrGDq5qOKPl9EiicMJ5FgsIu7stBxv%2Fuh%2FuI%3D&reserved=0) - -info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]

      Executing endpoint '405 HTTP Method Not Supported'

info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]

      Executed endpoint '405 HTTP Method Not Supported'

info: Microsoft.AspNetCore.Hosting.Diagnostics[2]

      Request finished HTTP/1.1 GET [http://f74f-167-220-255-106.ngrok.io/api/skills/v3/conversations/c0d9e65e-4333-4f99-8692-183708b871a5/members/29:1Cxm-gcZsC9F-g2a-eGy5UcNCWddONWz0ZCWeicK8s24sbZBsss0FuWJY0ElL8r380i6Bn3ifRhh5oPdEuFeeJQ](https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Ff74f-167-220-255-106.ngrok.io%2Fapi%2Fskills%2Fv3%2Fconversations%2Fc0d9e65e-4333-4f99-8692-183708b871a5%2Fmembers%2F29%3A1Cxm-gcZsC9F-g2a-eGy5UcNCWddONWz0ZCWeicK8s24sbZBsss0FuWJY0ElL8r380i6Bn3ifRhh5oPdEuFeeJQ&data=05%7C01%7CWei.Yao%40microsoft.com%7C227d0470e5a1477c48b108da74286c10%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637950014330398888%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=npVjSKJCrGDq5qOKPl9EiicMJ5FgsIu7stBxv%2Fuh%2FuI%3D&reserved=0) - - - 405 0 - 9.0898ms

info: Microsoft.Bot.Builder.Integration.AspNet.Core.IBotFrameworkHttpAdapter[0]

      SendActivitiesAsync for 1 activities.

info: Microsoft.Bot.Builder.Integration.AspNet.Core.IBotFrameworkHttpAdapter[0]

      Sending activity.  ReplyToId: 1659251898544


[TROUBLESHOOTING STEPS]

I added the code snippet in the EchoSkillBot for testing TeamsInfo.GetMemberAsync(...)
image

Here is the source code of TeamsInfo.GetMemberAsync(...),
image

As I investigated,

  • Working scenario, when I call EchoSkillBot directly by Teams channel. The logical condition of if was true and it executed if branch.
  • Non-working scenario, when I started the conversation from SimpleRootBot and handoff it to EchoSkillBot. The condition is false and it executed else branch.

image
image
image

Based on the source code, it will create a HTTP GET request to “https://{rootbot}/api/skills/v3/conversations/{conversationId}/members/{userId}”. This request was sent to SimpleRootBot and routed to GetConversationMembersAsync(…) of SkillController. But the HTTP attribute doesn't have {UserID} in the URL rule.

image

I think that's the root cause of this issue.

[BUSINESS IMPACT]
One Premire customer used TeamsInfo.GetMemberAsync(...) in their Skill Bot. They experienced error and raised a ticket to CSS team. Customer uses Graph API relace of this method now.

[ASK FOR PG]

Need to check and confirm whether it's a bug or not. If it's a SDK bug, please help to fix it.

@ramfattah ramfattah added bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team. labels Aug 5, 2022
@ramfattah
Copy link
Contributor Author

Hey @JuanAr

I'm able to reproduce this issue where if we call the method TeamsInfo.GetMemberAsync(...) from the Root bot to EchoSkillBot. It throws The skill encountered an error or bug.

Example:
image

Sharing the steps I took:

  1. Clone sample 80.skills-simple-bot-to-bot
  2. In EchoSkillBot, update the OnMessageActivityAsync method in EchoBot.cs with below code:
        protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            if (turnContext.Activity.Text.Contains("end") || turnContext.Activity.Text.Contains("stop"))
            {
                // Send End of conversation at the end.
                var messageText = $"ending conversation from the skill...";
                await turnContext.SendActivityAsync(MessageFactory.Text(messageText, messageText, InputHints.IgnoringInput), cancellationToken);
                var endOfConversation = Activity.CreateEndOfConversationActivity();
                endOfConversation.Code = EndOfConversationCodes.CompletedSuccessfully;
                await turnContext.SendActivityAsync(endOfConversation, cancellationToken);
            }
            else if (turnContext.Activity.Text.Contains("test"))
            {
                try
                {
                    var activity = turnContext.Activity;
                    var member = new TeamsChannelAccount();
                    if (activity.ChannelId == Channels.Msteams)
                    {
                        member = await TeamsInfo.GetMemberAsync(turnContext, activity.From.Id, cancellationToken);
                        if (member.Name != null)
                        {
                            await turnContext.SendActivityAsync(MessageFactory.Text(member.Name), cancellationToken);
                        }
                        else
                        {
                            await turnContext.SendActivityAsync(MessageFactory.Text("member.Name is null"), cancellationToken);
                        }
                    }
                    else
                    {
                        await turnContext.SendActivityAsync(MessageFactory.Text("ChannelID is not msTeams"), cancellationToken);
                    }
                }
                catch (System.Exception ex)
                {
                    logger.LogInformation(ex.Message);
                    throw;
                }

            }
            else
            {
                var messageText = $"Echo: {turnContext.Activity.Text}";
                await turnContext.SendActivityAsync(MessageFactory.Text(messageText, messageText, InputHints.IgnoringInput), cancellationToken);
                messageText = "Say \"end\" or \"stop\" and I'll end the conversation and back to the parent.";
                await turnContext.SendActivityAsync(MessageFactory.Text(messageText, messageText, InputHints.ExpectingInput), cancellationToken);
            }
        }
  1. Start the sample from SimpleRootBot and handoff it to EchoSkillBot to test the TeamsInfo.GetMemberAsync(...) in Teams Channel
  2. Notice the error
    image

@tracyboehrer tracyboehrer added customer-reported Issue is created by anyone that is not a collaborator in the repository. and removed needs-triage The issue has just been created and it has not been reviewed by the team. labels Aug 9, 2022
tracyboehrer pushed a commit that referenced this issue Aug 30, 2022
…Bot scenario, it returns http 405 error (#6443)

* Implement GetMemberAsync for skills

* Add unit test
tracyboehrer pushed a commit that referenced this issue Sep 1, 2022
…Bot scenario, it returns http 405 error (#6443)

* Implement GetMemberAsync for skills

* Add unit test
tracyboehrer added a commit that referenced this issue Sep 1, 2022
* README version to 4.18 (#6425)

Co-authored-by: Tracy Boehrer <[email protected]>

* [#6434] Priority broken for RegexRecognizer (#6435)

* Consider priority in OnRecognizeAsync method

* Add unit test

* Update Bool function to use Convert.ToBoolean (#6431)

* Update IsMatch empty string values (#6426)

* [#6428] Adaptive ForEachElement loop's incorrectly when changes cause ContinueDialogAsync to be recalled (#6448)

* Reacquire childDialogState after ContinueDialogAsync

* Add unit test

* Support passing sas token url's for token service (#6449)

Co-authored-by: Swagat Mishra <[email protected]>

* Bump @actions/core from 1.6.0 to 1.9.1 in /actions/verify-pr-labels (#6445)

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.6.0 to 1.9.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Support passing sas token url's for token service (#6449)

Co-authored-by: Swagat Mishra <[email protected]>

* [#6428] Adaptive ForEachElement loop's incorrectly when changes cause ContinueDialogAsync to be recalled (#6448)

* Reacquire childDialogState after ContinueDialogAsync

* Add unit test

* Delete vnext code which is dead (#6440)

* Fix PublishToCoveralls.ps1 (#6439)

* Remove failing Powershell patch download

* Upgrade coveralls.net to 4.0.1

* [#6430] Adaptive ForEachElement does not exit when child action CancelAllDialogs is called (#6452)

* Consider canceled status to end the dialog

* Add unit test

* [#6432] TeamsInfo.GetMemberAsync(...) doesn't work properly in Skill Bot scenario, it returns http 405 error (#6443)

* Implement GetMemberAsync for skills

* Add unit test

* [#6433] Error in AdaptiveDialog.ContinueActionAsync with native dialog SDK (#6444)

* Add condition before loading the resource

* Add unit tests

* Load AdaptiveDialogs dynamically on DialogContext

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Tracy Boehrer <[email protected]>
Co-authored-by: Cecilia Avila <[email protected]>
Co-authored-by: Joel Mut <[email protected]>
Co-authored-by: swagat mishra <[email protected]>
Co-authored-by: Swagat Mishra <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: BruceHaley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or an unintended behavior. customer-reported Issue is created by anyone that is not a collaborator in the repository.
Projects
None yet
3 participants