private async Task <bool> CheckPictureAndAskForName(DetectiveBotContext context)
        {
            if (context.Request.Attachments != null && context.Request.Attachments.Count > 0)
            {
                string photo = context.Request.Attachments[0].ContentUrl;

                var person = await faceRecognitionService.IdentifyPerson(photo);

                if (person != null && !string.IsNullOrEmpty(person.Name))
                {
                    LatestImage = photo;
                    Suspect     = person;
                    var reply2 = BotReplies.ReplyWithOptions($"Is this {person.Name}?", new List <string>()
                    {
                        Intents.Yes, Intents.No
                    }, context);
                    await context.SendActivity(reply2);

                    State = TopicState.checkEsistingPerson;
                    return(true);
                }
                else
                {
                    LatestImage = photo;
                    var reply = context.Request.CreateReply("What is the name of this suspect?");
                    await context.SendActivity(reply);

                    State = TopicState.askedForName;
                    return(true);
                }
            }
            return(true);
        }
        private async Task <bool> CheckExistingPerson(DetectiveBotContext context)
        {
            if (context.RecognizedIntents.TopIntent?.Name == Intents.Yes)
            {
                var result = await faceRecognitionService.AddPhotoToExistingPerson(Suspect.PersonId, LatestImage);

                var reply = context.Request.CreateReply($"Added picture to {Suspect.Name}");
                await context.SendActivity(reply);
            }
            else
            {
                var result = await faceRecognitionService.AddNewPerson(Suspect.Name, LatestImage);

                var reply = context.Request.CreateReply($"Added picture to {Suspect.Name}");
                await context.SendActivity(reply);
            }

            var reply2 = BotReplies.ReplyWithOptions("Would you like to add another?", new List <string>()
            {
                Intents.Yes, Intents.No
            }, context);
            await context.SendActivity(reply2);

            State = TopicState.finished;
            return(true);
        }
Пример #3
0
        public async Task <bool> StartTopic(DetectiveBotContext context)
        {
            var reply = BotReplies.ReplyWithOptions("How may i help you?", new List <string>()
            {
                Intents.Train, Intents.IdentifySuspect, Intents.IdentifyMurderWeapon, Intents.MatchSuspect, Intents.DescribePerson
            }, context);
            await context.SendActivity(reply);

            State = TopicState.askedTopic;

            return(true);
        }
Пример #4
0
        public async Task <bool> StartTopic(DetectiveBotContext context)
        {
            var reply = BotReplies.ReplyWithOptions("What would you like to train?", new List <string>()
            {
                Intents.Suspects
            }, context);
            await context.SendActivity(reply);

            State = TopicState.askedTopic;

            return(true);
        }
        private async Task <bool> SaveName(DetectiveBotContext context)
        {
            var name   = context.Request.Text;
            var result = await faceRecognitionService.AddNewPerson(name, LatestImage);

            var reply = context.Request.CreateReply($"Added person {name}");
            await context.SendActivity(reply);

            var reply2 = BotReplies.ReplyWithOptions("Would you like to add another?", new List <string>()
            {
                Intents.Yes, Intents.No
            }, context);
            await context.SendActivity(reply2);

            State = TopicState.finished;

            return(true);
        }