Skip to content

Instantly share code, notes, and snippets.

@maxpert maxpert/samples.yaml
Last active Jan 9, 2017

Embed
What would you like to do?
LUL
# Everything starting with a # is a comment
################################## 1-1-simple-example.rive
on: Hello bot
say: Hello human
################################## 1-2-replies.rive
# By default all statements live under start, this can be explicitly specified
start:
on: hello bot
say:
- Hello human!
- Hello!
- Hi!
- Hi there!
################################## 1-3-weights.rive
on: hello bot
say:
- Hello human!
- weight: 5
text: Hello!
- Hi there!
- weight: 5
text: Hey!
- weight: 10
text: Hi!
################################## 2-1-wildcards.rive
# Notice the multiple when statements if switch cases
- on: My name is @name:words
say:
# in replies :: indicates substituion of value from parameters above
- It's nice to meet you, @name.
- @name, nice to meet you.
- Pleased to meet you, @name.
# Note I can ommit name of variable and refer it with 1 based index
- on: My name is @:number
say:
- Nobody has the name of @1.
- @1 isn't a real name.
- Names don't have numbers in them, @1
- on: my name is @name:any
say: Your name has a number in it?
- on: I am @age:number years old
say: A lot of people are @age years old.
- on: I am @age:words years old
say: Can you say that again using a number?
- on: I am @age:any years old
say: You told me numbers and letters? Tell me only numbers.
- on: I am from @country:any
say: What is it like to live in @country?
- on: @someone:words told me to say @say:any
- say: So did you say "@say" because "@someone" told you to?
################################## 2-2-alternations.rive
- on: what is your @loc=(home|office|cell) phone number
say: You can call my @loc number at 1 (888) 555-5555.
- on: I @=(can not|cannot) @:any
say:
- Have you tried?
- Why can't you @do?
- Do you really want to @do?
- on: who @who=(is your master|made you|created you|programmed you)
say: I was developed by a developer at Microsoft; you don't need to know his name!
- on: @=(what is your name|who are you|who is this)?
say: My name is doesn't matter, what matters is that I can run.
- on: @=(happy|merry) @event=(christmas|xmas|valentines day|thanksgiving)
say: Wow! Is it really @event already?
################################## 2-3-optionals.rive
# Notice optional variables are @?, @variable?
- on: what is your @location=(home|office|cell) @?=(phone) number
say: My @location number is: 1 (888) 555-5555.
- on: i do not have @?=(any) friends
say: Aw. I'll be your friend!
- on: am i @?=(a) @male=(boy|guy|male) or @?=(a) @female=(girl|female)
say: I can't tell with any degree of certainty whether you are a @male or @female.
################################## 2-4-google.rive
# Notice invoking method google_search from code behind
# Notice @> for invoking method directly using
- on: google @query:any
# Piping parameter to google_search it's equallent to google_search(query)
say: Google says: @query|>google_search
- on: search @query:any from @engine=(bing|google)
say: @engine|>uppercase_first says @>invoke_search(engine, query)
- on: @:any or something
say: >
There is nothing like
having really clean linebreaks
################################## redirect
start:
- on: Hey
redirect: hello
- on: Hi
redirect: hello
- on: @invoke:any
redirect: @invoke
hello:
say:
- Hi there!
- Hey!
- Howdy!
################################## conditionals
variables:
name: ~
age: ~
start:
# not_empty is builting function
- when:
age: not_empty
name: not_empty
on: Who am I
say: You are @name and you are @age year old
- on: Who am I
say: Seems like we don't know each other much, who don't you introduce yourself?
- on: my name is @my_name
say: It's nice to meet you @my_name
assign:
name: @my_name
- on: my age is @my_age
say: You are still too young!
assign:
age: @my_age|>parse_int
default:
say:
- You make no sense!
- I don't get it.
- Do you need some help?
################################### topics
start:
on: I hate you
say: You're really mean! I'm not talking again until you apologize.
topic: sorry
sorry:
- on: @:any sorry @:any
say: It's OK, I'll forgive you!
topic: start
- on: @:any
say:
- Nope, not until you apologize.
- Say you're sorry!
- weight: 10
text: Apologize!
################################### pizza order sample
variables:
menu_toppings: @>get_available_toppings()
credit_card: @>get_saved_credit_card()
last_pizza_quantity: @>get_last_ordered_quantity()
last_pizza_type: @>get_last_ordered_pizza()
last_pizza_toppings: @>get_last_ordered_toppings()
pizza_quantity: 0
pizza_type: ~
pizza_toppings: []
#-------------- Main menu
start:
- on: repeat @?=(my|the) @=(last|previous) order
say:
confirm:
message: Sure you want me to @last_pizza_type again?
yes: last_pizza_reordered #redirect to pizza_info_collected
no: start # redirect to start
- on: get me @amount?:number @=(pizza|pizzas)
say: I am glad you are hungry; what kind of pizza would you like?
topic: collect_pizza_info
#-------------- Collect pizza info
collect_pizza_info:
- on: order @quantity:number @type:any @=(pizza|pizzas)
say: >
Sure I can order @quantity @type @>pluralize('pizza', quantity) for you.
What toppings will you like to have?
set:
pizza_type: type
pizza_quantity: quantity
- on: @=(add|include|put on) topping @?=(of) @topping:any
set:
pizza_toppings: @>set_add(pizza_toppings, topping)
say:
- Ok so it's a @pizza_type with @pizza_toppings|>topping_list
- Gotcha your @>pluralize('pizza', pizza_quantity) will have @pizza_toppings|>topping_list
- Awesome I just added @topping to your @pizza_type
- on: @=(remove|exclude|don't put) topping @?=(of) @topping:any
set:
pizza_toppings: @>set_remove(pizza_toppings, topping)
say:
- Ok I removed @topping
- Betya! No @topping
- on: change @=(quantity|number) of pizzas to @new_quantity:number
say:
- Ok I order @new_quantity instead of @pizza_quantity
- Sure, it's @pizza_type @new_quantity @>pluralize('pizza', @new_quantity)
set:
pizza_quantity: new_quantity
- on: @=(cancel|go back|main menu|I changed my mind)
say: Sure!
topic: start
- on: @=(that's all|that is it|yep I am done|yum yum)
say: Awesome let's get some payment info :)
#-------------------- user reordered last pizza
last_pizza_reordered:
say:
- Ok I am ordering @last_pizza_quantity @last_pizza_type @last_pizza_toppings|>topping_list, Let's get payment info!
- Gotcha! Let's get paid :)
set:
pizza_type: last_pizza_type
pizza_quantity: last_pizza_quantity
pizza_toppings: last_pizza_toppings
topic: collect_payment_info
#-------------------- collect payment info from user
collect_payment_info:
- on: I would like to pay with my credit card
say:
payment:
accepted: visa|mastercard|amex
provider: my provider
amount: @>order_total(pizza_type, pizza_quantity, pizza_toppings)
receipt: @>order_receipt(pizza_type, pizza_quantity, pizza_toppings)
success: order_placed
failure: payment_failed
- on: I would like to pay from my paypal account
say:
paypal:
title: @>generate_order_title
amount: @>order_total(pizza_type, pizza_quantity, pizza_toppings)
receipt: @>order_receipt(pizza_type, pizza_quantity, pizza_toppings)
- on: (hold on|wait|cancel|I changed my mind)
say: Oh sure let me know whenever you want to pay I have your pizza order with me :)
topic: start
#------------ Yayyy!
order_placed:
say: Your pizza is on it's way now :). I will notify you once it's out for delivery.
topic: start
#-------------- Boooo!
payment_failed:
say: Seems like we are not able to process your payment, please call our support at 444-429-9993
topic: start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.