Bubblescript
Academy
dialog main do
say "Welcome at Restaurant Sienna đź‘‹"
show image "restaurant.jpg"
say "We serve traditional Italian pizza's."
say "We are located at Joan Muyskenweg 22 in Amsterdam"
show location [4.91505839, 52.3326472]
ask "What would you like to order?"
say "We'll start preparing your #{answer}"
say "Goodbye"
stop
end
Say, ask & show
dialog main do
say "Welcome at Restaurant Sienna đź‘‹"
prompt "What can I do for you?"
end
dialog trigger: "about" do
say "We serve traditional Italian pizza's."
end
dialog trigger: "location | address" do
say "We are located at Joan Muyskenweg 22 in Amsterdam"
show location [4.91505839, 52.3326472]
end
dialog trigger: "order" do
ask "What would you like to order?"
say "We'll start preparing your #{answer}"
end
dialog trigger: "stop | close | bye" do
say "Goodbye"
stop
end
Dialogs
dialog __root__ do
prompt "What can I do for you?"
end
dialog __unknown__ do
say "I don't understand"
end
Special dialog triggers
dialog __root__ do
prompt ["What can I do for you today?", "What else can I do for you?"]
end
dialog __unknown__ do
random do
say "I don't understand"
say "I'm not sure what you mean"
say "Sorry, I don't get it"
end
end
Once...do & Random
dialog __unknown__ do
once do
say "I don't understand"
say "I still don't understand"
after
say "Sorry, I don't think this is working"
stop
end
end
https://doc.botsquad.com/bubblescript/statements/#once               https://doc.botsquad.com/bubblescript/statements/#random
dialog main do
say "Welcome at Restaurant Sienna đź‘‹"
invoke about
show image "restaurant.jpg"
end
dialog about, trigger: "about" do
say "We serve traditional Italian pizza's."
end
Invoke
about
__main__
__root__
main
dialog.stack
order
@about intent(match: ["about _ (restaurant | sienna)"])
@address intent(match: ["what _ (location | address", "where be _ ( you | restaurant)"])
@order intent(match: ["i _ order", "i _ buy"])
@close intent(match: ["bye | close | stop | goodbye | exit"])
dialog trigger: @about, do: invoke about
dialog trigger: @address, do: invoke address
dialog trigger: @order, do: invoke order
dialog trigger: @close, do: invoke close
dialog about do
say "We serve traditional Italian pizza's."
end
dialog address do
say "We are located at Joan Muyskenweg 22 in Amsterdam"
end
dialog order do
ask "What would you like to order?"
say "We'll start preparing your #{answer}"
end
Intents
dialog __root__ do
prompt ["What can I do for you today?", "What else can I do for you?"]
dialog label: "About️", do: invoke about
dialog label: "Location", do: invoke address
dialog label: "Order", do: invoke order
dialog label: "Nothing", do: invoke close
end
Inner dialog labels
dialog order do
say "Let's take your order…"
ask "What pizza would you like to order?",
quick_replies: ["Margherita", "Pepperoni", "Hawaii"]
say "We'll start preparing your #{answer}!"
end
Quick replies
dialog order do
say "Let's take your order…"
ask "What pizza would you like to order?",
expecting: ["Margherita", "Pepperoni", "Hawaii"]
say "We'll start preparing your #{answer}!"
end
Expecting
dialog order do
say "Let's take your order…"
ask "What pizza would you like to order?",
expecting: ["Margherita", "Pepperoni", "Hawaii"]
say "We'll start preparing your #{answer}!"
dialog trigger: "caprese", do: say "The Caprese Pizza is out of order"
dialog trigger: "pasta" , do: say "We don't serve pasta's, only pizza's"
dialog __unknown__ , do: say "Sorry, that is not on our menu…"
end
Inner dialog triggers
dialog order do
say "Let's take your order…"
ask "What pizza would you like to order?",
expecting: ["Margherita", "Pepperoni", "Hawaii"]
say "We'll start preparing your #{answer}!"
dialog trigger: "caprese", do: say "The Caprese Pizza is out of order"
dialog trigger: "pasta" , do: say "We don't serve pasta's, only pizza's"
dialog __unknown__ , do: say "Sorry, that is not on our menu…"
dialog __returning__ do
say "Let's continue with your order…"
end
end
__returning__
dialog order do
menu = ["Margherita", "Pepperoni", "Hawaii"]
say "We serve #{length(menu)} different pizza's:"
repeat item in menu do
say item
end
ask "What pizza would you like to order?", expecting: menu
say "We'll start preparing your #{answer}!"
dialog __unknown__, do: say "Sorry, we only serve #{join_and(menu)}…"
end
List
@base_url "https://storage.googleapis.com/botsquad-assets/workshop/"
@menu [
%{title: "Pizza Marherita", image_url: @base_url + "pizza_marg.jpg"},
%{title: "Pizza Pepperoni", image_url: @base_url + "pizza_pep.jpg" },
%{title: "Pizza Hawaii" , image_url: @base_url + "pizza_haw.jpg" }
]
@menu_titles pluck(@menu, "title")
dialog order do
say "We serve #{length(@menu)} different pizza's:"
ask "What pizza would you like to order?",
quick_replies: @menu,
expecting: @menu_titles
say "We'll start preparing your #{answer}!"
dialog __unknown__, do: say "Sorry, we only serve #{join_and(@menu_titles)}…"
end
Maps & global constants
@base_url "https://storage.googleapis.com/botsquad-assets/workshop/"
@menu [
%{value: "Margherita", title: "Pizza Margherita",
image_url: @base_url + "pizza_marg.jpg", subtitle: "$5.95"},
%{value: "Pepperoni" , title: "Pizza Pepperoni" ,
image_url: @base_url + "pizza_pep.jpg" , subtitle: "$6,95"},
%{value: "Hawaii" , title: "Pizza Hawaii" ,
image_url: @base_url + "pizza_haw.jpg" , subtitle: "$7.95"}
]
dialog order do
item_picker = input_method("item_picker",
caption: "Please select",
mode: "single",
items: @menu)
ask "What pizza would you like to order?",
expecting: item_picker
say "We'll start preparing your #{answer}!"
end
Web Widgets
List
Gallery / Card
Buttons
UI Components (web & messenger)
Text
Multi select
Form
Location picker
Numeric
Wait control
Closed control
Web Widgets (alternative keyboard)
if length(order) > 0 do
say "Ok, we'll prepare your #{join_and(order)}"
else
say "You didn't order anything"
end
branch do
order == nil -> say "You ordered nothing"
length(order) == 1 -> say "We'll prepare your product"
length(order) < 3 -> say "We'll prepare your products"
else
say "You ordered too many products"
end
branch length(order) do
0 -> say "You've ordered nothing"
1 -> say "We'll prepare your product"
2 -> say "We'll prepare your products"
else
say "You ordered too many products"
end
Conditionals
dialog order_line when length(order) >= 5 do
say "You reached the maximum order size…"
end
dialog order_line when length(order) == 0 do
ask "What pizza would you like to order?"
invoke order_line
end
dialog order_line do
ask "Do you want another pizza?"
invoke order_line
end
Guards
@datetime entity(match: "[time=pickup_time]")
dialog ask_pickup_time do
ask "When would you like to pick-up your order?", expecting: @datetime
pickup_time = date_format(answer.pickup_time.value, "{D} {Mfull} at {h24}:{0m}")
dialog __unknown__ do
say "That doesn't seem to be a valid date or time"
end
end
Entities
perform calculate_price
say "The total price is $ #{total}"
task calculate_price do
total = 0
repeat item in order do
pizza = first(@menu[title: item])
price = replace(pizza.subtitle, "$", "")
total = total + number(price)
end
end
Tasks
Sign up
Clone example bot
Script - files
Content files
dialog main do
repeat item in @menu do
say item.title
end
end
CMS
type: form
storage:
type: script
script_title: menu
title: Ordering menu
icon: shopping-cart
description: Configure your ordering menu
form:
schema:
type: array
title: Answers
items:
type: object
properties:
value: { type: string, title: Value }
title: { type: string, title: Title of the dish }
image_url: { type: string, title: Image URL }
subtitle: { type: string, subtitle: Price }
required: ["value", "title", "image_url", "subtitle"]
ui_schema:
classNames: "collapsible-array--field"
items:
ui:field: collapsible_array
ui:options:
caption_template: '<b>{{title}}</b> <span class=right>{{subtitle}}</span>'
ui:layout:
- title: { sm: 8 }
subtitle: { sm: 4 }
- image_url: { sm: 12 }
image_url:
ui:widget: image
value:
ui:field: auto_uuid
ui:order: ["title", "image_url", "subtitle"]
json schema
Intents
Intent training
intents:
-
id: "about"
label:
$i18n: true
en: "About"
match: []
provider_agent: ""
provider_id: ""
provider_name: "about"
provider_type: "qna"
utterances:
about:
negative:
$i18n: true
en:
- "i don't want to know about you"
- "tell me about your personnel"
positive:
$i18n: true
en:
- "about restaurant sienna"
- "what type of restaurant is this"
- "what is this for restaurant"
- "what kind of restaurant is this"
- "what kind of restaurant is sienna"
- "information about the restaurant"
- "what can you tell me about restaurant sienna"
- "tell me about the restaurant"
- "i want information about the restaurant"
intents yaml
dialog ask_email do
ask "What is your email address?", expecting: @email
user.email = answer.email.value
remember user.email
dialog __unknown__, do: say "That isn't a valid email address"
end
User Data
Tagging
dialog confirm do
perform calculate_price
say "The total price is $ #{total}"
say "We will prepare your order for #{pickup_time}"
perform send_order
tag "ordered"
end
task send_order do
summary = "
You ordered:\n - #{join(order, "\n - ")}\n
Total price: #{total}\n
Please pickup at #{pickup_time}"
mail user.email, "Order Confirmation", summary
end
Connect (as PWA)
PWA settings
manifest:
background_color: '#f0f0f0'
display: standalone
orientation: portrait
theme_color: '#990000'
splash_screen:
title: Restaurant Sienna
description: Order your pizza's
call_to_action: Start
footer: 'I have read the <a target="_blank" href="https://www.botsquad.com/terms">terms and conditions</a>'
appearance: app
PWA yaml
Old Bubblescript Basics workshop
By Niels Wildenberg
Old Bubblescript Basics workshop
- 91