Skip to content

Latest commit

 

History

History
577 lines (394 loc) · 8.91 KB

b00.md

File metadata and controls

577 lines (394 loc) · 8.91 KB

Chatbots with RiveScript


  • hello.rive
! version = 2.0

+ hello bot
- Hello human!

  • comments.rive
! version = 2.0

// This is the simple trigger again
+ hello bot    // What the human says
- Hello human! // How the bot responds

/*
  multiple line comments
*/

  • replies.rive
! version = 2.0

+ hello bot
- Hello human!
- Hello!
- Hi there!
- Hey!
- Hi!

  • random-responses.rive
! version = 2.0

+ say something random
- This {random}message|sentence{/random} has a random word.

  • weight.rive
! version = 2.0

+ hello bot
- Hello human!
- Hello!{weight=5}
- Hi there!
- Hey!{weight=5}
- Hi!{weight=10}

  • continuation.rive
! version = 2.0

+ what are you
- I am an artificial intelligence programmed\n
^ using RiveScript.

/*
- I am an artificial intelligence programmed
^ using RiveScript.


- I am an artificial intelligence programmed\s
^ using RiveScript.

*/

  • substitutions.rive
! version = 2.0

// Substitutions
! sub i'm     = i am
! sub i'd     = i would
! sub i've    = i have
! sub i'll    = i will
! sub don't   = do not
! sub isn't   = is not
! sub you'd   = you would
! sub you're  = you are
! sub you've  = you have
! sub you'll  = you will
! sub what's  = what is
! sub whats   = what is
! sub what're = what are
! sub what've = what have
! sub what'll = what will
! sub who's   = who is


+ what is up
- Not much, you?
- nm, you?
- Not a lot, you?

+ you are a bot
- How did you know I'm a machine?

  • wildcards.rive
! version = 2.0

+ my name is *
- Nice to meet you, <star>!
- Good to see you, <star1>!

+ * told me to say *
- Why would <star1> tell you to say "<star2>"?
- Did you say "<star2>" after <star1> told you to?

+ i am * years old
- A lot of people are <star1> years old.

+ where is *
- Where it belongs.
- Where you left it.
- Where the heart is.


// catch-all trigger
+ *
- I'm not sure how to reply to that.
- Try asking your question a different way.
- Let's change the subject.

// only numbers
+ i am # years old
- A lot of people are <star> years old.

// only letters (word without numbers)
+ i am _ years old
- Tell me that again but with a number this time.

// anything
+ i am * years old
- Can you use a number instead?

// This one has multiple wildcards in it
+ _ told me to say *
- So did you say "<star2>" because "<star1>" told you to?

  • alternatives.rive
! version = 2.0

+ what is your (home|office|cell) number
- You can reach me at: 1 (800) 555-1234.

+ i am (really|very|super) tired
- I'm sorry to hear that you are <star> tired.

+ i (like|love) the color *
- What a coincidence! I <star1> that color too!
- I also have a soft spot for the color <star2>!
- Really? I <star1> the color <star2> too!
- Oh I <star1> <star2> too!

+ i (will|will not) *
- It doesn't matter to me whether you <star2> or not.

  • optionals.rive
! version = 2.0

+ how [are] you
- I'm great, you?

+ what is your (home|office|cell) [phone] number
- You can reach me at: 1 (800) 555-1234.

+ i have a [red|green|blue] car
- I bet you like your car a lot.

+ am i [a] (boy|guy|male) or [a] (girl|female)
- I can't tell with any degree of certainty whether you are a <star1> or <star2>.
  • keyword.rive
! version = 2.0

+ [*] the machine [*]
- How do you know about the machine!?

  • array1.rive
! version = 2.0


! array colors = red blue green yellow


+ what color is my (@colors) *
- Your <star2> is <star1>, silly!
- Do I look dumb to you? It's <star1>!

+ i am wearing a (@colors) shirt
- Do you really like <star>?

// Without parenthesis, the array doesn't go into a <star> tag.
+ what color is my @colors *
- I don't know what color your <star> is.

// Arrays in an optional
- i just bought a [@colors] *
- Is that your first <star>?

  • array2.rive
// Single word array items
! array colors = red blue green yellow

// Multiple word items
! array blues = light blue|dark blue|medium blue

