Beispiel #1
0
        public virtual bool ParseIntent(CUIContext context, DateTime time, string input)
        {
            var intent = NLUEngine.GetIntent(input);

            if (Controller.DebugEnabled)
            {
                DebugIntent(intent);
            }
            if (!intent.IsNone && intent.Top.Label == "menu" && intent.Top.Score > 0.7)
            {
                Menu(intent);
            }
            if (intent.Top.Score < 0.8)
            {
                return(false);
            }
            else
            {
                if (Intents.ContainsKey(intent.Top.Label))
                {
                    DispatchIntent(intent, Intents[intent.Top.Label]);
                }
                else
                {
                    SayErrorLine("This package recognizes intent {0} but does not have handler for it.", intent.Top.Label);
                    DebugIntent(intent);
                }
                return(true);
            }
        }
Beispiel #2
0
        public override bool ParseIntent(CUIContext context, DateTime time, string input)
        {
            if (IsBotsContext)
            {
                if (BotCommands.Contains(input.ToLower()))
                {
                    var cmd = input.ToLower();
                    switch (cmd)
                    {
                    case "leave":
                        Controller.SetDefaultPrompt();
                        DispatchIntent(null, Menu);
                        break;

                    default:
                        SayErrorLine($"No handler for command {cmd}.");
                        break;
                    }
                    return(true);
                }
                else if (Int32.TryParse(input, out int result) && QuickReplies != null && (result - 1) < QuickReplies.Length)
                {
                    DispatchBotInput(QuickReplies[result - 1]);
                }
                else
                {
                    DispatchBotInput(input);
                }
                return(true);
            }
            else
            {
                return(base.ParseIntent(context, time, input));
            }
        }
Beispiel #3
0
 public bool CanDispatchVariableInput(CUIContext context)
 {
     if (context.Label.StartsWith("INPUT_"))
     {
         string label = context.Label.Replace("INPUT_", "");
         return(Variables.ContainsKey(label));
     }
     else
     {
         return(false);
     }
 }
Beispiel #4
0
        public virtual void DispatchVariableInput(CUIContext context, string input)
        {
            string variableName = context.Label.Replace("INPUT_", "");

            Variables[variableName] = input;
            if (Controller.DebugEnabled)
            {
                SayInfoLine("Variable {0} set to to {1}.", variableName, input);
                SayInfoLine("Dispatch variable input {0} to {1}.", input, context.IntentAction.Method.Name);
            }
            Controller.SetDefaultPrompt();
            context.IntentAction.Invoke(context.Intent);
        }
Beispiel #5
0
        public void DispatchToMenuItem(CUIContext context, DateTime time, int i)
        {
            string label = context.Label.Replace("MENU_", "");

            if (i < 1 || i > MenuIndexes[label])
            {
                SayInfoLine("Enter a number between {0} and {1}.", 1, MenuIndexes[label]);
            }
            else
            {
                MenuHandlers[label].Invoke(i);
            }
        }