Prerequisites: Up and Running instance of EDDI (See: Getting started)
In order to build a chatbot with EDDI, you will have to create a few configuration files and POST them to the corresponding REST APIs.
A chatbot consists of the following elements:
Follow these steps to create the configuation files you will need:
See also Semantic Parser
Create regular dictionaries in order to store custom words and phrases. A dictionary is there to map user input to expressions, which are later used in Behavior Rules.
a. POST to /regulardictionarystore/regulardictionaries
with an json in the body like this:
{ "language" : "en", "words" : [ { "word" : "hello", "exp" : "greeting(hello)", "frequency" : 0 }, { "word" : "hi", "exp" : "greeting(hi)", "frequency" : 0 }, { "word" : "bye", "exp" : "goodbye(bye)", "frequency" : 0 }, { "word" : "thanks", "exp" : "thanks(thanks)", "frequency" : 0 } ], "phrases" : [ { "phrase" : "good afternoon", "exp" : "greeting(good_afternoon)" }, { "phrase" : "how are you", "exp" : "how_are_you" } ] } |
e.g. as CURL
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \ "language" : "en", \ "words" : [ \ { \ "word" : "hello", \ "exp" : "greeting(hello)", \ "frequency" : 0 \ }, \ { \ "word" : "hi", \ "exp" : "greeting(hi)", \ "frequency" : 0 \ }, \ { \ "word" : "bye", \ "exp" : "goodbye(bye)", \ "frequency" : 0 \ }, \ { \ "word" : "thanks", \ "exp" : "thanks(thanks)", \ "frequency" : 0 \ } \ ], \ "phrases" : [ \ { \ "phrase" : "good afternoon", \ "exp" : "greeting(good_afternoon)" \ }, \ { \ "phrase" : "how are you", \ "exp" : "how_are_you" \ } \ ] \ }' 'http://localhost:7070/regulardictionarystore/regulardictionaries' |
See also the API documentation at http://localhost:7070/view#!/configurations/createRegularDictionary
|
b. The API returns with HTTP code 201 an URI in the location header referencing the newly created dictionary
with format eddi://ai.labs.regulardictionary/regulardictionarystore/regulardictionaries/<UNIQUE_DICTIONARY_ID>?version=<DICTIONARY_VERSION>
e.g. eddi://ai.labs.regulardictionary/regulardictionarystore/regulardictionaries/5a26d25817312628b46119f9?version=1
The returned URI is a reference for this specific resource. This recourse will be referenced in the bot definition.
|
See also Behavior Rules
Next, create a behavior rule resource to configure the decision making
a. Make a POST to /behaviorstore/behaviorsets
With an json in the body like this:
{ "behaviorGroups": [ { "name": "Smalltalk", "behaviorRules": [ { "name": "Welcome", "actions": [ "welcome" ], "children": [ { "type": "occurrence", "values": { "maxTimesOccurred": 0, "behaviorRuleName": "Welcome" } } ] }, { "name": "Greeting", "actions": [ "greet" ], "children": [ { "type": "inputmatcher", "values": { "expressions": "greeting(*)", "occurrence": "currentStep" } } ] }, { "name": "Goodbye", "actions": [ "say_goodbye", "CONVERSATION_END" ], "children": [ { "type": "inputmatcher", "values": { "expressions": "goodbye(*)" } } ] }, { "name": "Thank", "actions": [ "thank" ], "children": [ { "type": "inputmatcher", "values": { "expressions": "thank(*)" } } ] }, { "name": "how are you", "actions": [ "how_are_you" ], "children": [ { "type": "inputmatcher", "values": { "expressions": "how_are_you" } } ] } ] } ] } |
See also the API documentation at http://localhost:7070/view#!/configurations/createBehaviorRuleSet
|
b. You should again get a return code of 201 with an URI in the location header referencing the newly created behavior rules
eddi://ai.labs.behavior/behaviorstore/behaviorsets/<UNIQUE_BEHAVIOR_ID>?version=<BEHAVIOR_VERSION>
e.g. eddi://ai.labs.behavior/behaviorstore/behaviorsets/5a26d8fd17312628b46119fb?version=1
See also Output Configuration.
You have guessed correctly, another POST to /outputstore/outputsets create the bot's Output.
With an JSON in the body like this:
{ "outputSet": [ { "action": "welcome", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Welcome!" ] }, { "type": "text", "valueAlternatives": [ "My name is E.D.D.I" ] } ], "quickReplies": [ { "value": "Hi EDDI", "expressions": "greeting(hi)" }, { "value": "Bye EDDI", "expressions": "goodbye(bye)" } ] }, { "action": "greet", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Hi there! Nice to meet up! :-)", "Hey you!" ] } ] }, { "action": "greet", "timesOccurred": 1, "outputs": [ { "type": "text", "valueAlternatives": [ "Did we already say hi ?! Well, twice is better than not at all! ;-)" ] } ] }, { "action": "say_goodbye", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "See you soon!" ] } ] }, { "action": "thank", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Your Welcome!" ] } ] }, { "action": "how_are_you", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Pretty good.. having lovely conversations all day long.. :-D" ] } ] } ] } |
See also the API documentation at http://localhost:7070/view#!/configurations/createOutputSet
|
b. You should again get a return code of 201 with an URI in the location header referencing the newly created output
eddi://ai.labs.output/outputstore/outputsets/<UNIQUE_OUTPUTSET_ID>?version=<OUTPUTSET_VERSION>
e.g. eddi://ai.labs.output/outputstore/outputsets/5a26d97417312628b46119fc?version=1
Now we will align the just created LifecycleTasks in the Package. Make a POST to /packagestore/packages
with a json in the body like this:
{ "packageExtensions": [ { "type": "eddi://ai.labs.normalizer", "config": { "allowedChars": "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ !?:;.,", "convertUmlaute": "true" } }, { "type": "eddi://ai.labs.parser", "extensions": { "dictionaries": [ { "type": "eddi://ai.labs.parser.dictionaries.integer" }, { "type": "eddi://ai.labs.parser.dictionaries.decimal" }, { "type": "eddi://ai.labs.parser.dictionaries.punctuation" }, { "type": "eddi://ai.labs.parser.dictionaries.email" }, { "type": "eddi://ai.labs.parser.dictionaries.time" }, { "type": "eddi://ai.labs.parser.dictionaries.ordinalNumber" }, { "type": "eddi://ai.labs.parser.dictionaries.regular", "config": { "uri": "eddi://ai.labs.regulardictionary/regulardictionarystore/regulardictionaries/<UNIQUE_DICTIONARY_ID>?version=<DICTIONARY_VERSION>" } } ], "corrections": [ { "type": "eddi://ai.labs.parser.corrections.stemming", "config": { "language": "english", "lookupIfKnown": "false" } }, { "type": "eddi://ai.labs.parser.corrections.levenshtein", "config": { "distance": "2" } }, { "type": "eddi://ai.labs.parser.corrections.mergedTerms" } ] }, "config": {} }, { "type": "eddi://ai.labs.behavior", "config": { "uri": "eddi://ai.labs.behavior/behaviorstore/behaviorsets/<UNIQUE_BEHAVIOR_ID>?version=<BEHAVIOR_VERSION>" } }, { "type": "eddi://ai.labs.output", "config": { "uri": "eddi://ai.labs.output/outputstore/outputsets/<UNIQUE_OUTPUTSET_ID>?version=<OUTPUTSET_VERSION>" } } ] } |
See also the API documentation at http://localhost:7070/view#!/configurations/createPackage
|
b. You should again get a return code of 201 with an URI in the location header referencing the newly created package
format eddi://ai.labs.package/packagestore/packages/<UNIQUE_PACKAGE_ID>?version=<PACKAGE_VERSION>
e.g. eddi://ai.labs.package/packagestore/packages/5a2ae60f17312624f8b8a445?version=1
Make a POST to /botstore/bots
with a JSON like this:
{ "packages" : [ "eddi://ai.labs.package/packagestore/packages/<UNIQUE_PACKAGE_ID>?version=<PACKAGE_VERSION>" ], "channels" : [] } |
See also the API documentation at http://localhost:7070/view#!/configurations/createBot
|
b. You should again get a return code of 201 with an URI in the location header referencing the newly created bot
format eddi://ai.labs.bot/botstore/bots/<UNIQUE_BOT_ID>?version=<BOT_VERSION>
e.g. eddi://ai.labs.bot/botstore/bots/5a2ae68a17312624f8b8a446?version=1
Finally, we are ready to let the bot fly. From here on, you have the possibility to let an UI do it for you or you do it step by step.
The UI that automates these steps can be reached here: /chat/unrestricted/<UNIQUE_BOT_ID>
Otherwise via REST:
Include the User Input in the body as application/json (e.g. Hello)
{ "input": "some user input" } |
If you made it till here, CONGRATULATIONS, you have created your first Chatbot with E.D.D.I
By the way you can use the attached postman collection below to do all of the steps mentioned above by clicking send on each request in postman.
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|