Serbian Chatbot is project of writing first multi-purpose chatbot for Serbian-speaking users.
Rocket is AIML generator written in Ruby for faster prototyping of AIML chatbots. Files generated by Rocket could be used independently of programming language in which chatbot is written, but Rocket requires Ruby to convert Ruby files to AIML ones.
Tags are easier for beginners but for bigger projects it's pretty hard to write everything in tags. That's the reason why I made Rocket.
If Ruby is already installed on your system, install pretty-xml
gem, clone this repository and require core file.
require_relative "lib/core.rb"
To start writing in Rocket, define new specification:
bot = Bot.new("botname")
You can define options for specification:
bot.options({
debug: false, # define as true if you want to get logs from translation (helpful on bigger projects)
pretty: true # define as true if you want to get nicely formatted code
})
# Patterns are automatically uppercased
# when conversion begins
bot.on "How are you" => "I'm fine, thanks!"
<category>
<pattern>HOW ARE YOU</pattern>
<template>I'm fine, thanks!</template>
</category>
bot.on "*" => rand([
"I don't understand you!",
"Write clearly!"
])
<category>
<pattern>*</pattern>
<template>
<random>
<li>I don't understand you!</li>
<li>Write clearly!</li>
</random>
</template>
</category>
# You can chain multiple conditions
# using + operator
on "My name is *" =>
set({"name" => "#{star}"}) +
cond({"name" => "Mia"}, "Hi darling!") +
cond({"name" => "Gordon"}, "Nice to meet you Gordon!"})
<category>
<pattern>MY NAME IS *</pattern>
<template>
<set name="name"><star/></set>
<condition name="name" value="Mia">
Hi darling!
</condition>
<condition name="name" value="Gordon">
Nice to meet you Gordon!
</condition>
</template>
</category>
All generated code is available via get_content
method for each Bot instance:
bot = Bot.new("chatbot")
# ... code ...
# Output: code converted to AIML
puts bot.get_content