public static async Task HandleScheduleCommand(IDialogContext context, Activity activity, string[] keywords) { JObject ctx = activity.Value as JObject; // Check if this is a button press or a text command. if (ctx != null) { JObject scheduleRequest = JObject.Parse((string)ctx["body"]); DateTime scheduleDate = DateTime.Parse((string)scheduleRequest["date"]); // make call to the Microsoft Graph to schedule the interview await MessageHelpers.SendMessage(context, $"Interview scheduled for position {scheduleRequest["reqId"]} with {scheduleRequest["name"]} on {scheduleDate.ToShortDateString()}"); } else if (keywords.Length == 3) { string name = string.Join(" ", keywords.Take(2).ToArray()); string reqId = keywords[2]; // Takes 3 parameters: first name, last name, and then req ID await SendScheduleInterviewMessage(context, name, reqId); } else { await MessageHelpers.SendMessage(context, MessageHelpers.CreateHelpMessage("I'm sorry, I did not understand you :(")); } }
private async Task <Activity> HandleSystemMessageAsync(Activity message) { TeamEventBase eventData = message.GetConversationUpdateData(); switch (eventData.EventType) { case TeamEventType.MembersAdded: var connector = new ConnectorClient(new Uri(message.ServiceUrl)); connector.SetRetryPolicy( RetryHelpers.DefaultPolicyBuilder.WaitAndRetryAsync( new[] { TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10) }) ); var tenantId = message.GetTenantId(); var channelData = message.GetChannelData <TeamsChannelData>(); var botAccount = message.Recipient; // if the bot is in the collection of added members, // then send a welcometo all team members if (message.MembersAdded.Any(m => m.Id.Equals(botAccount.Id))) { // Fetch the members in the current conversation IList <ChannelAccount> channelAccount = await connector.Conversations.GetConversationMembersAsync( message.Conversation.Id); IEnumerable <TeamsChannelAccount> members = channelAccount.AsTeamsChannelAccounts(); // send a OneToOne message to each member foreach (TeamsChannelAccount member in members) { await MessageHelpers.SendOneToOneWelcomeMessage( connector, channelData, botAccount, member, tenantId); } } else { string messageText = MessageHelpers.CreateHelpMessage($"The team {channelData.Team.Name} has the Talent Management bot- helping your team to find and hire candidates."); string messageSummary = "This team has the Talent Management bot"; // send a OneToOne message to new members foreach (TeamsChannelAccount member in message.MembersAdded.AsTeamsChannelAccounts()) { await MessageHelpers.SendPriorityMessage(messageText, messageSummary, connector, botAccount, member, tenantId); } } break; case TeamEventType.MembersRemoved: break; case TeamEventType.ChannelCreated: break; case TeamEventType.ChannelDeleted: break; case TeamEventType.ChannelRenamed: break; case TeamEventType.TeamRenamed: break; default: break; } return(null); }