I am having the same issue. the possible scopes on my manifest are personal and team, however when I install it on the teams scope I am getting the notification on both, team and personal scopes.
this is my code:
import * as dotenv from 'dotenv';
import { TeamsActivityHandler, TurnContext, MessageFactory, CardFactory } from "botbuilder";
const environment = process.env.NODE_ENV || 'dev'; // Default to 'dev' if NODE_ENV is not set
dotenv.config({ path: `env/.env.${environment}` });
export class TeamsBot extends TeamsActivityHandler {
private callbackUrl: string;
constructor() {
super();
// Handle bot installation
this.onInstallationUpdateAdd(async (context: TurnContext, next: () => Promise<void>) => {
dotenv.config();
const conversationType = context.activity.conversation?.conversationType;
let configurationUrl = process.env.CONFIGURATION_URL; //base URL of Snappy integrations
// Check if the app is installed in a team or personal scope
if (conversationType === "channel") {
// For team scope installation
const channelId = context.activity.conversation?.id;
const teamName = context.activity.channelData?.team?.name;
// Add teamId and teamName to the configuration URL
configurationUrl += `?teamId=${channelId}&teamName=${teamName}`;
} else if (conversationType === "personal") {
// For personal scope installation
const userId = context.activity.from?.id;
// Add userId and userName (or any other equivalent) to the configuration URL
configurationUrl += `?teamId=${userId}&teamName=member-level`;
}
// Adaptive card payload
const adaptiveCard = {
.....
.....
};
console.log(`configurationUrl = ${configurationUrl}`);
// Send the adaptive card as the welcome message
await context.sendActivity(MessageFactory.attachment(CardFactory.adaptiveCard(adaptiveCard)));
// Proceed to the next middleware or handler
await next();
});
}
}