// A lot of colors!
! array colors = red blue green yellow orange cyan fuchsia magenta
^ light red|dark red|light blue|dark blue|light yellow|dark yellow
^ light orange|dark orange|light cyan|dark cyan|light fuchsia
^ dark fuchsia|light magenta|dark magenta
^ black gray white silver
^ light gray|dark gray

  • google.rive
! version = 2.0

// If the user begins a message with "google" it will create
// a google search link.
+ google *{weight=10}
- Google search: <a href="http://google.com/search?q=<star>">Click Here</a>

  • redirections1.rive
! version = 2.0

+ hello
- Hi there!
- Hey!
- Howdy!

+ hey
@ hello

+ hi
@ hello


+ bot
- Chatbot
- ALICE
- ChatGPT

+ * or something{weight=100}
- Or something. {@ <star>}

  • redirections2.rive
! version = 2.0

+ hello *
- {@ hello} <@>

+ hello
- Hi there!

+ bot
- My name is Javis!

+ are you a bot
- How did you know I'm a machine?

  • previous1.rive
! version = 2.0

! sub what's = what is


+ i have a girlfriend
- What's her name?

+ *
% what is her name
- That's a pretty name.

  • previous2.rive
! version = 2.0

! array colors = red|blue|green|yellow


+ i have a dog
- What color is it?

+ (@colors)
% what color is it
- That's a silly color for a dog!

  • previous3.rive
! version = 2.0

! sub who's = who is


+ knock knock
- Who's there?

+ *
% who is there
- <star> who?

+ *
% * who
- HaHaHa! <star>! That's funny!

  • user-variable.rive
! version = 2.0


+ my name is *
- <set name=<star>>It's nice to meet you, <get name>.

+ what is my name
- Your name is <get name>, silly!

+ i am # years old
- <set age=<star>>I will remember that you are <get age> years old.

+ how old am i
- You are <get age> years old.

  • bot-variable.rive
! version = 2.0


// Bot variables
! var name = Javis
! var age  = 5


// The user can ask the bot its name too!
+ what is your name
- You can call me <bot name>.
- My name is <bot name>.

+ how old are you
- I am <bot age> years old.

  • formal-tag.rive
! version = 2.0


// Store the name with the correct casing
+ my name is *
- <set name=<formal>>Nice to meet you, <get name>!

  • conditionals1.rive
! version = 2.0


/*
+ my name is *
- <set name=<star>>It's nice to meet you, <get name>.
*/


+ what is my name
* <get name> == undefined => You never told me your name.
- Your name is <get name>, silly!
- Aren't you <get name>?

  • conditionals2.rive
! version = 2.0

// Bot variables
! var name = Javis
! var age  = 5


+ my name is *
* <formal>   == <bot name> => Wow, we have the same name!<set name=<formal>>
* <get name> == undefined  => <set name=<formal>>Nice to meet you!
- <set oldname=<get name>><set name=<formal>>
^ I thought your name was <get oldname>?

  • conditionals3.rive
! version = 2.0


+ i am # years old
- <set age=<star>>I will remember that you are <get age> years old.

+ what am i old enough to do
* <get age> == undefined => I don't know how old you are.
* <get age> >  25 => You can do anything you want.
* <get age> == 25 => You're old enough to rent a car with no extra fees.
* <get age> >  21 => You're old enough to drink, but not rent a car.
* <get age> == 21 => You're exactly old enough to drink.
* <get age> >  18 => You're old enough to gamble, but not drink.
* <get age> == 18 => You're exactly old enough to gamble.
- You're not old enough to do much of anything yet.

  • topic.rive
! version = 2.0

+ i hate you
- You're really mean! I'm not talking again until you apologize.{topic=sorry}

> topic sorry

  // This will match if the word "sorry" exists ANYWHERE in their message
  + [*] sorry [*]
  - It's OK, I'll forgive you!{topic=random}

  + *
  - Nope, not until you apologize.
  - Say you're sorry!
  - Apologize!

< topic

  • begin.rive
! version = 2.0

! var name = Javis


> begin

  // If we don't know their name, set the new_user topic and continue.
  + request
  * <get met> == undefined => <set met=true>{topic=new_user}{ok}
  - {ok}

< begin



> topic new_user

  + *
  - Hi! I'm <bot name>! I'm a chatbot written in RiveScript.\s
  ^ What is your name?{topic=asked_name}

< topic



> topic asked_name

  + #
  - Your name is a number?

  + *
  - I only want your first name.

  + _
  - <set name=<formal>>Nice to meet you, <get name>!{topic=random}

< topic