Beispiel #1
0
 /* Eg: give me customeraddress for xyz*/
 public static void AddressResponse(ConversationContext cContext, TokenRequest p1, TokenCustomer p2, TokenQueryAddress p3, TokenFor p4, TokenQuotedPhrase p5)
 {
     cContext.Say(CreateResponse(p5.Value.ToString()), null);
 }
Beispiel #2
0
 /* Eg: give me address for customer */
 public static void AddressResponse(ConversationContext cContext, TokenRequest p1, TokenQueryAddress p2, TokenFor p3, TokenCustomer p4)
 {
     // Ask for which customer
     cContext.AskQuestion(CreateResponse(null));
 }
        public override IEnumerable<TokenResult> Parse(string input, string UserId)
        {
            var tokenResults = new List<TokenResult>();
            string remainder = string.Empty;

            var results = base.Parse(input, UserId);

            if (results.Any())
            {
                tokenResults.Add(results.OrderByDescending(qty => qty.Length).First());

                int startPos = tokenResults.First().Start + tokenResults.First().Length + 1;

                if (startPos < input.Length)
                {
                    remainder = input.Substring(startPos);

                    if (remainder.Length > 0)
                    {
                        results = new TokenFor().Parse(remainder, UserId);
                        if (results.Any())
                        {
                            var tokenFor = results.OrderByDescending(token => token.Start).First();

                            tokenFor.Start += startPos;
                            startPos = tokenFor.Start + tokenFor.Length + 1;

                            tokenResults.Add(tokenFor);

                            remainder = (remainder.Length <= tokenFor.Length) ? string.Empty : remainder.Substring(tokenFor.Length + 1);

                            if (remainder.Length > 0)
                            {
                                results = new TokenCustomer().Parse(remainder, UserId);
                                if (results.Any())
                                {
                                    var tokenCust = results.OrderByDescending(token => token.Start).First();

                                    tokenCust.Start += startPos;
                                    startPos = tokenCust.Start + tokenCust.Length + 1;

                                    tokenResults.Add(tokenCust);

                                    remainder = (remainder.Length <= tokenCust.Length) ? string.Empty : remainder.Substring(tokenCust.Length + 1);
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(remainder))
                        {
                            tokenResults.Add(new TokenResult
                            {
                                Length = remainder.Length,
                                Start = startPos,
                                Token = new TokenQuotedPhrase { Value = remainder },
                                TokenType = typeof(TokenQuotedPhrase).ToString(),
                                Value = remainder
                            });
                        }
                    }
                }
            }

            return tokenResults;
        }
Beispiel #4
0
 /* Eg: give me customer phone number */
 public static void PhoneNoResponse(ConversationContext cContext, TokenRequest p1, TokenCustomer p2, TokenQueryPhoneNo p3)
 {
     // Ask for which customer
     cContext.AskQuestion(CreateResponse(null));
 }
Beispiel #5
0
 /* Eg: customer phone number for xyz*/
 public static void PhoneNoResponse(ConversationContext cContext, TokenCustomer p1, TokenQueryPhoneNo p2, TokenFor p3, TokenQuotedPhrase p4)
 {
     cContext.Say(CreateResponse(p4.Value.ToString()), null);
 }
Beispiel #6
0
 /* Eg: customer balance for */
 public static void BalanceResponse(ConversationContext cContext, TokenCustomer p1, TokenQueryBalance p2, TokenFor p3)
 {
     // Ask for which customer
     cContext.AskQuestion(CreateResponse(null));
 }
Beispiel #7
0
 /* Eg: How much does customer xyz owe us */
 public static void BalanceResponse(ConversationContext cContext, TokenDoes p1, TokenCustomer p2, TokenQuotedPhrase p3, TokenOwe p4)
 {
     cContext.Say(CreateResponse(p3.Value.ToString()), null);
 }