Created
March 11, 2018 01:40
-
-
Save pictos/6d947682143829628825bd1e162d9e06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
type: "object", | |
required: [ | |
"Sandwich", | |
"Length", | |
"Ingredients", | |
"DeliveryAddress" | |
], | |
Templates: { | |
NotUnderstood: { | |
Patterns: [ | |
"I do not understand "{0}".", | |
"Try again, I don't get "{0}"." | |
] | |
}, | |
EnumSelectOne: { | |
Patterns: [ | |
"What kind of {&} would you like on your sandwich? {||}" | |
], | |
ChoiceStyle: "Auto" | |
} | |
}, | |
properties: { | |
Sandwich: { | |
Prompt: { | |
Patterns: [ | |
"What kind of {&} would you like? {||}" | |
] | |
}, | |
Before: [ | |
{ | |
Message: [ | |
"Welcome to the sandwich order bot!" | |
] | |
} | |
], | |
Describe: { | |
Image: "https://placeholdit.imgix.net/~text?txtsize=16&txt=Sandwich&w=125&h=40&txttrack=0&txtclr=000&txtfont=bold" | |
}, | |
type: [ | |
"string", | |
"null" | |
], | |
enum: [ | |
"BLT", | |
"BlackForestHam", | |
"BuffaloChicken", | |
"ChickenAndBaconRanchMelt", | |
"ColdCutCombo", | |
"MeatballMarinara", | |
"OvenRoastedChicken", | |
"RoastBeef", | |
"RotisserieStyleChicken", | |
"SpicyItalian", | |
"SteakAndCheese", | |
"SweetOnionTeriyaki", | |
"Tuna", | |
"TurkeyBreast", | |
"Veggie" | |
], | |
Values: { | |
RotisserieStyleChicken: { | |
Terms: [ | |
"rotis\w* style chicken" | |
], | |
MaxPhrase: 3 | |
} | |
} | |
}, | |
Length: { | |
Prompt: { | |
Patterns: [ | |
"What size of sandwich do you want? {||}" | |
] | |
}, | |
type: [ | |
"string", | |
"null" | |
], | |
enum: [ | |
"SixInch", | |
"FootLong" | |
] | |
}, | |
Ingredients: { | |
type: "object", | |
required: [ | |
"Bread" | |
], | |
properties: { | |
Bread: { | |
type: [ | |
"string", | |
"null" | |
], | |
Describe: { | |
Title: "Sandwich Bot", | |
SubTitle: "Bread Picker" | |
}, | |
enum: [ | |
"NineGrainWheat", | |
"NineGrainHoneyOat", | |
"Italian", | |
"ItalianHerbsAndCheese", | |
"Flatbread" | |
] | |
}, | |
Cheese: { | |
type: [ | |
"string", | |
"null" | |
], | |
enum: [ | |
"American", | |
"MontereyCheddar", | |
"Pepperjack" | |
] | |
}, | |
Toppings: { | |
type: "array", | |
items: { | |
type: "integer", | |
enum: [ | |
"Everything", | |
"Avocado", | |
"BananaPeppers", | |
"Cucumbers", | |
"GreenBellPeppers", | |
"Jalapenos", | |
"Lettuce", | |
"Olives", | |
"Pickles", | |
"RedOnion", | |
"Spinach", | |
"Tomatoes" | |
], | |
Values: { | |
Everything: { | |
Terms: [ | |
"except", | |
"but", | |
"not", | |
"no", | |
"all", | |
"everything" | |
] | |
} | |
} | |
}, | |
Validate: "var values = ((List<object>) value).OfType<string>(); var result = new ValidateResult {IsValid = true, Value = values} ; if (values != null && values.Contains("Everything")) { result.Value = (from topping in new string[] { "Avocado", "BananaPeppers", "Cucumbers", "GreenBellPeppers", "Jalapenos", "Lettuce", "Olives", "Pickles", "RedOnion", "Spinach", "Tomatoes"} where !values.Contains(topping) select topping).ToList();} return result;", | |
After: [ | |
{ | |
Message: [ | |
"For sandwich toppings you have selected {Ingredients.Toppings}." | |
] | |
} | |
] | |
}, | |
Sauces: { | |
type: [ | |
"array", | |
"null" | |
], | |
items: { | |
type: "string", | |
enum: [ | |
"ChipotleSouthwest", | |
"HoneyMustard", | |
"LightMayonnaise", | |
"RegularMayonnaise", | |
"Mustard", | |
"Oil", | |
"Pepper", | |
"Ranch", | |
"SweetOnion", | |
"Vinegar" | |
] | |
} | |
} | |
} | |
}, | |
Specials: { | |
Templates: { | |
NoPreference: { | |
Patterns: [ | |
"None" | |
] | |
} | |
}, | |
type: [ | |
"string", | |
"null" | |
], | |
Active: "return (string) state["Length"] == "FootLong";", | |
Define: "field.SetType(null).AddDescription("cookie", DynamicSandwich.FreeCookie).AddTerms("cookie", Language.GenerateTerms(DynamicSandwich.FreeCookie, 2)).AddDescription("drink", DynamicSandwich.FreeDrink).AddTerms("drink", Language.GenerateTerms(DynamicSandwich.FreeDrink, 2)); return true;", | |
After: [ | |
{ | |
Confirm: "var cost = 0.0; switch ((string) state["Length"]) { case "SixInch": cost = 5.0; break; case "FootLong": cost=6.50; break;} return new PromptAttribute($"Total for your sandwich is {cost:C2} is that ok?");" | |
} | |
] | |
}, | |
DeliveryAddress: { | |
type: [ | |
"string", | |
"null" | |
], | |
Validate: "var result = new ValidateResult{ IsValid = true, Value = value}; var address = (value as string).Trim(); if (address.Length > 0 && (address[0] < '0' || address[0] > '9')) {result.Feedback = DynamicSandwich.BadAddress; result.IsValid = false; } return result;" | |
}, | |
PhoneNumber: { | |
type: [ | |
"string", | |
"null" | |
], | |
pattern: "(\(\d{3}\))?\s*\d{3}(-|\s*)\d{4}" | |
}, | |
DeliveryTime: { | |
Templates: { | |
StatusFormat: { | |
Patterns: [ | |
"{&}: {:t}" | |
], | |
FieldCase: "None" | |
} | |
}, | |
DateTime: true, | |
type: [ | |
"string", | |
"null" | |
], | |
After: [ | |
{ | |
Confirm: [ | |
"Do you want to order your {Length} {Sandwich} on {Ingredients.Bread} {&Ingredients.Bread} with {[{Ingredients.Cheese} {Ingredients.Toppings} {Ingredients.Sauces} to be sent to {DeliveryAddress} {?at {DeliveryTime}}?" | |
] | |
} | |
] | |
}, | |
Rating: { | |
Describe: "your experience today", | |
type: [ | |
"number", | |
"null" | |
], | |
minimum: 1, | |
maximum: 5, | |
After: [ | |
{ | |
Message: [ | |
"Thanks for ordering your sandwich!" | |
] | |
} | |
] | |
} | |
}, | |
OnCompletion: "await context.PostAsync("We are currently processing your sandwich. We will message you the status.");" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment