static InterestConfirmation OutboundLeadType_NewInterestConfirmation(Lead lead, UtcDateTime now) { var greeting = "Dear Client"; if (lead.FirstName.IsSome) { greeting = "Hi " + lead.FirstName.Val; } else if (lead.IdNumber.IsSome) { greeting = "Dear " + (lead.IsMale ? "Sir" : "Madam"); } var interestedPrompt = new YesNoPrompt("ProceedPrompt", "InterestConfirmed", greeting + ". 300MB FREE when you apply now. Great Smartphone and contract deals. FREE SMS. No calls. No documents. NO=Optout. Reply YES to apply. T&Cs"); var onOptOutMessage = new SendMessage("OnOptOutMessage" , "Noted. We will make sure not to send you any future Smartphone deals. To get Smartphone deals again, SMS APPLY to 39360" , isAccepted_: false ); var confirmation = new InterestConfirmation(lead.MobileNo, now, new List <Step> { new Step("AskIfInterestedStep", new List <IAction_> { interestedPrompt }, onOptOutMessage) }); return(confirmation); }
public void DisableTextUI() { if (InteractivityCue) { InteractivityCue.SetActive(false); } if (YesNoPrompt) { YesNoPrompt.SetActive(false); } if (textBox) { textBox.SetActive(false); } Destroy(textBalloon); /* * if(NPCGameObject) * NPCGameObject.GetComponent<ActivateTextAtLine>().ResetText(); //Alex : Not sure it's the best way to reset the text. * //It's not. */ EventManager.TriggerEvent("StartMoving"); //Alex: I added this line here 'cause I don't know what is "movementManager"; if (namePlate != null) { namePlate.SetActive(false); } if (movementManager != null) { EventManager.TriggerEvent("StartMoving"); } EventManager.TriggerEvent("resetNpcs"); }
protected override IEnumerable <string> execute(BeamGenerator generator) { var definedConcepts = new HashSet <Concept2>(generator.GetDefinedConcepts()); var conceptWithAssignedProperty = Get <PropertySetEvent>((s) => hasExtraInformation(s, definedConcepts, generator)); if (conceptWithAssignedProperty == null) { yield break; } var target = conceptWithAssignedProperty.Target; var rememberValue = RememberPropertyValue.Create(generator, target, conceptWithAssignedProperty.SubstitutedValue); YesNoPrompt.Generate(generator, rememberValue, new ConceptInstance(Concept2.Nothing)); yield return($"You think that {singular(target.Instance)} has {singular(conceptWithAssignedProperty.SubstitutedValue)} {singular(target.Property)}?"); }
protected override IEnumerable <string> execute(BeamGenerator generator) { var unknownPhrases = GetUnknownPhrases(generator); if (!PreviousPolicy <RequestRefinement>(out var refinementPolicy) || unknownPhrases.Count() != 1) { yield break; } var instanceToRefine = generator.GetValue(refinementPolicy.Tag, Concept2.Target); var unknown = unknownPhrases.First(); var assignUnknownProperty = AssignUnknownProperty.Create(instanceToRefine, unknown, generator); YesNoPrompt.Generate(generator, assignUnknownProperty, instanceToRefine); yield return($"I suppose, you would like to find {plural(instanceToRefine)} which are {unknown}?"); }
protected override IEnumerable <string> execute(BeamGenerator generator) { var evt = Get <InstanceOutputEvent>(); if (evt?.Instance.Concept != Concept2.NeedsRefinement) { yield break; } var instanceToRefine = generator.GetValue(evt.Instance, Concept2.Subject); var activationTarget = generator.GetValue(evt.Instance, Concept2.Target); var prefixesForRefine = generator.GetPrefixingUnknowns(instanceToRefine); if (!prefixesForRefine.TryGetValue(instanceToRefine, out var propertyUnknownRaw)) { //nothing to ask for yield break; } var propertyUnknown = toMeaningfulPhrase(propertyUnknownRaw); if (propertyUnknown == "") { yield break; } /* * //TODO feature based questions * * //ACTION SEQUENCE * //Do you want X which is UNKNOWN ? * Prompt * //-yes: what property UNKNOWN is ? * yes -> expect (properties) * //-- expect property * * //-no: So which X you want ? * no -> ? * //--standard refinement * * * yield return $"I know many {plural(instanceToRefine)} which one would you like?";*/ var assignUnknownProperty = AssignUnknownProperty.Create(instanceToRefine, propertyUnknown, generator); YesNoPrompt.Generate(generator, assignUnknownProperty, instanceToRefine); yield return($"So, you would like to find {plural(instanceToRefine)} which are {propertyUnknown}?"); }
public static async Task <bool> PromptYesNo(this Context ctx, string msgString, string acceptButton, User user = null, bool matchFlag = true) { if (matchFlag && ctx.MatchFlag("y", "yes")) { return(true); } var prompt = new YesNoPrompt(ctx) { Message = msgString, AcceptLabel = acceptButton, User = user?.Id ?? ctx.Author.Id, }; await prompt.Run(); return(prompt.Result == true); }
protected override IEnumerable <string> execute(BeamGenerator generator) { var evt = Get <InstanceOutputEvent>(i => i.Instance.Concept == Concept2.LearnNewConcept); if (evt == null) { yield break; } var collection = evt.Instance; var answer = generator.GetValue(collection, Concept2.Answer); var unknown = generator.GetValue(collection, Concept2.Unknown); var rememberDescription = RememberConceptDescription.Create(generator, answer.Concept, unknown.Concept.Name); YesNoPrompt.Generate(generator, rememberDescription, new ConceptInstance(Concept2.Nothing)); yield return($"So you think {singular(unknown)} is {singular(answer)} ?"); }
protected override IEnumerable <string> execute(BeamGenerator generator) { var unknownPhrases = GetUnknownPhrases(generator).ToArray(); var substitutionRequest = Get <IncompleteRelationEvent>(p => !p.IsFilled, searchInsideTurnOnly: false); if (PreviousPolicy <LearnNewPhrase>(out _) || unknownPhrases.Count() != 1 || substitutionRequest == null || substitutionRequest.Subject == null) { yield break; } var unknownPhrase = unknownPhrases.FirstOrDefault(); var unknownPropertyCandidate = new ConceptInstance(Concept2.From(unknownPhrase)); var newPropertyAssignment = Find <PropertySetEvent>(p => p.Target.Property == Concept2.HasProperty && p.SubstitutedValue?.Concept == substitutionRequest.Property, precedingTurns: 1); if (newPropertyAssignment != null) { //in the previous turn, new property was registered - this might be its value var remember = RememberPropertyValue.Create(generator, new PropertySetTarget(substitutionRequest.Subject, substitutionRequest.Property), unknownPropertyCandidate); YesNoPrompt.Generate(generator, remember, new ConceptInstance(Concept2.Nothing)); yield return($"So, you think {singular(substitutionRequest.Subject)} {singular(substitutionRequest.Property)} {unknownPhrase} ?"); yield break; } /*// Unknown value when substitution is required was observed * // TODO detect whether request is for parameter (then nothing to do here) * // or try to learn new property value * * var assignUnknownProperty = new ConceptInstance(Concept2.AssignUnknownProperty); * generator.SetValue(assignUnknownProperty, Concept2.Subject, unknownPropertyCandidate); * * //TODO incorporate target property * generator.SetValue(assignUnknownProperty, Concept2.Target, substitutionRequest.Subject); * generator.Push(new InstanceActivationRequestEvent(assignUnknownProperty)); * * yield return $"What does {unknownPhrase} mean?";*/ }
protected override IEnumerable <string> execute(BeamGenerator generator) { var fullRelation = Get <PropertySetEvent>(p => IsDefined(p.SubstitutedValue.Concept) && IsDefined(p.Target.Instance?.Concept)); if (fullRelation == null) { yield break; } var targetInstance = fullRelation.Target.Instance; if (targetInstance == null) { yield break; } var children = generator.GetInverseConceptValues(Concept2.InstanceOf, targetInstance); if (children.Any()) { //TODO add learning for classes yield break; } var parameters = generator.GetParameterDefinitions(targetInstance); if (parameters.Any(p => p.Property == fullRelation.Target.Property)) { //don't learn argument values yield break; } generator.Push(new StaticScoreEvent(0.1)); var remember = RememberPropertyValue.Create(generator, fullRelation.Target, fullRelation.SubstitutedValue); YesNoPrompt.Generate(generator, remember, new ConceptInstance(Concept2.Nothing)); yield return($"So you think, {singularWithProperty(fullRelation.Target.Instance)} ?"); }
static InterestConfirmation UpgradeLeadType_NewInterestConfirmation(Lead lead, UtcDateTime now) { var greeting = "Dear Client"; if (lead.FirstName.IsSome) { greeting = "Hi " + lead.FirstName.Val; } else if (lead.IdNumber.IsSome) { greeting = "Dear " + (lead.IsMale ? "Sir" : "Madam"); } var interestedPrompt = new YesNoPrompt("ProceedPrompt", "InterestConfirmed", greeting + ". SmartMobile would like to let you know that you can UPGRADE your contract today with this free SMS service. Reply YES to upgrade now and select your new Smartphone. T&Cs"); var confirmation = new InterestConfirmation(lead.MobileNo, now, new List <Step> { new Step("AskIfInterestedStep", new List <IAction_> { interestedPrompt }) }); return(confirmation); }
/* * private void LoadScripts() * { * foreach(string file in Directory.EnumerateFiles(ScriptDirectory, ScriptFileExtension)) * { * try * { * var scriptOptions = ScriptOptions.Default.AddReferences(Assembly.GetExecutingAssembly()); * #if DEBUG * scriptOptions = scriptOptions.WithEmitDebugInformation(true) * .WithFilePath(new FileInfo(file).FullName) * .WithFileEncoding(Encoding.UTF8); #endif * * string script = File.ReadAllText(file); * CSharpScript.RunAsync(script, scriptOptions).Wait(); * } * catch(Exception e) * { * Output.WriteLine($"Error compiling script: {file} Error: {e.Message}"); * } * } * } */ public void ConfirmAction(string prompt, YesNoPrompt yes, YesNoPrompt no) { Output.WriteLine(prompt); IsWaitingForYesNo = true; YesPrompt = yes; NoPrompt = no; /* * Output.Write(prompt); * * while (true) * { * string response = Console.ReadLine().Trim().ToUpper(); * if (response == "YES" || response == "Y") * return true; * else if (response == "NO" || response == "N") * return false; * else * Output.Write("Please answer yes or no.> "); * } */ }
protected override IEnumerable <string> execute(BeamGenerator generator) { var askedForLearning = PreviousPolicy <LearnNewPhrase>(out var policyTag) || PreviousPolicy <UnknownAnsweredToLearnNewPhrase>(out policyTag); if (!askedForLearning) { yield break; } var instances = FindTurnInstances().ToArray(); if (!instances.Any()) { yield break; } var unknown = generator.GetValue(policyTag.Tag, Concept2.Unknown); var hypothesis = instances.Last(); generator.Push(new StaticScoreEvent(0.1)); YesNoPrompt.Generate(generator, RememberConceptDescription.Create(generator, hypothesis.Concept, unknown.Concept.Name), new ConceptInstance(Concept2.Nothing)); yield return($"So, you think that {singular(unknown)} means {singular(hypothesis)} ?"); }
static Application OutboundLeadType_NewApplicationWorkflow(Lead lead, UtcDateTime now) { var onOptOutMessage = new SendMessage("OnOptOutMessage" , "Noted. We will make sure not to send you any future Smartphone deals. To get Smartphone deals again, SMS APPLY to 39360" , isAccepted_: false ); var a1 = new LoadRecommendedProductsAction(); var a2 = new RecommendProductAction(); var a3 = new IdNoVerifyAndSurnamePrompt("IdVerifyAndSurnamePrompt", "We won't take too much of your time. Please reply with your surname and the first 6 digits of your ID number. Example: Williams 740412"); var a4 = new BankDetailsPrompt("BankDetailsPrompt", "To apply, reply with your bank name, account no and type. Example: Capitec 100112 Savings. Your info is SECURED"); var a5 = new VerifyBankAccountAction(); var onRejectAccountVerification = new SendMessage("OnRejectAccountVerification" , "Something went wrong while confirming your bank account details. Please ensure your account details are correct." , isAccepted_: false ); var a6 = new FreeTextPrompt("CompanyNamePrompt", "EmployerName", "For FAST & FREE delivery to your work address reply with your Employer's Name. Example: iSmart"); var a7 = new FreeTextPrompt("CompanyAddressPrompt", "EmployerAddress", "Almost done! Reply with your Employer's Street Address. Example: 15 Vilakazi str, Soweto, Gauteng, 1803"); var a8 = new YesNoPrompt("AcceptT&CsPrompt", "AcceptT&Cs", $"View your T&Cs here: https://swoosh-mobile-prod.azurewebsites.net/tAndCs/{lead.Id}. Reply YES to agree and complete your application"); var a9 = new SendMessage("CongratsMessage" , "Your brand new Smartphone is on its way. The couriers will contact you to arrange for FREE delivery to your work address. Enjoy your day" , isAccepted_: true ); var application = new Application(lead.MobileNo, now, new List <Step> { new Step("LoadRecommendedProductsStep", new List <IAction_> { a1 }), new Step("ChooseProductStep", new List <IAction_> { a2 }), new Step("VerifyIdNoAndSurnameStep", new List <IAction_> { a3 }), new Step("AskBankDetailsStep", new List <IAction_> { a4 }), new Step("VerifyBankDetailsStep", new List <IAction_> { a5 }, onRejectAccountVerification, "AskBankDetailsStep", 2), new Step("AskCompanyNameStep", new List <IAction_> { a6 }), new Step("AskCompanyAddressStep", new List <IAction_> { a7 }), new Step("AcceptT&CsStep", new List <IAction_> { a8 }, onOptOutMessage), new Step("CongratsStep", new List <IAction_> { a9 }) }); return(application); }
static Application InboundLeadType_NewApplicationWorkflow(Lead lead, UtcDateTime now) { var onOptOutMessage = new SendMessage("OnOptOutMessage" , "Noted. We will make sure not to send you any future Smartphone deals. To get Smartphone deals again, SMS APPLY to 39360" , isAccepted_: false ); var a2 = new IdNoSurnamePrompt("IdSurnamePrompt", "We want to give you the best deal. We need to see which deals you qualify for. Reply with your Surname and ID number. All info is SECURED. Example: Williams 7404125001087"); var a3 = new ScoringAction(minAcceptableScore: 0); var onRejectScore = new SendMessage("OnRejectScoreMessage" , "Unfortunately, you have not qualified for a Smartphone. If your circumstances change, please reply with APPLY to 39360" , isAccepted_: false ); var a4 = new LoadRecommendedProductsAction(); var a5 = new RecommendProductAction(); var a6 = new BankDetailsPrompt("BankDetailsPrompt", "To apply, reply with your bank name, account no and type. Example: Capitec 100112 Savings. Your info is SECURED"); var a7 = new VerifyBankAccountAction(); var onRejectAccountVerification = new SendMessage("OnRejectAccountVerification" , "Something went wrong while confirming your bank account details. Please ensure your account details are correct." , isAccepted_: false ); var a8 = new FreeTextPrompt("CompanyNamePrompt", "EmployerName", "Thanks. Your banking details are verified, and application approved. For FREE delivery to your work address reply with your Employer's Name. Example: iSmart"); var a9 = new FreeTextPrompt("CompanyAddressPrompt", "EmployerAddress", "Almost done! Reply with your Employer's Street Address. Example: 15 Vilakazi str, Soweto, Gauteng, 1803"); var a10 = new YesNoPrompt("AcceptT&CsPrompt", "AcceptT&Cs", $"View your T&Cs here: https://swoosh-mobile-prod.azurewebsites.net/tAndCs/{lead.Id}. Reply YES to agree and complete your application"); var a11 = new SendMessage("CongratsMessage" , "Your brand new Smartphone is on its way. The couriers will contact you to arrange for FREE delivery to your work address. Enjoy your day" , isAccepted_: true ); var application = new Application(lead.MobileNo, now, new List <Step> { new Step("AskIdNoAndSurnameStep", new List <IAction_> { a2 }), new Step("ScoreCustomerStep", new List <IAction_> { a3 }, onRejectScore), new Step("LoadRecommendedProductsStep", new List <IAction_> { a4 }, onRejectScore), new Step("ChooseProductStep", new List <IAction_> { a5 }), new Step("AskBankDetailsStep", new List <IAction_> { a6 }), new Step("VerifyBankDetailsStep", new List <IAction_> { a7 }, onRejectAccountVerification, "AskBankDetailsStep", 2), new Step("AskCompanyNameStep", new List <IAction_> { a8 }), new Step("AskCompanyAddressStep", new List <IAction_> { a9 }), new Step("AcceptT&CsStep", new List <IAction_> { a10 }, onOptOutMessage), new Step("CongratsStep", new List <IAction_> { a11 }) }); return(application); }
public static YesNoPrompt.Result ShowYesNoPrompt(string message, YesNoPrompt.Result?defaultValue = YesNoPrompt.Result.Yes) { var prompt = new YesNoPrompt(); return(prompt.Show(message, defaultValue)); }