Exemple #1
0
        public IHttpActionResult Post([FromBody] Activity activity)
        {
            if (string.IsNullOrEmpty(activity.Text))
            {
                return(NotFound());
            }

            string reply = "";

            if (activity.Type == ActivityTypes.Message)
            {
                // calculate something for us to return
                int length     = (activity.Text ?? string.Empty).Length;
                var keyPhrases = TextAnalytics.GetKeyPhrases(activity.Text, activity.Id);

                //MessageDB.MessagesList.Add(message);
                var keys = _keyWords_manager.FindKeyWords(activity.Text, _question_manager.CurrentTopic);
                if (keys.Count == 0)
                {
                    var topic = _keyWords_manager.RecognizeTopic(activity.Text);
                    if (topic != Topic.None)
                    {
                        reply = _question_manager.GetQuestion(topic);
                    }
                }
                _question_manager.AllowToNextQuestion = keys.Count > 0;
                if (String.IsNullOrEmpty(reply))
                {
                    if (_question_manager.CurrentTopic == Topic.Experience)
                    {
                        if (_question_manager.CurrentTopic == Topic.Experience)
                        {
                            string txt = "";
                            foreach (var key in keyPhrases.Result.documents)
                            {
                                txt += key + ", ";
                            }
                            txt += " seems cool!";
                        }
                    }
                    reply = _question_manager.GetQuestion();
                }

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