Пример #1
0
        public async Task <IActionResult> PostAsync(GoogleCloudDialogflowV2WebhookRequest value)
        {
            WebhookResponse returnValue = null;

            returnValue = await _obtainMarketSummary.GetIndicesValuesAsync();

            if (returnValue == null)
            {
                returnValue = new WebhookResponse
                {
                    FulfillmentText = Utilities.ErrorReturnMsg() + Utilities.EndOfCurrentRequest()
                };
            }
            else if (returnValue.FulfillmentMessages.Count == 0 &&
                     !returnValue.FulfillmentText.Contains(Utilities.EndOfCurrentRequest()))
            {
                returnValue.FulfillmentText = returnValue.FulfillmentText + "\n" + Utilities.EndOfCurrentRequest();
            }
            var responseString = returnValue.ToString();

            _log.LogTrace("Completed processing request");
            return(new ContentResult
            {
                Content = responseString,
                ContentType = "application/json",
                StatusCode = 200
            });
        }
Пример #2
0
        /// <summary>
        /// Processes the intent.
        /// </summary>
        /// <param name="intentName">
        /// Name of the intent.
        /// </param>
        /// <param name="parserResult">
        /// The parser result.
        /// </param>
        /// <param name="log">
        /// The log.
        /// </param>
        /// <returns></returns>
        private static async Task <WebhookResponse> ProcessIntent(string intentName, JObject parserResult, WebhookRequest webhookRequest, ILogger log)
        {
            WebhookResponse returnValue = new WebhookResponse
            {
                FulfillmentText = Utilities.ErrorReturnMsg()
            };

            switch (webhookRequest.QueryResult.Intent.DisplayName)
            {
            case "marketSummary":
                var msActor = new ObtainMarketSummary(webhookRequest, log);
                returnValue = await msActor.GetIndicesValuesAsync(parserResult);

                break;

            case "marketTrends":
                var mtActor = new ObtainTrenders(webhookRequest, log);
                returnValue = await mtActor.GetTrendingAsync(parserResult);

                break;

            case "newsFetch":
                var newsActor = new ObtainNews(webhookRequest, log);
                returnValue = await newsActor.GetExternalNews(parserResult);

                break;

            case "stockQuote":
                var stockQuoteActor = new ObtainStockQuotes(webhookRequest, log);
                returnValue = await stockQuoteActor.GetExternalQuotesAsync();

                break;

            default:
                break;
            }

            return(returnValue);
        }