Esempio n. 1
0
        private async Task ProcessSentimentAnalysis(IDialogContext context, LuisResult luisResult)
        {
            var result = await TextAnalyticsService.AnalyseSentiment(luisResult.Query);

            if (result.Score.Value > 0.7)
            {
                await context.PostAsync("Merci d'apprecié nos services. Nous travaillons dur pour vous offrir un service de qualité");

                context.Wait(MessageReceived);
            }
            else
            {
                var feedbackForm = new FormDialog <FeedbackForm>(new FeedbackForm(), FeedbackForm.BuildForm, FormOptions.PromptInStart);
                context.Call <FeedbackForm>(feedbackForm, ResumeAfterDialog);
            }
        }
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                var result = await TextAnalyticsService.AnalyseSentiment(activity.Text);

                var reply = activity.CreateReply();

                reply.Text  = "Votre langue est : " + result.LanguageName + "\n\n";
                reply.Text += "Les mots clés trouvés sont : ";

                foreach (var item in result.KeyPhrases)
                {
                    reply.Text += item + " ";
                }

                if (result.Score.Value > 0.5)
                {
                    reply.Text += "\n\n Vous semblez heureux. Votre score est de : " + result.Score.Value;
                }
                else
                {
                    reply.Text += "\n\n Vous ne semblez pas heureux. Votre score est de : " + result.Score.Value;
                }

                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));

                await connector.Conversations.ReplyToActivityAsync(reply);
            }
            else
            {
                await HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }