microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.45k forks source link

Remove app from personal scope #6604

Closed jnaglis closed 1 year ago

jnaglis commented 1 year ago

Describe the bug

When app is removed from personal scope OnTeamsMembersRemovedAsync is not called. In some cases has been observed that also OnInstallationUpdateAddAsync and OnTeamsMembersAddedAsync called after removing app from personal scope.

To Reproduce

Steps to reproduce the behavior:

  1. Install app to personal scope by uploading manifest
  2. Remove app from personal scope

Expected behavior

OnMembersRemovedAsync called after app removed from personal scope. And not OnInstallationUpdateAddAsync and OnTeamsMembersAddedAsync.

breakingram commented 1 year ago

Thanks @jnaglis, I'm looking into this.

breakingram commented 1 year ago

Hi @jnaglis,

are you removing the app in Teams application or Teams Admin Center portal?

jnaglis commented 1 year ago

Hi @ramfattah, In Teams application.

breakingram commented 1 year ago

Hi @jnaglis,

For uninstallation in the personal scope, the "Install update event" is triggered, aligning with the official Teams documentation. It appears this behavior is by design.

Please refer to the Uninstall behavior for personal app with bot for more details.

Example:

protected override async Task OnInstallationUpdateActivityAsync(ITurnContext<IInstallationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
    var activity = turnContext.Activity;
    if (string.Equals(activity.Action, "Add", StringComparison.InvariantCultureIgnoreCase))
    {
        // TO:DO Installation workflow.
    }
    else
    {
        // TO:DO Uninstallation workflow.
    }
    return;
}