/// <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)
            {
                if (activity.Text.Equals("reset", StringComparison.CurrentCultureIgnoreCase))
                {
                    MessagesController.SetInternalState(CookBotState.Intro);
                    messageIntro  = new MessageIntro();
                    messageWebApi = new MessageWebapi();
                }
                else
                {
                    switch (_state)
                    {
                    case CookBotState.Initial:
                        await MessageInitial.Post(activity);

                        break;

                    case CookBotState.Ingredients:
                        await MessageIngredientes.Post(activity);

                        break;

                    case CookBotState.Webapi:
                        await messageWebApi.Post(activity);

                        break;

                    case CookBotState.Intro:
                        await messageIntro.Post(activity);

                        break;
                    }
                }
            }
            else
            {
                HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            return(response);
        }
示例#2
0
        public async Task Post([FromBody] Activity activity)
        {
            using (var connector = new ConnectorClient(new System.Uri(activity.ServiceUrl)))
            {
                if (activity.Type == ActivityTypes.Message)
                {
                    if (status == 0)
                    {
                        status = 1;
                        var reply = activity.CreateReply($"Boa noite, Filho.");
                        await connector.Conversations.ReplyToActivityAsync(reply);
                    }
                    else if (status == 1)
                    {
                        var reply = activity.CreateReply($"Mamãe tá cansada demais. Hoje você vai cozinhar! Vai ver o que tem disponível no armário e geladeira.");
                        await connector.Conversations.ReplyToActivityAsync(reply);

                        MessagesController.SetInternalState(CookBotState.Webapi);
                    }
                }
            }
        }