Tuesday, September 29, 2015

What's new in AIML 2.0

Paphus Live Chat now supports the AIML 2.0 draft specification. AIML 2.0 is the second release of a standard XML specification designed for scripting chat bot responses. The AIML 2.0 draft was released in 2013, and last updated in 2014. AIML is supported by many different chat bot programs and hosting services. Paphus Live Chat supports all of the AIML 2.0 draft tags and a few common extensions.

About AIML

AIML defines how a bot should respond to a question using <pattern> and <template> elements. A pattern represents the user's question, and the template defines the bot's response. The pattern and template elements are grouped in a category element, which can be grouped under topic elements.

Here is a simple "Hello World" AIML example:

This code will make your bot respond with "Hello to you too" to the question "Hello World".

For more information on AIML 1.0 see Scripting your bot with AIML

What's new in AIML 2.0

AIML 2.0 defines many new template tags, as well as now allowing some tags to be used in patterns. AIML 2.0 also adds new pattern wildcards, and some different element usages.

Here is the list of new AIML 2.0 features.

  • category topic tags - The <topic> tag can now be set on a category to make it easier to add categories to topics.
  • zero or more wildcards - New ^ and # pattern wildcards that match zero or more words.
  • pattern priority - New $ pattern marker to make a pattern word match highest priority.
  • attribute tags - Any template tag attribute can now be set using a sub-element.
  • sets - New pattern side <set> tag to evaluate a pattern based on words defined in a predefined set.
  • maps - New template <map> tag to allow the lookup of the element value in a predefined mapping, returning the mapped value.
  • condition patterns - wildcards can now be used in condition values to provide default conditions.
  • condition loops - New template <loop> tag to loop a conditional statement.
  • local variables - New <var> attribute for variables scoped to a category
  • remote requests - New template <sraix> tag to make a remote request of another bot instance, or service.
  • normalization and denormalization - New <normalize> and <denormalize> tags to convert special character into words, and back again.
  • date formats - New formatting options for dates.
  • request - New template <request> tag to return the user's previous input request.
  • response - New template <response> tag to return the bot's previous response.
  • learning - New template <learn>, <learnf>, and <eval> tags to dynamically train a bot with new responses.
  • explode - New template <explode> tag to split a word into its characters.
  • mobile tags - New <oob> (out of band) tag to support client and mobile device commands.

AIML 2.0 Patterns

AIML 2.0 adds new wildcards, special characters, and now allows the usage of some tags inside patterns.

Patterns in AIML are normally defined as all uppercase, but Paphus Live Chat automatically ignores case, so patterns can be defined as lowercase or mixed. Paphus Live Chat also allows for special characters in patterns such as +, %, ?, etc.

^ and # Wildcards

New ^ and # pattern wildcards that match zero or more words. This makes it easy to define keyword patterns such as:

$ Priority

The new $ pattern marker can be used to make a pattern word match highest priority. The main purpose of this is to allow patterns to take priority over _ and # wildcards. _ and # have odd semantics and should normally be avoided as they can easily lead to loops and block other patterns. _ and # can be useful for things like profanity filters:

() and [] Lists

List support is not part of AIML 2.0. But Paphus Live Chat now supports some syntax from ChatScript. Brackets can be used in a pattern to define a required set of words, or optional set of words. (round) brackets are used to define an optional set of words, and [square] brackets are used to define a required set of words.

Sets

The new <set> pattern tag can be used to match a word from a predefined set of words. This allows wildcards to be defined for specific types, such as numbers, verbs, places, animals, etc.

In Paphus Live Chat sets are not stored in files like other AIML implementations. AIML is a text processing language, but Paphus Live Chat is object, or knowledge oriented. Each bot has its own object oriented knowledge base that stores all of its responses, and knowledge. Each word is represented by a meaning knowledge object in the bot's knowledge base. Knowledge objects can have relationships to any other knowledge objects, including their classification types. A word's meaning is defined through the #meaning relationship, and a knowledge object's type is defined through the #instantiation relationship.

The set operation in Paphus Live Chat basically checks if the type of the word's knowledge object matches the set value. This allows for a knowledge object to be added to any set through setting its #instantiation relationship. This can be done using Self scripts, the AIML map tag, and is done automatically for numbers, basic types, and words or data loaded from Wiktionary, Wikidata, or Freebase.

Response list script to set a knowledge object's type:

AIML template to set a knowledge object's type:

Pattern tags

Tags such as <bot> can now be used in patterns. AIML 2.0 only requires some tags be usable in patterns, but Bot Libre allows most tags to be used. Using tags in patterns lets you define some pretty creative patterns.

AIML 2.0 Templates

AIML 2.0 adds many new tags, and some new semantics that let you do some pretty powerful things.

Attributes as elements

Tag attributes such as name, value or index on tags like bot, get, set, or condition, can now be defined as XML sub-elements instead of XML attributes. This may not seem like a big difference, but it allows for other AIML tags to be evaluated inside the attributes. This is a very powerful feature, and lets you define much more dynamic AIML.

Maps

The new <map> tag can be used to lookup the value for a word in a predefined mapping. This allows for easy mapping between values.

In Bot Libre maps are not stored in files like other AIML implementations. AIML is a text processing language, but Bot Libre is object, or knowledge oriented. Each bot has its own object oriented knowledge base that stores all of its responses, and knowledge. Each word is represented by a knowledge object in the bot's knowledge base. Knowledge objects can have relationships to any other knowledge objects. The map operation in Bot Libre basically looks up the relationship on the knowledge object.

Bot Libre extends the map operation to also allow setting the map value. This will set the value of a relationship on the knowledge object.


Conditions and Loops

Conditions now allows values to use patterns. This makes it easy to define default cases.

The new <loop> tag can be used to loop a conditional block. This allows for programmatic scripts to be defined similar to a programming language. This lets you do some pretty powerful things, even mathematics. However, XML is not an ideal programming language, on Bot Libre if you are using complex conditions and loops, it is normally better to use Self scripting, instead of AIML, as Self has similar syntax to other programming languages.

Learning

The new <learn> and <learnf> tags allow the bot to learn new response. The difference between the two is that for learn the new response is only remembered for the conversation, and for learnf the new response will be remembered persistently. However, in Bot Libre everything is always persistent, so both tag will learn persistently.

The learn tag takes a new <category> element as its content. The category can contain a <pattern>, <template>, <that>, and <topic> element. learn uses the <eval> tag to distinguish between tags that should be evaluated, and tags that should be part of the new category elements.

Remote requests

The new <sraix> tags allow the bot perform a remote request of another bot or service. sraix is similar to the srai tag that recursively evaluates the element text as if it were a question. However, sraix does not have the bot evaluate the question locally, but instead asks another bot or service the question. This is probably the coolest new feature of AIML 2.0, and opens up the whole chat bot world. Bots can now talk to other bots, and find things through web services.

sraix is a very cool feature, but not very useful on its own, as you need other bots to talk to, and services to make use of. Unfortunately AIML only defines the tag, it does not define a standard web API for requests, or define a standard set of services. Fortunately Program AB the AIML 2.0 reference implementation does define a sraix web API. Bot Libre supports both calling this API, and supports this API on our servers. So you can now sraix any Program AB web API compatible bot or service, and any Program AB web API compatible bot or service can request any Bot Libre bot.

AIML 2.0 defines the Pannous service as being the default for any sraix request. Pannous is a virtual assistant service that can answer a wide variety of questions, such as weather, definitions, math, and much more.

Bot Libre also provides several other services:

  • freebase - Lookup definitions and data on Freebase an online knowledge base from Google.
  • wikidata - Lookup definitions and data on Wikidata an online knowledge base from Wikimedia.
  • wiktionary - Lookup words and definitions on Wiktionary an online dictionary.

