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

context.EndConversation() dosnt work with msteams channel #4774

Closed
Wenish opened this issue Jun 21, 2018 · 4 comments
Closed

context.EndConversation() dosnt work with msteams channel #4774

Wenish opened this issue Jun 21, 2018 · 4 comments

Comments

@Wenish
Copy link

Wenish commented Jun 21, 2018

Bot Info

  • SDK Platform: .NET
  • SDK Version: 3.15.2.2
  • Active Channels: MS Teams, Direct Line
  • Deployment Environment: Azure Bot Service

Issue Description

If you use context.EndConversation("200"); and the user is with msteams to the bot connected the bot throws an error. This does only happens in msteams channel

Code Example

Its the basic bot example with 1 line changed

    private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
    {
        var activity = await result as Activity;

        // Calculate something for us to return
        int length = (activity.Text ?? string.Empty).Length;

        // Return our reply to the user
        await context.PostAsync($"You sent {activity.Text} which was {length} characters");

        context.EndConversation("200"); //<----- this line fails with msteams
    }

https://drive.google.com/open?id=1oPVWoZ6CKmfXlpiWCAxZpIti8aAuvdqv

Reproduction Steps

  1. Register Bot
  2. Add MS Teams Channel
  3. Write a msg to bot via msteams

Expected Behavior

Like on the other channels it should not throw an error

Actual Results

The Bot send to the user:
Sorry my Bot Code is having an issue
hey

@Wenish Wenish changed the title contect.EndConversation() dosnt work with msteams channel context.EndConversation() dosnt work with msteams channel Jun 21, 2018
@sbuffkin
Copy link

EndConversation is not supported in MS Teams, part of its functionality is to delete conversationData, which is not enabled within MS Teams for compliance reasons. The error is left on so that it's clear to the user that it isn't a valid action for that channel. This is covered in more detail in these two github issues.

#3379
OfficeDev/BotBuilder-MicrosoftTeams#62

To fix your current issue filter out any calls coming from MSTeams from your endConversation call via:

if(ChannelIds.Teams != activity.ChannelID)

That said, we will look into updating our documentation for endConversation so this is more obvious.

@xiaolangxyz
Copy link

@nyxsys @Wenish
I have the same problem. Do you have a any suggestions instead of using EndConversation?

@Wenish
Copy link
Author

Wenish commented Nov 22, 2018

@xiaolangxyz
we handle it like this:
on a child dialog we always make context done

context.Done<bool>(true);

and on the root dialog we check if the bot is with msteams or something else connected:

private async Task ResumeAfterChildDialogAsync(IDialogContext context, IAwaitable<object> result)
        {
            try
            {
                var message = await result;
            }
            catch (Exception ex)
            {
                await context.PostAsync($"{Text.Failed}: {ex.Message}");
            }
            finally
            {
                if(context.Activity.ChannelId == ChannelIds.Msteams)
                {
                    context.Wait(MessageReceivedAsync);
                } else
                {
                    context.EndConversation("200");
                }
            }
        }

@amistry79
Copy link

How can we fix this issue with bot (VA and Skill) which was developed using typescript? We dont see below method support in the typescript library.

context.Done(true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants