/// <summary> /// Send a welcome message to the user that was just added to a team. /// </summary> /// <param name="connectorClient">The connector client</param> /// <param name="memberAddedId">The id of the added user</param> /// <param name="tenantId">The tenant id</param> /// <param name="teamId">The id of the team the user was added to</param> /// <param name="botInstaller">The person that installed the bot</param> /// <returns>Tracking task</returns> public async Task WelcomeUser(ConnectorClient connectorClient, string memberAddedId, string tenantId, string teamId, string botInstaller) { this.telemetryClient.TrackTrace($"Sending welcome message for user {memberAddedId}"); var teamName = await this.GetTeamNameAsync(connectorClient, teamId); var allMembers = await connectorClient.Conversations.GetConversationMembersAsync(teamId); ChannelAccount userThatJustJoined = null; foreach (var m in allMembers) { // both values are 29: values if (m.Id == memberAddedId) { userThatJustJoined = m; break; } } if (userThatJustJoined != null) { var welcomeMessageCard = WelcomeNewMemberAdaptiveCard.GetCard(teamName, userThatJustJoined.Name, this.botDisplayName, botInstaller); await this.NotifyUser(connectorClient, welcomeMessageCard, userThatJustJoined, tenantId); } else { this.telemetryClient.TrackTrace($"Member {memberAddedId} was not found in team {teamId}, skipping welcome message.", SeverityLevel.Warning); } }
private async Task HandleDebugWelcomeUser(ConnectorClient connectorClient, Activity activity, string teamId) { var welcomeCard = WelcomeNewMemberAdaptiveCard.GetCard( new TeamContext { TeamId = teamId, TeamName = "TestTeam" }, Model.EnrollmentStatus.NotJoined, "InstallerPerson", false); var replyActivity = activity.CreateReply(); replyActivity.Attachments = new List <Attachment> { AdaptiveCardHelper.CreateAdaptiveCardAttachment(welcomeCard) }; await connectorClient.Conversations.ReplyToActivityAsync(replyActivity); }
/// <summary> /// Send a welcome message to the user that was just added to a team. /// </summary> /// <param name="turnContext">Context object containing information cached for a single turn of conversation with a user.</param> /// <param name="memberAddedId">The id of the added user</param> /// <param name="tenantId">The tenant id</param> /// <param name="teamId">The id of the team the user was added to</param> /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param> /// <returns>Tracking task</returns> private async Task WelcomeUser(ITurnContext turnContext, string memberAddedId, string tenantId, string teamId, CancellationToken cancellationToken) { this.telemetryClient.TrackTrace($"Sending welcome message for user {memberAddedId}"); var installedTeam = await this.GetInstalledTeam(teamId); var teamName = turnContext.Activity.TeamsGetTeamInfo().Name; ChannelAccount userThatJustJoined = await this.conversationHelper.GetMemberAsync(turnContext, memberAddedId, cancellationToken); if (userThatJustJoined != null) { var welcomeMessageCard = WelcomeNewMemberAdaptiveCard.GetCard(teamName, userThatJustJoined.Name, this.botDisplayName, installedTeam.InstallerName); await this.conversationHelper.NotifyUserAsync(turnContext, MessageFactory.Attachment(welcomeMessageCard), userThatJustJoined, tenantId, cancellationToken); } else { this.telemetryClient.TrackTrace($"Member {memberAddedId} was not found in team {teamId}, skipping welcome message.", SeverityLevel.Warning); } }