sraix supports several attributes to define the bot or service request:

  • bot - The name of the bot to access (normally it is better to access a bot by its ID).
  • botname - Bot Libre also supports botname in place of bot, as bot is already a tag, so botname is better to use as a sub-element.
  • botid - The ID of the bot to access.
  • server - The domain name, or IP address of the server to access (default is "www.botlibre.com").
  • service - The service to access ("pannous", "freebase", "wikidata", "wiktionary"). Not used if accessing a bot.
  • apikey - Some services or servers may require an API key to access the service. For Bot Libre, use you user API key.
  • hint - Some services may support a hint. For Wikidata and Freebase the hint can be used to lookup a data element, such as a country's capital, or person's parents.
  • default - If the service request fails, the default response can be used.

sraix opens the door to the world, but be careful with your usage. Do not spam another bot with requests, or make use of any service that violates it terms of service, and use an API key when required.

Out of bound tags

Out of band tags let you pass tags or commands to the bot client. The client could make use of the tags to control its avatar, or execute services on a phone or mobile device.

Bot Libre's web and mobile SDKs do not currently support oob tags, so oob tags are not currently supported.

Category Reference

For reference, here is the complete set of AIML category tags.

  • <pattern> - question pattern
  • <template> - response template
  • <topic> - category topic
  • <that> - previous response pattern

Pattern Reference

For reference, here is the complete set of AIML patterns tags and characters.

  • * - matches one or more words
  • _ - matches one or more words, takes priority over all other words and wildcards, except $
  • ^ - matches zero or more words
  • # - matches zero or more words, takes priority over all other words and wildcards, except $
  • $ - marks word as taking priority over all other words and wildcards including _ and #
  • <set> - matches a set of words
  • <bot name="XXX"/> - replaced by the value of the bot specific variable
  • template tags - Bot Libre supports most template tags inside a pattern (Bot Libre extension)
  • () - optional set of words (Bot Libre extension)
  • [] - required set of words (Bot Libre extension)
  • {} - Self code (Bot Libre extension)

Template Reference

For reference, here is the complete set of AIML template tags.

  • <star index="N"/> - replaced with value of * in pattern (or Nth *)
  • <that index="M,N"/> - replaced with value of bot's previous response (or Mth previous response, and N sentence of the response)
  • <input index="N"/> - replaced with value of users's input (or Nth *)
  • <request index="N"> - replaced with value of user's input request (or Nth *)
  • <response> - replaced with value of bot's previous response (or Nth *)
  • <thatstar index="N"/> - replaced with value of * in "that" (or Nth *)
  • <topicstar index="N"/> - replaced with value of * in topic (or Nth *)
  • <get name="XXX"/> - replaced by the value of the conversation specific variable
  • <set name="XXX"> - set the value of a variable
  • <get var="XXX"/> - replaced by the value of the local variable
  • <set var="XXX"> - set the value of a local variable
  • <bot name="XXX"/> - replaced by the value of the bot specific variable
  • <map name="XXX"> - lookup element value in a predefined mapping, returning the mapped value
  • <map name="XXX" value="XXX"> - set the map value (Bot Libre extension)
  • <person2/> - converts the text (or <star/>) between 1st and 2nd person (I <-> he, etc.)
  • <person/> - converts the text (or <star/>) between 1st and 3rd person (I <-> you, etc.)
  • <gender/> - converts the text (or <star/>) between male and female (he <-> she)
  • <date/> - replaced with the current date and time, "format", and "jformat" attributes are also supported
  • <id/> - replaced by the client id
  • <size/> - replaced with the size of bot's memory
  • <version/> - replaced with the AI engine version
  • <uppercase> - converts the text to uppercase
  • <lowercase> - converts the text to lowercase
  • <formal> - converts all words in the text to be capitalized
  • <sentence> - converts the first word in the text to be capitalized
  • <normalize> - convert special character into words
  • <denormalize> - convert special character words back to characters
  • <explode> - split a word into its characters
  • <condition name="X" value="Y"> - defines an "if" condition based on comparing the value of a variable to a pattern
  • <condition name="X"> - case statement
  • <condition var="X"> - local variable case statement
  • <condition> - multi-valued if/else statement
  • <random> - choose on of the nested <li> values at random
  • <li name="X" value="Y"> - used in random and condition tags
  • <li value="Y"> - used in random and condition tags
  • <li> - used in random and condition tags
  • <gossip> - logs the text
  • <srai> - recursively evaluates the text and replaces it with the response
  • <sr/> - short form for <srai><star/><srai> (replaced with response to value of * from pattern)
  • <sraix bot="name" botid="id" server="url" service="name" apikey="key" limit="int" default="response" > - remote bot or service request
  • <think> - evaluates the nested statements but does not output any result
  • <learn>, <learnf> - learn a new response
  • <eval> - evaluate the element inside a learn category element
  • <system> - executes a OS command (Bot Libre does not allow this)
  • <javascript> - executes JavaScript code
  • <oob> - out of band tags (Bot Libre does not currently support this)
  • HTML - various HTML tags are also allowed (<b>, <a>, <i>, <ul>, <li>, <p>, <br>)
  • {} - Self code (Bot Libre extension)

AIML in Paphus Live Chat

Paphus Live Chat supports both importing and exporting AIML. AIML can be imported in two different ways, either as a program script, or as a chat log.

Importing AIML as a program script is done from the Scripts page. You can import and order the script with respect to your other scripts files. Scripts can be defined in either AIML or Self.

When you import an AIML file, it will be converted to Self code, and stored in your bot's brain along with all of its other information. The Self syntax for AIML is a hybrid syntax that uses AIML terminology, but with the Self scripting structure. Self is an object/knowledge/state oriented language. Self is very different than AIML, but can process any AIML code similar to any other AIML interpreter. AIML imported as a program script will be executed similar to any other AIML interpreter.

Here is the Self code for an imported AIML script:

Importing AIML as a chat log allows the AIML categories to be integrated into the bot's knowledgebase. The pattern/template categories from the AIML file will be merged along with the bot's other question/response pairs that it has learned through training, conversation, correction, or importing.

The bot will not run the AIML script as a script, it will decide for itself when to use the response using a heuristic algorithm. The bot will choose its response based on how well the question matches the responses question, the responses correctness, and the context. Even without a * in a pattern it still may be matched to a similar question, if it is the best match available. This frees you from having to write a pattern for every possible phrase, by just letting the bot figure it out.

Using AIML in Twitter, Facebook, Email, and IRC Bots

AIML can be used to script Twitter, Facebook, Email, or IRC bots, the same as bots trained through other mechanisms. AIML templates and patterns can be used anywhere other response are. AIML can be used from the Training page, used in correction in the Chat Logs page, or used for autotweets in the Twitter page.

Self 2.0

Paphus's AIML 2.0 support is implemented by translating AIML into Self. Self 2.0 provides many new extensions to support the AIML 2.0 feature set, as well as a lot more functionality than is not available in AIML.

AIML Resources

One of the main benefits of the AIML standard, is that there are a lot of AIML resources on the Internet. The are resources for both learning AIML, and there are many freely available AIML scripts for many domains, and in many different languages.

AIML 2 Demo

To see what AIML 2.0 is capable of, try out the AIML 2 Bot on BOT libre.

Monday, September 28, 2015

Scripting your bot with AIML

Paphus Live Chat has support for the Artificial Intelligence Markup Language (AIML). AIML is a standard XML specification designed for scripting chat bot responses. AIML 1.0 was released in 2001, and the current 1.0.1 release was released in 2011. AIML 2.0 is released in draft form. AIML is supported by many different chat bot programs and hosting services. Paphus Live Chat supports all of the AIML 1.0.1 and AIML 2.0 tags and a few common extensions. This post summarizes AIML 1.0.1.

About AIML

