/// <inheritdoc /> public async Task OnReceiveActivity(IBotContext context) { var botContext = new DetectiveBotContext(context, _faceRecognitionService, _customVisionService); switch (botContext.Request.Type) { case ActivityTypes.ConversationUpdate: await GetOrAddUserProfile(botContext); break; case ActivityTypes.Message: await HandleMessage(botContext); break; } }
private async Task GetOrAddUserProfile(IBotContext botContext) { try { var context = new DetectiveBotContext(botContext, _faceRecognitionService, _customVisionService); var activity = context.Request.AsConversationUpdateActivity(); var user = activity.MembersAdded.Where(m => m.Id == activity.Recipient.Id).FirstOrDefault(); if (user != null) { await context.SendActivity($"Hello {user.Name}, welcome to the Detective bot!"); } } catch (Exception ex) { _logger.LogError(ex, "Failed to get user."); } }
public static Activity ReplyWithOptions(string question, List <string> options, DetectiveBotContext context) { var reply = context.Request.CreateReply(question); reply.SuggestedActions = new SuggestedActions( actions: options.Select(option => new CardAction(type: ActionTypes.ImBack, title: option, value: option)).ToList()); return(reply); }