private static async Task <Luis> GetEntityFromLUIS(string Query)
        {
            Query = Uri.EscapeDataString(Query);
            Luis Data = new Luis();

            using (HttpClient client = new HttpClient())
            {
                string RequestURI       = "https://api.projectoxford.ai/luis/v2.0/apps/abb9c320-d690-4062-acff-f6835344be3f?subscription-key=ea3d5065b78345c9b0d85a9c45874702&q=" + Query + "&verbose=true";
                HttpResponseMessage msg = await client.GetAsync(RequestURI);

                if (msg.IsSuccessStatusCode)
                {
                    var JsonDataResponse = await msg.Content.ReadAsStringAsync();

                    Data = JsonConvert.DeserializeObject <Luis>(JsonDataResponse);
                }
            }
            return(Data);
        }
        public virtual async Task <HttpResponseMessage> Post([FromBody] Activity activity)
        {
            if (activity != null)
            {
                // one of these will have an interface and process it
                if (activity.GetActivityType() == ActivityTypes.Message)
                {
                    if (activity.Text == "login" | activity.Text == "hi" | activity.Text == "logout")
                    {
                        await Conversation.SendAsync(activity, () => SimpleFacebookAuthDialog.dialog);
                    }
                    else if (activity.Text == "help")
                    {
                        ConnectorClient connector           = new ConnectorClient(new Uri(activity.ServiceUrl));
                        Activity        replyToConversation = activity.CreateReply();
                        replyToConversation.Recipient   = activity.From;
                        replyToConversation.Type        = "message";
                        replyToConversation.Attachments = new List <Attachment>();
                        List <CardImage> cardImages = new List <CardImage>();
                        cardImages.Add(new CardImage(url: "https://contosobankbot.azurewebsites.net/logo.png"));
                        List <CardAction> cardButtons = new List <CardAction>();
                        CardAction        plButton    = new CardAction()
                        {
                            Value = "stock price of msft?",
                            Type  = "imBack",
                            Title = "Microsoft Stock Price"
                        };
                        cardButtons.Add(plButton);
                        CardAction plButtona = new CardAction()
                        {
                            Value = "all my balances",
                            Type  = "imBack",
                            Title = "Show me my account balances"
                        };
                        cardButtons.Add(plButtona);
                        CardAction plButtonb = new CardAction()
                        {
                            Value = "recent transactions on current",
                            Type  = "imBack",
                            Title = "Recent transactions on current"
                        };
                        cardButtons.Add(plButtonb);
                        HeroCard plCard = new HeroCard()
                        {
                            Title    = "Welcome to Contoso Bank Bot",
                            Subtitle = "How can I help you?",
                            Images   = cardImages,
                            Buttons  = cardButtons
                        };
                        Attachment plAttachment = plCard.ToAttachment();
                        replyToConversation.Attachments.Add(plAttachment);
                        var reply = await connector.Conversations.SendToConversationAsync(replyToConversation);
                    }
                    else
                    {
                        ConnectorClient connector   = new ConnectorClient(new Uri(activity.ServiceUrl));
                        string          userMessage = activity.Text;
                        string          message     = "Sorry, I am not getting you...";

                        try
                        {
                            var audioAttachment = activity.Attachments?.FirstOrDefault(a => a.ContentType.Equals("audio/wav") || a.ContentType.Equals("application/octet-stream"));
                            if (audioAttachment != null)
                            {
                                var stream = await GetImageStream(connector, audioAttachment);

                                var text = await this.speechService.GetTextFromAudioAsync(stream);

                                userMessage = text;
                            }
                        }
                        catch
                        {
                        }

                        Luis StLUIS = await GetEntityFromLUIS(userMessage);

                        if (StLUIS.intents.Count() > 0)
                        {
                            switch (StLUIS.intents[0].intent)
                            {
                            case "StockPrice":
                                message = await GetStock(StLUIS.entities[0].entity);

                                break;

                            case "SendMoney":
                                message = SendMoney(StLUIS.entities);
                                break;

                            case "GetRecent":
                                message = GetRecent(StLUIS.entities);
                                break;

                            case "CheckBalance":
                                message = GetBalance(StLUIS.entities);
                                break;

                            default:
                                message = "Sorry, I am not getting you...";
                                break;
                            }
                        }
                        Activity infoReply = activity.CreateReply(message);
                        await connector.Conversations.ReplyToActivityAsync(infoReply);
                    }
                }
            }
            return(new HttpResponseMessage(System.Net.HttpStatusCode.Accepted));
        }