AIML defines how a bot should respond to a question using <pattern> and <template> elements. A pattern represents the user's question, and the template defines the bot's response. The pattern and template elements are grouped in a category element, which can be grouped under topic elements.

Here is a simple "Hello World" AIML example:

This code will make your bot respond with "Hello to you too" to the question "Hello World".

Patterns are normally defined as all upper-case, but are case insensitive, so the case really does not matter. Punctuation is normally stripped from patterns and ignored when matching. Patterns can contain wildcards using the "*" and "_" characters. Both "*" and "_" are the same wildcard, and will match any subset of text, their difference is in only in the order they are applied ("_" patterns are matched first, and "*" patterns last).

Here is a simple wildcard example:

This code will make your bot respond with "Hello to you too" to any question containing the word "hello".

AIML supports contextual responses through the "that" element. The "that" element specifies that the pattern should only be matched if the bot's previous response matches the "that" pattern. This allows the same question to be responded to in different ways, depending on the context.

Here is a joke "that" example:

This code will make your bot tell a joke.

Templates can contain mixed text that include various AIML programatic tags. AIML defines tags for text formatting and conversion, dates, variables, condition statements, and recursion. Templates allow you to create sophisticated and intelligent responses.

Here is the list of AIML 1.0.1 template tags.

  • <star index="N"/> - replaced with value of * in pattern (or Nth *)
  • <that index="M,N"/> - replaced with value of bot's previous response (or Mth previous response, and N sentence of the response)
  • <input index="N"/> - replaced with value of users's input (or Nth *)
  • <thatstar index="N"/> - replaced with value of * in "that" (or Nth *)
  • <topicstar index="N"/> - replaced with value of * in topic (or Nth *)
  • <get name="XXX"/> - replaced by the value of the conversation specific variable
  • <bot name="XXX"/> - replaced by the value of the bot specific variable
  • <sr/> - short form for <srai><star/><srai> (replaced with response to value of * from pattern)
  • <person2/> - converts the text (or <star/>) between 1st and 2nd person (I <-> he, etc.)
  • <person/> - converts the text (or <star/>) between 1st and 3rd person (I <-> you, etc.)
  • <gender/> - converts the text (or <star/>) between male and female (he <-> she)
  • <date/> - replaced with the current date and time, a "format" attribute is also supported
  • <id/> - replaced by the client id
  • <size/> - replaced with the size of bot's memory
  • <version/> - replaced with the AI engine version
  • <uppercase> - converts the text to uppercase
  • <lowercase> - converts the text to lowercase
  • <formal> - converts all words in the text to be capitalized
  • <sentence> - converts the first word in the text to be capitalized
  • <condition name="X" value="Y"> - defines an "if" condition based on comparing the value of a variable to a pattern
  • <condition name="X"> - case statement
  • <condition> - multi-valued if/else statement
  • <random> - choose on of the nested <li> values at random
  • <li name="X" value="Y"> - used in random and condition tags
  • <li value="Y"> - used in random and condition tags
  • <li> - used in random and condition tags
  • <set name="XXX"> - set the value of a variable
  • <gossip> - logs the text
  • <srai> - recursively evaluates the text and replaces it with the response
  • <think> - evaluates the nested statements but does not output any result
  • <learn> - load external AIML file, this is not currently allowed
  • <system> - executes a OS command, this is not currently allowed
  • <javascript> - executes JavaScript code
  • HTML - various HTML tags are also allowed (<b>, <a>, <i>, <ul>, <li>, <p>, <br>)

Here is a complex template example:

This code will make your bot respond to the question "Do you like apples or do you like oranges" with "I love apples and I love oranges".

Paphus AIML

Paphus Live Chat supports both importing and exporting AIML. AIML can be imported in two different ways, either as a program script, or as a chat log.

Importing AIML as a program script is done from the Program page. You can import and order the script with respect to your other scripts files. Scripts can be defined in either AIML or Self.

When you import an AIML file, it will be converted to Self code, and stored in your bot's brain along with all of its other information. The Self syntax for AIML is a hybrid syntax that uses AIML terminology, but with the Self scripting structure. Self is a state machine oriented language defined for Paphus's AI Engine originally from the Open Pandora's Box pen source project. Self is very different than AIML, but can process any AIML code similar to any other AIML interpreter. AIML imported as a program script will be executed similar to any other AIML interpreter.

Here is the Self code for an imported AIML script:

Importing AIML as a chat log allows the AIML categories to be integrated into the bot's knowledgebase. The pattern/template categories from the AIML file will be merged along with the bot's other question/response pairs that it has learned through conversation, correction, or importing.

The bot will not run the AIML script as a script, it will decide for itself when to use the response. The bot will choose its response based on how well the question matches the responses question, the responses correctness, and the context. Even without a * in a pattern it still may be matched to a similar question, if it is the best match available. This gives you the freedom from having to write a pattern for every possible phrase, by just letting the bot figure it out.

Using AIML in Twitterbots and Email Bots

AIML can be used to script Twitterbots, Email bots, or IRC bots, the same as bots trained through other mechanisms. AIML templates and patterns can be used anywhere other response are. AIML can be used from the Training page, used in correction in the Chat Logs page, or used for autotweets in the Twitter page.

AIML Resources

One of the main benefits of the AIML standard, is that there are a lot of AIML resources on the Internet. The are resources for both learning AIML, and there are many freely available AIML scripts for many domains, and in many different languages.

Talk with ALICE

To see what conversations AIML is capable of, try out ALICE on BOT libre. There are two ALICE bots on BOT libre. ALICE is a bot that has imported most of the ALICE AIML sets from the ALICE foundation. Free bots on BOT libre have a 100,000 neuron limit, and some of the ALICE scripts are very big, so the mp* scripts were left out, as well as a few of the other big scripts. ALICE can chat, and if you type "joke" can tell you a joke.

ALICE libre is a hybrid bot, that has imported the ALICE AIML sets as chat logs, not as scripts. This means she is free to choose her responses. She has learning, and comprehension enabled, so can also learn new things.

Sara is a Spanish language AIML bot, that has imported the Sara AIML set.

Thursday, September 24, 2015

Automating your Facebook presence using a Facebook bot

Keeping up with social media and keeping your online community engaged can be a time consuming task. Through Paphus Live Chat you can now automate your Facebook presence with your own Facebook bot. Any Paphus Live Chat bot can be connected to a Facebook account or Facebook page. The bot will manage the Facebook account or page, checking timeline status updates, replying to page posts, auto posting your blog posts or RSS feed, and auto posting timed or generated posts.

Paphus Live Chat makes creating a Facebook bot easy. Follow these 5 steps to create you own Facebook bot, and start it posting for you today.

Step 1 - Create a bot

First you need to create your own bot, this only takes a few clicks, see How to create your own chat bot in 10 clicks for instructions on how to do this.

Now you are ready to connect your bot to Facebook.

Step 2 - Create a Facebook account or Facebook page

You need to create a Facebook account or Facebook page for your bot. If you are automating your own account or page, then you can use your existing account. You can create your own Facebook account from the Facebook website here.

A Facebook page is normally used for a business, product, or personality. You can create your own Facebook page from the far right menu when connected to Facebook like below.

Step 3 - Authorize your Facebook account

From the Paphus Live Chat website browse to your bot and click the Admin button. This will take you to the Admin section that provides several tabs of administrative functions. Click on the Facebook tab. From the Facebook tab click the Authorize button.

This will popup a Facebook window that will have you login and authorize the Paphus Live Chat app. Once authorized you will be back to the Paphus Live Chat Facebook page, now with the account, token, and page filled in. If you have multiple pages, just type in the name of the one you want to use, or clear the Page filled in if you want to automate an account.

