예제 #1
0
파일: QueryService.cs 프로젝트: 7633/ApiAi
        /// <summary>
        /// Takes natural language text and information as query parameters.
        /// </summary>
        /// <param name="config">Agent connection configuration</param>
        /// <param name="message">Natural language text to be processed. Query length should not exceed 256 characters.</param>
        /// <returns></returns>
        public static QueryResponseModel SendRequest(ConfigModel config, string message)
        {
            var requestData = new QueryRequestJsonModel
            {
                Query     = message,
                SessionId = (config.SessionId ?? Guid.NewGuid()).ToString(),
                Lang      = config.Language.GetAlternativeString()
            };

            var result = Internal.RequestHelper.Send <QueryRequestJsonModel, QueryResponseJsonModel>
                             (requestData, Internal.Enums.ActionsEnum.Query, System.Net.Http.HttpMethod.Post, config);

            return(new QueryResponseModel(result));
        }
예제 #2
0
        public DialogflowResponseV1 ProcessRequestForQuery(QueryRequestJsonModel request, ILogWriter logWriter)
        {
            logWriter.LogMessage("Handle Request");

            var responseText =
                _processRules.First(r => r.IsRequestTextMatch(request.Result.Parameters.EntityText))
                .ProcessRequest(request, logWriter);

            var response = new DialogflowResponseV1
            {
                Speech      = responseText,
                DisplayText = responseText,
                Source      = "Webhook Service",
                Data        = new Data(),
                ContextOut  = new Context[0]
            };

            return(response);
        }
예제 #3
0
        public string ProcessRequest(QueryRequestJsonModel request, ILogWriter logWriter)
        {
            string responseText;

            switch (request.Result.Parameters.PeriodRange.ToLower().Trim())
            {
            case "last week":
                responseText = "There were 20 users logged in last week";
                break;

            case "month":
                responseText = "There were 50 users logged into web3 this month";
                break;

            default:
                responseText = "Sorry, I could only process for last week and this month";
                break;
            }
            return(responseText);
        }
예제 #4
0
 public string ProcessRequest(QueryRequestJsonModel request, ILogWriter logWriter)
 {
     return("Sorry, I could not process your request. Please try again.");
 }
예제 #5
0
 public string ProcessRequest(QueryRequestJsonModel request, ILogWriter logWriter)
 {
     return("200 clients are using web3 at the moment");
 }
예제 #6
0
 public string ProcessRequest(QueryRequestJsonModel request, ILogWriter logWriter)
 {
     return($"Hi welcome to {request.Result.Parameters.EntityText} world");
 }