/// <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); }
private async Task <WebhookResponse> ProcessIntent(GoogleCloudDialogflowV2WebhookRequest intent) { string intendDisplayName = intent.QueryResult.Intent.DisplayName; WebhookResponse returnValue = null; switch (intendDisplayName) { case "marketTrends": returnValue = await _obtainTrends.GetTrendingAsync(intent); break; case "newsFetch": break; case "stockQuote": break; case "fundamentals": break; default: break; } 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(); } return(returnValue); }