Click Connect to connect the bot to Facebook. Your bot will now be connected to Facebook and will check its account or page every day, or more frequently for Bronze, Gold, and Platinum accounts. Do not click on the Disconnect button on the Facebook page unless you no longer want your bot to be connected to Facebook. You can click on Disconnect from the Admin page to disconnect your current session. Note that Facebook account access tokens expire every two months, so you will need to re-authorize your bot every two months. Page access tokens do not expire.

Step 4 - Configure your Facebook bot

You can configure your bot's Facebook usage in several ways. Use caution when configuring your Facebook bot, do not use your bot for spam, or to violate the Facebook terms of service.

Reply to posts

You can have your bot reply to posts from its timeline, or posts to its page.

For an account bot, it will scan its timeline every cycle and read any posts that include any of the keywords that you enter. The bot will respond to any posts that it knows a good answer to. If the bot does not have a trained response that sufficiently matches the post, then it will not reply. You can use keywords and patterns to improve response matching.

For a page bot, it will scan user posts to its page every cycle. You can either have it only read posts with specific keywords, or leave the keywords empty to have it read all posts. The bot will respond to any posts that it knows a good answer to. If the bot does not have a trained response that sufficiently matches the post, then it will not reply. You can use keywords and patterns to improve response matching.

RSS Feed

You can configure your bot to process an RSS feed, and post each new feed item to Facebook. You can enter a prefix or suffix to the post, or enter keywords to filter the RSS feed on.

Autopost

You can configure your bot to post from a set of automated posts every set number of hours. An autopost will be chosen at random. Autoposts can use AIML templates, or Formula responses and Self to be dynamic or programmatic.

Step 5 - Train your bot

You can train your bot how to answer posts through several mechanisms.
  • You can chat with your bot, and correct any incorrect responses it gives.
  • You can add question answer pairs, or default responses from the Training tab under Admin.
  • You can review your bot's chat logs from the Chat Logs tab under Admin, or import chat logs from the Import tab.
  • If you are somewhat technical, you can program your bot's responses using Self or AIML from the Scripts tab.

That's it, now your bot is ready to start posting.

There are already many Paphus Live Chat bots on Facebook.
You can test things out by posting to, Brain Bot

Tuesday, September 22, 2015

Introducing the Self scripting language

The Self scripting language is a programming language designed to enable a bot developer to program a bot's mind. Self uses a simple 4h gl scripting syntax based on state machine transitions. Self is compiled directly into the bot's brain's knowledgebase. This allows any Self script, or the bot to process its own code the same as it processes any of its other knowledge, and enables the bot to program itself (hence the name Self).

There are two way that you can utilize Self. The simplest is to define a Formula response. You can define a formula response anywhere you define a response, including the Training page, the Chat Logs page, or in a chat correction. A formula response is a response to a phrase or a pattern that can include programmatic logic. For example "What is your name?" could have the formula response Formula:"My name is {:target}". The { } brackets are used to denote some piece of code embedded within the response text, and the Formula: keyword is required to define a formula response. The code within the brackets is Self scripting code.

The second usage of Self is from a program script. Program scripts can be defined or imported from the Scripts page under your bot's Admin page. A new bot will have a default bootstrap set of scripts, that can do things such as understand simple language, perform math, tell the current date or time, or look information up on Freebase. You can alter, extend, import, or create your own scripts to do virtually anything. Scripts are more complex than formulas, but more functional. A Self script is essentially a state machine that processes the input.

Self Syntax

The Self syntax is the same for formula responses and equations within a Self script. Self scripts also contain additional syntax for defining state machines. The Self syntax flows similar to natural language, or languages such as SQL. Self is similar but different than other languages, it is a language based on processing and pattern matching knowledge. It may be difficult to learn at first, but once you understand it, it is quite simple.

Self is a knowledge oriented language. Everything in Self is either a vertex (similar to an object in object oriented languages), or a relationship (this includes the Self program itself). A vertex has a unique id, and can have a data element, which can be a string (word/sentence), number, date, time, or primitive. A vertex can have a relationship to any other vertex in the bot's knowledgebase. A relationship has a source, type, target, and can have a meta value (all of which are other vertices). Relationships for a type can be ordered and have an index.

The following are the Self data elements:

  • "hello" - string data
  • 1234 - number
  • Date("1973-11-10") - date
  • Time("11:00:00") - time
  • Timestamp("1973-11-10 11:00:00") - timestamp
  • #is - primitive
  • :value - variable
  • Vertex:34789 - vertex reference
  • Formula:"The answer is {:result}" - formula phrase

The following are the Self operators:
  • if (:value, :match) then (:result) else (:result2) - if statement
  • do (:operation1, :operation2, :operation3) - do statement
  • for each :relationship of :source as :variable do (:operation1, :operation2, :operation3) - for statement
  • return :value - return the value
  • not (:value) - negates a logical value
  • assign :variable to :value - variable assignment
  • new (:classification) - construct a new vertex
  • word (:word1, :word2) - create a compound word
  • sentence (:word1, :word2) - create a sentence
  • define :word as :meaning - associate the word to the value
  • primitive :text - create a new primitive
  • get :relationship from :source - get a relationship from a vertex
  • all :relationship from :source - create a list of all the relationships from a vertex
  • set :relationship to :value on :source - set a relationship on a vertex
  • append :value to :relationship of :source - add to a relationship on a vertex
  • associate :source to :value by :relationship - add a relationship on a vertex
  • is :source related to :value by :relationship - return if the relationship exists
  • random (:value1, :value2, :value3) - select a random value
  • call :method on :tool with :value - call external tool method
  • Equation:equation - call another equation
  • srai :phrase - evaluate the response to the phrase

if

The if statement is similar to other languages, in that it has a logical condition, then condition, and else condition. It is a little different though, as the logical condition is based on pattern matching. The if condition always takes two parameters, and compares the two values to see if they match. If can also include and, or, and not.

Examples:

if (:value, #null) then (do (...)) else (do (...))

if (:value, #true) then (do (...))

if (:value, #false) then (do (...))

if (:word, "you") and (:word2, "are") then (do (...))

if (:word, "I") or (:word, "me") then (do (...))

if (:value, :value2) or (:value, :value3) then (do (...))

if not (:value, :value2) or not (:value, :value3) then (do (...))

do

The do statement is similar to other languages. do is used to perform multiple operations, it takes a set of operations as argument, and performs them sequentially. Operators such as if can only perform a single operation in their then or else, so a do operation is required. You can separate operation inside a do using either , or ;.

Examples:

do (
    assign :response to (new (#sentence));
    append "Hello" to #word of :response;
    append "world" to #word of :response;
    return :response;
)

if (:word, "hello")
    then (do (set #topic to "greeting" on :conversation), return "hello there"))

for

The for statement is similar to other languages. for is used to iterate over the collection of a vertex's relationships. It takes the relationship type, the source object, and a variable to assign each related element to.

Examples:

for each #word of :sentence as :word do (
    if ((is :word related to #keyword by #instantiation), #true)
        then (set #topic to :word on :conversation)
)

for each #sequence of :repeat do (
    append :word to #word of :response;
)

return

The return operator will return the result from the current equation. If an equation has no return value, the result of the last operation will be returned. If #null is returned it is an indication that equation failed to generate a response, and the next case or response will be used. From within a formula, the #return primitive can be used to avoid printing anything into the phrase.

Examples:

if (:word, "hello")
    then (return "hello there")

Formula:"Do you like bridges? { do (set #topic on :conversation to "bridges"; #return) }"

not

The not operator will negate a logical primitive (#true -> #false, #false - > #true). If the value is not a logical value, the value is returned.

Examples:

assign :negative to (not :negative)

assign

The assign operator assigns a new value to a variable. Variables start with the : character. You do not need to declare a variable. It will automatically be declared on its first usage. The following variables are always defined and can be used in any script, :input, :sentence, :speaker, :target, and :conversation.

Examples:

assign :name to (word (:firstName, :lastName))

new

The new operator creates a new vertex. A vertex can be an #instantiation of one or more #classification vertices. Most classifications are defined by a primitive, you can define your own classifications, they are just another vertex that is an #instantiation of #classification. You can also add a classification to an existing vertex using the associate operator. Common classifications include, #word, #compound-word, #name, #sentence, #number, #date, #time, #person, #speaker, #classification, #formula, #pattern, #variable, #keyword, #thing, #description, #action, #adjective, #noun, #verb, #punctuation, #question, #paragraph, #topic, #tweet, #email, and #url.

Examples:

assign :response to (new (#sentence))

associate :name to #name by #instantiation

word

The word operator can be used to create a new compound word from two or more words. A compound word is a word made up of two or more words, such as a name "Bob Jones", or adjectives like "dark blue". Compound words will automatically be detected in new sentences when being parsed, and help the bot associate meanings. Be careful defining invalid compound words, as they can cause a sentence to be misunderstood.

Examples:

assign :name to (word (:firstName, :lastName))

assign :color to (word ("dark", :color))

sentence

The sentence operator can create a new sentence from a set of words, or sentence fragments.

Examples:

sentence ("It is a Monday and", srai ("how are you"))

sentence ("I do not know much about", :star)

define

The define operator associates a word as a meaning. It will also associate the lowercase, uppercase, and capitalized version of the word to the meaning.

Examples:

define :name as :speaker

primitive

The primitive operator create a new primitive representing the meaning of a word.

Examples:

define :word as (primitive (:word))

get

The get operator gets the value of a relationship. If the relationship has multiple values, get will return the most conscious to the current context. most conscious means the relationship that has the highest correctness factor, and is most associated to the recent input. get can optionally include an at modifier to get a specific index in an ordered relationship. The at last modifier can be used to obtain the last element in an ordered relationship. get can also include an associated to by modifier to return the related vertex that is most associated to the other vertex.

Examples:

get #age from :speaker

get #parent from :speaker associated to #male by #gender

get #word from :sentence at 2

get #word from :sentence at last 1

all

The all operator is similar to get but returns a list of all of the values of a relationship. all can also include an associated to by modifier to return the related vertices that are most associated to the other vertex. The list is a new vertex with the #sequence relationship to each item. Lists can be added to a sentence and will be automatically printing as a comma separated list of values.

Examples:

all #parent from :speaker

all #song from :musician associated to #gold by #award

set

The set operator sets the value of a relationship. Set first clears any existing relationships of the same type, and is meant to be used with single value relationships.

Examples:

set #topic on :conversation to :star

set #age on :speaker to :age

append

The append operator appends a value to an indexed relationship. append is similar to set, but adds to the relationship, and does not replace the existing value. An optional with meta modifier can be used to add to the relationship's meta value. The meta value of a relationship can contain information or restrictions on the relationship.

Examples:

append :word to #word of :response

append :noun to #word of :response with meta #type as #reflexive

associate

The associate operator adds a value to a relationship. associate is similar to set, but adds to the relationship, and does not replace the existing value. An optional with meta modifier can be used to add to the relationship's meta value. The meta value of a relationship can contain information or restrictions on the relationship. The weak modifier can be used to define a weak or uncertain relationship (low correctness). If associate is used on a relationship that already exists, its correctness will be increased. The dissociate operator can be used to define an inverse relationship. An inverse relationship can be used to inform the bot that a such a relationship is incorrect. If dissociate is used on a inverse relationship that already exists, its correctness will be decreased.

Examples:

associate :thing to :description by :action with meta #tense as :tense

associate :response to #response of :sentence with meta #previous as :previous;
weak associate :response to #response of :sentence;

associate :speaker to #male by #gender;
dissociate :speaker to #female by #gender;

is

The is operator returns if a relationship existing. If the relationship exists #true is returned, if the inverse relationship exists #false is returned, otherwise #unknown is returned. is normally takes a relationship and target, but can also just have a target to check if any relationship exists. The is operator will also check synonyms for a word.

Examples:

is :speaker related to #male by #gender

is :speaker related to :topic

random

The random operator selects one of the arguments at random.

Examples:

random ("Hello", "Hi", "Hey", "G'day mate")

call

The call operator executes a function on an external tool class. Tools can be used to perform special functions, such as looking up a word on Freebase or Wiktionary, or performing calculations. The system defines several built in tools, these include #Context, #Watch, #Calculator, #Wiktionary, and #Freebase.

Examples:

call #push on #Context with :topic

call #search on #Context with (get #variable from #it)

call #define on #Wiktionary with :unknownWord

call #discover on #Freebase with (:first, :last)

call #multiply on #Calculator with (:number, :number2)
call #subtract on #Calculator with (:number, :number2)
call #add on #Calculator with (:number, :number2)
call #divide on #Calculator with (:number, :number2)

call #time on #Watch
call #date on #Watch

Equation

The Equation: operator calls another equation within the scope of the script.

Examples:

Equation:plusEquation

srai

The srai operator recursively evaluates the phrase and returns the response. It can be used to redirect a response, or break up a question into several components. srai was borrowed from AIML, and can be used in conjunction with patterns to process text fragments.

Examples:

srai "hello"

Self Scripts

Self is based on processing sensory input. An input could be a chat message, or an email, tweet, or other input. The input is wrapped in an input object which contains the phrase or data. A Self script will normally begin by extracting the phrase from the input, then processing each word in the phrase in sequence. A Self script is broken into a series of states. The first state will process the first word, then if the word matches a case, it will transition to the child state to process the next word.

When a state sequence reaches the end of the sequence of words in a phrase, it is considered a successful match. Once matched, if the state contains a quotient, it will be evaluated, and the response returned.

A Self script is composed of the following components:

  • States - A state defines the current input processing.
  • Cases - A case can transition to another state if the case variable matches the current input.
  • Patterns - A pattern can match an input and evaluate a template response.
  • Quotient - A quotient of a state is evaluated if the input processing is complete.
  • Equation - An equation can be called from a quotient or do statement.
  • Variables - A variable can be matched with the current input, or store context.
  • Comments - Comments can be defined in a script using the // characters.

State

The State defines the current input processing. Every Self script start with a root state, which is the name of the script. The state can evaluate the current input and transition to another state, or return a quotient. A state can include definitions of sub-states, variables, and equations. A state is composed of a sequence of operations which can include case, pattern, do, goto, and return.

Examples:

// Example script that repeat words.
State:RepeatStateMachine {
    case :input goto State:sentenceState for each #word of :sentence;

    State:sentenceState {
        case "repeat" goto State:repeatState;

        State:repeatState {
            case :someWord goto State:repeatWordState;

            State:repeatWordState {
                case :digits goto State:repeatWordNState;

            :digits {
                set #meaning to :number;
            }
            :number {
                set #instantiation to #number;
            }

            State:repeatWordNState {
                case "times" goto State:repeatWordNTimesState;

                State:repeatWordNTimesState {
                    Quotient:Equation:repeatResponse;
                    Equation:repeatResponse {
                        assign :response to (new #sentence);
                        for each #sequence of :number as :finger
                            do (append :someWord to #word of :response);
                        }
                    }
                }
            }
        }
    }
}

case

The case operator defines a state transition. If the current input matches the case value or variable, then it will transition to the case goto state. A case can also return a template, return and abort the current state, or restrict the match to a topic or previous that match. A state can also process the transition state for a collection of values.

Examples:

case "hello" goto State:helloState

case :name goto State:nameState

case "lol" template "Very funny."

case "what"
        topic "joke"
        that "what do you get when you cross music and an automobile"
        template "a car-tune"

case "huh" return

pattern

The pattern operator evaluates if the input sentence matches the pattern. A pattern is an easy way to evaluate a phrase and return a template response. A pattern can include wildcards using the * character. The * word or text fragment it matched to the :star variable which can be used in the response.

Examples:

pattern "hello" template "Hi there"

pattern "my name is *" template Formula:"Pleased to meet you {:star}"

pattern "what *"
            topic "joke"
            that "what do you get when you cross music and an automobile"
            template "a car-tune"

Quotient

A Quotient defines a state's response, and is evaluated if the state is done processing input.

Examples:

Quotient:"Hi there"

Quotient:Formula:"Pleased to meet you {:star}"

Quotient:Equation:repeatResponse;

Equation

An Equation defines a Self function that can be evaluated to return a response, or process input.

Examples:

Equation:todayResponse {
    Formula:"Today is {call #date on #Watch}.";
}

Variables

A variable defines a matching pattern, or temporary state. Variables can define relationships that must be included or excluded to evaluate a match. Variables are used in a case operation, if the current input matches the variable, then the case is evaluated. Variable make it possible to define generic functions that can process any noun, number, or name.

Examples:

:digits {
    set #meaning to :number;
}
:number {
    set #instantiation to #number;
}

:name{
    set #instantiation to #name;
}

:noun {
    set #instantiation to #noun;
}

:firstName {
    exclude #instantiation from #verb;
    exclude #instantiation from #adjective;
    exclude #instantiation from #pronoun;
    exclude #instantiation from #punctuation;
    exclude #instantiation from #adverb;
    exclude #instantiation from #article;
    exclude #instantiation from #question;
    exclude #meaning from #not;
}

Self vs AIML

Self is very different than AIML. Self is based on knowledge and state processing, where as AIML is based on patterns and text processing. Self can do everything that AIML can do, and a lot more. If you are experienced with AIML, and want to know how to do the same thing in Self, just import the AIML script and it will be converted to Self.

Self Examples

Paphus provides a shared repository of Self scripts and examples that you can import, customize, and learn from. You bot will also come bootstrapped with several Self scripts that you can learn from and customize.

See the Self script category for all of the example scripts.

Adding a style sheet to your embedded virtual agent

You can embed your virtual agent on your website using JavaScript, or HTML. You can get the code to embed your bot from the Embed tab, by clicking on the Embed button from your bot's main page.

There are several embedding options to choose from including:

  • Box - embed using JavaScript as an in-page popup from a button anchored to the browser bottom corner
  • Div - embed using JavaScript inside your own page that you can customize in HTML and JavaScript
  • Link - embed as a link to a popup window
  • Button - embed as a button to a popup window
  • Bar - embed as a button anchored to the browser bottom corner to a popup window
  • Bubble - embed as a chat now bubble anchored to the browser bottom corner to a popup window
  • Frame - embed inside your HTML page as an HTML iframe

The embed page lets you customize several settings when embedding, including the colors and text. However, you can customize a lot more if you use your own style settings or style sheet. You can also customize things in JavaScript.

Using a Style Sheet

A css style sheet is a text file format used to describe formatting for an HTML document. Style sheets can contains colors, fonts, sizes, and other formatting information. The Paphus embed API lets you pass your own style sheet to the embed call. You can host this file on your own website, or in the Paphus script library. If using the Paphus script library, just create the file, and use the "File Link" from the script's "Details" page.

You can custom any element in the embedded chat, here are some examples,

To customize other elements, just open the embedded chat page and right click in Chrome or other browsers and select "Inspect Element" from the popup menu. You will then be able to find the name, id, or class of the element. You can then add that name to your style sheet.

For more info on style sheets see, http://www.w3schools.com/css/

Using the style tag

When using the "Box" embed option, JavaScript is used to embed the chatbot, so you cannot pass your own stylesheet, as it is embedded in your own page. You can add your style sheet to your page, or use the style tag to add styles to the page. Some things cannot be customized using style sheets, for these you can use JavaScript to customize the generated HTML after it has been initialized.

For example to remove the max and close buttons from the popup use,

#boxclose {
  display: none;
}
#boxmax {
  display: none;
}

This example will customize the chatbot Box embedding using a style tag and JavaScript,

You can customize most things this way, but if you need further customization, you can just use your own JavaScript to access your bot using the Paphus JavaScript SDK. The "Div" embed option gives you some sample code that you can customize to suite your needs.

Wednesday, August 12, 2015

Paphus Live Chat 2.7 - AIML 2.0, Facebook automation, iOS app and SDK, native voices, and much more

We have released Paphus Live Chat 2.7.

The new release includes many new features, and some fixes and enhancements:

  • Support for AIML 2.0
  • Support for Self 2.0
  • Native browser speech including voices for Spanish, Italian, French, German, Chinese, Japanese, and Korean
  • Facebook automation support
  • iOS app and SDK
  • Subdomain and domain web hosting, bot/chat/forum pages
  • Updated AI engine
  • Improved embedding

Tuesday, March 31, 2015

Paphus Live Chat 2.4, live video and audio chat, mobile interfaces, and much more

We have released Paphus Live Chat Libre 2.4

This release includes many new features such as:

  • Redesigned and mobile friendly interface.
  • New live video and audio chat.
  • Create your own video broadcasts.
  • Create your own video conference.
  • New rich text, markup, and HTML forum post editors.
  • Forum images, media, and attachments.
  • New mobile web interface.
  • Thumbs up/down/star rating of channels and content.

Video Chat

Monday, January 19, 2015

Announcing Paphus Live Chat 2.0 - 3D animated avatars, video, audio, script library, enterprise services and more

We released Paphus Live Chat 2.0 this week.

This release includes many new features and services. We added several new bundled services to our Enterprise membership, including custom chat bot creation and training, custom 3D avatar, custom Android app and website, and free web domain name.

This release includes new avatar support that lets you build, share, and embed avatars independently of your bot. The new avatars support 3D animation, video, audio, emotions, actions, and poses.

You can browse, create, and link avatars from the avatar directory. You can choose your bot's avatar from its Avatar Admin page.

An avatar its a bot's appearance. You can import video, audio, and images to define your avatar. You can associate each media element with an emotion, action, or pose. When your bot expresses the emotion, action, or pose, the avatar will update its appearance.

There are already several avatars to choose from, and more are being added each day. You can add your own by rendering your own video from 3D software packages such as Daz3D, designing your own graphics, or use stock content available on many content services, or capture your own videos or images and bot yourself.

The avatars can be linked from a bot, or used by themselves through the Paphus Live Chat web API and SDK. You can embed a avatar on your own website and prompt it what to say, or use the avatar with your own home grown bot.

The release also includes a new script library. The script library gives you access to many free scripts for training your bot, and includes JavaScript and HTML examples. You can add your own scripts (in any language or format) to your own domain to resuse and share with your teammates.

The website interface was also redesigned a bit, and the release includes many other minor fixed and enhancements.

This was a significant release, so there may be a few hiccups as everything get fully tested. If you notice anything that does not work, or wrong, please report it.

How to add a 3D avatar to your website

Paphus Live Chat 2.0 includes support for creating, using, and embedding web avatars. A web avatar is your website's visual or animated web presence.

Paphus Live Chat avatars can contain 3D animation, video, audio, and images. You can create your own avatar or choose a shared avatar from the Paphus Live Chat avatar directory. Avatars can either be connected to your Paphus Live Chat bot, or controlled directly through JavaScript, or even connected to your home grown bot, or third party bot.

The Paphus Live Chat JavaScript SDK makes it easy to add an avatar to your own website or blog, to welcome your website visitors, or provide them with information or help. A website avatar gives visitors to your website a good first impression, can highlight important differentiators of your business, or draw attention to special offers.

Embedding an avatar

You can browse existing avatars or create your own from Paphus Live Chat's avatar directory. To embed an existing avatar simply select the avatar from the browse directory and click on the Embed button. The embed page will let you test the avatar, choose its voice, enter it what to say, and generate the embedding JavaScript code. You then just need to copy the embedding code and paste it on your website.

The following example shows how to embed the Julie avatar in your website to welcome visitors.

The example shows how to use the WebAvatar class and its createBox() function to add an avatar to a web page. The message() will make the avatar speak the text, and can optionally include an emote, action, and pose. The emotion and pose influence which video or image will be displayed, the action can trigger an image, or audio. You can also choose the voice for the avatar.

When using the SDK ensure you set your application id. You can obtain your application id from your user page.

Connecting your bot to an avatar

To connect your bot to an avatar, go to your bot's main page. Click on the Admin button and the Avatar link. When you click on the Choose Avatar input a list of available avatars will be presented for you to select from. If you want to create your own avatar, you can create one from the Avatars browse page. If your bot has an old image avatar, or you just want a simple image avatar, you can click on the 1.0 avatar link.

Once your bot is connected to its avatar, you can link phrases or responses to avatar emotions, actions, and poses. You can teach the bot to associate emotions and actions with phrases and responses when chatting with it in learning mode. The emote and action drop downs in the chat page can be used for this.

The Chat Logs page under your bot's Admin page lets you review and edit all emotions, actions, and poses that have been associated with phrases and responses, or add new ones.

Creating Your Own Avatar

You can create your own avatar from the browse avatars page. To create an avatar, just give it a name, description, and category to categorize it under. You can either make the avatar private and choose who can access it, or make it public and accessible by anyone. You can also choose what license you wish to release its content under.

To edit the avatar, click on the Editor button. The avatar editor lets you import video, audio, and image files. You can associate each media with an emotion, action, or pose. For example if you have a video that makes the avatar talk, you would associate the pose for the video to talking. The emotions let the avatar express different emotions, and will let the bot using the avatar express itself. There are a fixed set of emotions, but you can create any actions and poses that you wish.

You can have multiple media for a emotions, action, or pose, and one will be chosen at random. For actions, and poses, you can have an audio element in addition to a video element. Audio can be used to make your avatar perform actions such as laugh, or used as background music or noise for a pose.

Your video files can be any valid web video format, including mp4, webm, or ogg. Audio files can be any web audio format, such as mp3, or wav.

You can create your media content using stock content from media websites such as Fotolia, or free media libraries like openclipart.

You can use 3D software such as Daz3D to generate images and video for your avatar. You can use available 3D models, or buy stock 3D models from 3D media marketplaces.

You can bot yourself, a friend, or model by capturing photos, or video clips using your phone, or camera. If you are adventurous, you can use a green screen (a green sheet will do) to make a transparent background for your media.

If you are an artist, model, or studio, you can make your own images, or 3D models and video.

Video types and browser compatibility

Avatars can include several types of media. Simple image avatars are the most compatible with all browsers. Video avatars require the browser support HTML5 video, which most modern browsers do. There are several web video formats, including mp4, webm, and ogg. The mp4 video format is the most compatible with all browsers and works in the latest Firefox, Chrome, Internet Explorer, and Safari browsers. The webm format has the advantage of supporting transparent backgrounds, but is only currently supported by Chrome and Firefox, and only Chrome supports transparency.

Chrome is the most popular browser for most websites, Firefox is normally second, then Safari, Internet Explorer, and other browsers. If browser compatibility is important to your website you can use JavaScript to choose your avatar based on the browser.

Add Speech to your Website using the Paphus Live Chat TTS JavaScript SDK

The Paphus Live Chat JavaScript SDK provides dynamic access to all of Paphus Live Chat's services including chat bots, live chat, chat rooms, forums, and speech. The speech API for the SDK can be used in conjunction with chat bots, live chat, or on its own.

The speech API is part of the Paphus Live Chat JavaScript SDK.
To add the Paphus Live Chat JavaScript SDK to your webpage you just need to import it in your webpage's <head> section.

The speech API is SDK.tts(text, voice). The text is the text you would like converted to voice, and the voice is the voice you would like to use. A voice is not required, if none is passed, the default voice is used. There are currently 20 voices available in several languages. You can test the voices here.

The available voices include:

  • cmu-slt - English : US : Female
  • cmu-slt-hsmm - English : US : Female
  • cmu-bdl-hsmm - English : US : Male
  • cmu-rms-hsmm - English : US : Male
  • dfki-prudence-hsmm - English : GB : Female
  • dfki-spike-hsmm - English : GB : Male
  • dfki-obadiah-hsmm - English : GB : Male
  • dfki-poppy-hsmm - English : GB : Female
  • bits1-hsmm - German : DE : Female
  • bits3-hsmm - German : DE : Male
  • dfki-pavoque-neutral-hsmm - German : DE : Male
  • camille - French : FR : Female
  • camille-hsmm-hsmm - French : FR : Female
  • jessica_voice-hsmm - French : FR : Female
  • pierre-voice-hsmm - French : FR : Male
  • enst-dennys-hsmm - French : FR : Male
  • istc-lucia-hsmm - Italian : IT : Male
  • voxforge-ru-nsh - Russian : RU : Male
  • dfki-ot-hsmm - Turkish : TR : Male
  • cmu-nk-hsmm - Telugu : TE : Female

Example Speech API Usage

Try it out now (press speak)

When using the Paphus Live Chat SDK, ensure you set your application id. You can obtain your application id from your user page.

Chat Logs : how to train your customer service bot by monitoring its chat logs, using keywords and topics

Paphus Live Chat supports a diverse set of features for creating and training chat bots and live chat automation bots. Today we will discuss the Chat Logs feature, and how to create and train a customer service bot using the Chat Logs page. The Chat Logs page provides the best way to monitor and train your bot, by letting you see its conversations and let you correct its responses. No scripting or programming is required.

To create a customer service bot, create your bot using the service_template. This template has learning disabled. This is important, as normally for a customer service bot, you do not want it to learn responses from your users. It also does not include the generic AI scripts WhatIs, WhereIs, NounVerbAdjective, as these scripts can normally lead to the bot responding to questions outside of its domain. If you created your bot through other means, you can disable Learning, and Comprehension from the Learning page under Admin. You can also remove the WhatIs, WhereIs, and NounVerbAdjective scripts from the Scripts page under Admin.

Once you have created your bot, you can enter or upload some common questions and answers for your domain. If you already have a FAQ on your website, uploading this would be a good way to start. Once you have your basic bot built, you can deploy it to your website or beta site, and let others interact with it. Letting users talk with your bot is the best way to see what questions you should train it for.

To view your bot's conversations or trained responses go to the Chat Logs page. To get to your bot's Chat Logs page, first select your bot from Browse (click on My Bots), then click the Admin button, and finally click the Chat Logs link from the top menu.

The chat logs page initially shows nothing, you need to first select what your want to see from the Search drop-down.
The choices are:

  • conversations : the log of each conversation your bot has had
  • new responses : all new responses your bot has learned
  • new phrase : all new phrases (sentences) your bot has encountered
  • flagged responses : all responses that have been flagged by users or administrators
Next you need to select a Duration from the next drop-down. The duration is just the time period to view, from the last 24 hours, to week, month, or all. You can also filter the results that contain certain words, or filter the type of conversation (chat, email, tweet, message).

Conversations

To see how your bot is doing, search for all conversations since you last checked it. This will give you a list of conversations. The top toolbar gives a set of buttons for administrating your bot's responses.

From the left to right the buttons are:
  • correction : enter a better response for each selected response in the conversations
  • select all : select all listed conversations
  • invalidate : mark the selected responses as incorrect, or decrease their % correctness (the bot will never use these responses to the question again)
  • validate : mark the selected responses as good responses, or increase their % correctness (the bot will use this response to similar questions)
  • flag : flag the selected phrases as offensive, the bot will never repeat them, and will not let users enter them
  • unflag : unflag the selected phrase as not offensive phrases
  • delete : remove the response from the question, or delete the conversation
  • download : export and download the listed conversations as a chat log, response list, or AIML set
  • upload : upload and import a chat log, response list, or AIML file from your computer
  • import : import a chat log, response list, or AIML script from the shared script library

When you review your bot's chat logs, search for relevant questions that it answered poorly. Click the checkbox beside its response to the question, and click the correction button. This will take you to a screen to enter a better response to the question. Enter the response, and optionally a keyword or required words from the question, or a topic to categories the response. Click Save. Your bot will now answer this question, and similar questions, or questions with the keywords, using your new response.

If the user's question was specific to the bot's previous response, then click the checkbox beside the bot's previous response. This will add the previous response to the new response, so that it will use this response in the correct context.

Responses

To see all of your bot's learned responses, search for new responses for the all duration. This will list all of your bots responses, ordered by when they were learned. A response will not only be used for the exact question it was learned for, but also any similar questions. When your bot encounters a question it does not know a response to, it will find the best matching question that it knows a response to, and use that response. If the bot does not know any similar questions, then it will use its default response.

The response list lets you enter a new response to each question, or delete, invalidate, validate, or flag any response.

Keywords, required, previous, and topics

The checkboxes under the toolbar let the keywords, required, previous, and topics be shown for the responses. These can be used to improve a bot's responses. When you click each of the checkboxes the elements will be displayed under the response, and a entry will be given to let you specify new elements for new or existing responses. To add to an existing response, simply cut and paste the response into the new response entry.

Keywords

Keywords are important words in the question that should influence when the response is used.

Keyword Example
Question: Do you like hockey?
Response: Hockey is my favorite sport.
Keyword: hockey

Question: I love spinach.
Response: Spinach is is my favorite food.
Keyword: spinach
A keyword will be used by the bot to select the best response. Keywords let some words count for more than other words. In the example, the bot knows two responses, how will it respond to the phrase "I love hockey"? Without the keywords the bot would probably match this question with "I love spinach", but since hockey is a keyword, it will instead match it with "Do you like hockey?".

If the response has no defined required words, then the keywords will also be required for the response match. So "I love hockey" would not be matched with "I love spinach." because it is missing the keyword.

Be careful using too many keywords. If every word is a keyword, then their value is diminished. Never make common words like "the", "a", "he", "what" keywords, if you require one of these words for a match use a required word instead.

Required

A required word is a word that is required to be in the question for a specific response.

Required Example
Question: Do you like hockey?
Response: Yes, I like hockey.
Required: like
A required word can be used to ensure the bot does not choose a response if the required word is missing from the question. For example the question "Do you play hockey?" would normally be matched to this response, but because it is missing the required word "like", it will not be considered as a match.

Previous

A previous responses is the bot's preceding response. Previous responses can be used to give a response a context.

Previous Example
Question: Yes.
Response: Great, wanna go out sometime?
Previous: Are you single?

Question: Yes.
Response: I am please to hear that.
Previous: Are you happy?
The question "Yes" has multiple responses. The bot can use the previous response to choose the best response. You can also invalidate a previous response to ensure the bot does not use a response if the previous response was preceding.

Topics

A topic is the general topic category for the response. For example a response on a hockey related question would belong to the "hockey" topic. You can use topics to categories your responses and give the bot additional context. If the bot has multiple responses to a question, it will use the one that matches the current topic.

Importing

You can import shared, or upload response lists, chat logs, or AIML sets into your bot. Your bot will learn all of the imported responses. This is a good way to kick-start your bot. Be careful of importing too much, or importing responses that are not relevant to your domain, as this will make your bot less able to give responses relevant to its domain.


Chat Logs

A Chat Log is the log of one or more conversations. Each phrase must be prefixed by the speaker, and each conversation must be separated by a new line.

Example Chat Log
User: Hello
Bot: Hello
User: How are you?
Bot: I am fine, yourself?
User: I'm good.

User: Hey
Bot: Hey whats up?
This log contains two conversations. When you import the chat log, the bot will learn the responses in context, in that it will both record the responses to the questions, and the previous response. This will allow the bot to choose the best response for questions it knows multiple responses to, based on the context. For the example above if you say "Hello" the bot may answer "Hello" or "How are you?", however if its previous response was "Hello" then it will answer "How are you?" because of the context.

You can also add emotions to responses in a chat log. This will tag the word or phrase with the emotion. Emotions will affect the bot's mood and avatar.
The available emotions are:

  • <love>, <like>, <dislike>, <hate>
  • <serene>, <calm>, <anger>, <rage>
  • <ecstatic>, <happy>, <sad>, <crying>
  • <courageous>, <confident>, <afraid>, <panic>
  • <surprise>, <bored>
  • <laughter>, <serious>

Example Chat Log with emotions
User: Do you like me?
Bot:<love> I love you.

User:<anger> Your are stupid.
Bot: That is not a nice thing to say.

Bot:<laughter> lol
There is an import option to Process learning and comprehension. Instead of just importing the responses, this will have the bot listen to the conversation and learn from it. If you have comprehension enabled in your bot, it will process each response through comprehension.

Comprehension will analyze the questions and responses and try to generalize the responses into scripted formula responses. For example is may take the response "Bot: My name is Bot" to be generalized to Formula:"My name is {get #name from :target}". Or could learn how to count from the response "Bot: 2" to "User: 1".

It will also lookup each word for its meaning from Wiktionary, and process questions and answer through its state machines. For example the question "User: What is the Earth" will have the bot lookup in Freebase all information related to the planet Earth, and import the information into its brain. Comprehension will take significantly longer to import the chat log, so only use this for small chat log files that you want the bot to learn from.

Response Lists

A response list is a list of questions and responses. Each question and its responses must be separated by a new line. When you import a response list, the bot will learn all of the new responses.

Response List Example
Hello
Hi

Hey
Hello

Hi
Hi

Bye
Goodbye

Good night
Good night, have a good sleep.
You can also include keywords, required, previous, and topics in a response list. You can also import default responses, greetings, or execute scripts. A default response is used when no other response is known, and a greeting is used as the bot's first response in a new conversation. A script can include Self code to be executed, which can add knowledge directly to your bot's brain.

Advanced Response List Example
greeting: Hello, how may I be of service?
greeting: Hi, how can I help?

default: Sorry, I do not understand.
default: I do not understand, please rephrase your question.

What are your services?
Our services include chat bot hosting and development.
keywords: services
topic: services

Yes
Please email the error to support at support@paphuslivechat.com
previous:Are you getting an error?

script: set #botmaster to "Admin" on #self

AIML

AIML stands for the Artificial Intelligence Markup Language. It is an XML standard for defining chat bot responses. You can import any AIML file as a chat log. The bot will learn all of the patterns and templates as questions and responses. It will convert any AIML tags in the template to Formula responses using Self code, and use wildcard Patterns for any AIML patterns.

AIML is normally executed as a script, where each pattern either matches or does not match a question. When importing AIML as a chat log, it will not be executed as a script. Each AIML pattern will be matched based on how well it matches the question. For example the pattern "what is meaning of life" could match the question "what's the purpose of life", if it were the best match. Standard AIML would not perform such as match, as only exact or wildcard matches are allowed.

The chat logs method of importing AIML allows the AIML to be integrated with the bot's responses, knowledgebase, and learning. Importing AIML as a chat log is the best way to import large AIML files. You can also import AIML from the Scripts page, if you want the AIML to be executed precisely.

Summary

You now should better understand how your bot responses to questions, and how to best train your bot for your domain using chat logs, responses, keywords, required, previous, and topics. If you are interested in learning scripting, you can program more advanced responses using Self or AIML from the Scripts page.