As Covid-19 numbers continue to rise, you might wonder about your chance of contracting the virus. In this tutorial, learn how to build a chatbot that will assess your risk of getting infected with Covid-19 using the E.D.D.I Operator hosted on Red Hat Marketplace.
About the E.D.D.I Operator
E.D.D.I is an enterprise-ready chatbot platform that enables you to create and maintain customizable chatbots. It has a resource-oriented design and RESTful architecture which is easy to scale. A natural language processing parser matches user inputs as words and phrases and Behavior Rules assist in making decisions with predefined and custom conditions.
Learning objectives
After completing this tutorial, you will understand how to:
- Install the E.D.D.I Operator from Red Hat Marketplace on an OpenShift cluster
- Create an E.D.D.I chatbot instance
- Build a chatbot from scratch with the E.D.D.I operator
Estimated time
Completing this tutorial should take about 30 minutes.
Prerequisites
To complete the steps in this tutorial, you need to install the following:
Steps
- Configure a Red Hat OpenShift Cluster with Red Hat Marketplace
- Deploy a E.D.D.I operator to an OpenShift cluster
- Create an instance
- Create a chatbot in E.D.D.I
- Access the E.D.D.I Dashboard to manage the chatbot
- Explore the chatbot
Step 1. Configure a Red Hat OpenShift Cluster with Red Hat Marketplace
Follow the steps in this tutorial to configure a Red Hat OpenShift cluster and connect to the cluster using your command line interface (CLI): Configure a Red Hat OpenShift cluster hosted on Red Hat Marketplace.
Step 2. Deploy the E.D.D.I operator to an OpenShift cluster
Follow these steps to deploy the E.D.D.I operator to an OpenShift cluster.
Visit the Red Hat Marketplace catalog and search for “E.D.D.I”. Select
E.D.D.I
from the results.The E.D.D.I product page provides an overview, documentation, and pricing options associated with the product. Click the Free Trial button.
Next, the purchase summary will show the
Subscription term
and total cost is $0.00. Click Start trial.You can visit Workspace > My Software to view your list of purchased software.
Back in the web dashboard, select the E.D.D.I tile and click the Operators tab. Select the Install Operator button.
Leave the default selection for Update channel and Approval strategy. Select the cluster and namespace scope as
eddi-project
for the operator, and click Install.You should see a message that indicates the install process initiated in the cluster.
Step 3: Create an instance
Log into your OpenShift cluster. From the left navigation, click Operators and select Installed Operators to confirm the installation was successful. You should see the E.D.D.I Operator listed under the project/namespace
eddi-project
.On the E.D.D.I. operator screen, navigate to Provided APIs and select the first Create Instance.
The E.D.D.I page displays with the default YAML. Edit the
storageclass_name
in the YAML file and click on the Create button. If the default YAML file is not visiblie, you can copy and paste the following YAML file to replace thestorageclass_name
.apiVersion: labs.ai/v1alpha1 kind: Eddi metadata: name: eddi spec: size: 1 mongodb: environment: prod storageclass_name: <existing_storageclass> storage_size: 20G
E.D.D.I Operator pods should come up when the installation is completed.
Under the left panel, select Networking > Routes. Make sure you are in the
eddi-project
namesapace. You should now see theeddi-route
with a URL that starts with http://eddi-route-test.Click on that URL under the location to access the E.D.D.I Dashboard.
Step 4: Create a chatbot in E.D.D.I
Now, let’s create a chatbot in E.D.D.I from scratch. To create the chatbot, you will have to complete these steps:
- Create a regular dictionary
- Create behavior rules
- Create output sets
- Package your dictionary, rules, and sets
- Create a chatbot
In order to build a Chatbot with E.D.D.I, you will have to create a few configuration files and POST them to the corresponding REST APIs. You can use tools like Postman to make the API calls.
Step 4.1: Create a regular dictionary
Regular dictionaries are used store custom words and phrases in artifical intelligence systems.
Make a POST
to <eddi-url>/regulardictionarystore/regulardictionaries
with a JSON file in the body as follows.
Note: You will use the
<eddi-url>
generated in step 1.
In Postman, enter the <eddi-url>
followed by /regulardictionarystore/regulardictionaries
. Make sure you select the following parameters:
- Select the request type to be
POST
- Select
Body
- Select
raw
- Select type as
JSON
Copy and paste the JSON body given below:
{ "words": [ { "word": "hello", "expressions": "greeting(hello)", "frequency": 0 }, { "word": "hi", "expressions": "greeting(hi)", "frequency": 0 }, { "word": "bye", "expressions": "goodbye(bye)", "frequency": 0 }, { "word": "take test", "expressions": "taketest(yes)", "frequency": 0 }, { "word": "thanks", "expressions": "thanks(thanks)", "frequency": 0 } ], "regExs": [], "phrases": [ { "phrase": "good afternoon", "expressions": "greeting(good_afternoon)" }, { "phrase": "how are you", "expressions": "how_are_you" } ] }
Click the Send button to make the request. If your request is sucessful, you will see a status:
201 Created
in your postman.- Click on the
Headers
to view the response You can see a
Location
header with a URL something likeeddi://ai.labs.regulardictionary/regulardictionarystore/regulardictionaries/<UNIQUE_DICTIONARY_ID>?version=<UNIQUE_DICTIONARY_VERSION>
. Make a note of the<UNIQUE_DICTIONARY_ID>
as shown.
Note: The
<UNIQUE_DICTIONARY_ID>
will be used to package the elements of the chatbot, so please make a note of it.
Step 4.2: Create behavior rules
Behavior rules are are a series of defined rules by the developer of the bot. These rules are used to answer to the queries asked by the user.
To create behavior rules, you will make a POST
to <eddi-url>/behaviorstore/behaviorsets
with a JSON file in the body as follows.
Note: You will use the
<eddi-url>
generated in step 1.
In Postman, enter the <eddi-url>
followed by /behaviorstore/behaviorsets
. Make sure you select the following parameters:
- Select the request type to be
POST
- Select
Body
- Select
raw
- Select type as
JSON
Copy and paste the JSON body given below
{ "behaviorGroups": [ { "name": "Smalltalk", "behaviorRules": [ { "name": "Welcome", "actions": [ "welcome" ], "conditions": [ { "type": "occurrence", "configs": { "maxTimesOccurred": "0", "behaviorRuleName": "Welcome" } } ] }, { "name": "Greeting", "actions": [ "greet" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "greeting(*)", "occurrence": "currentStep" } } ] }, { "name": "Taketest", "actions": [ "taketest" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "taketest(*)", "occurrence": "currentStep" } } ] }, { "name": "Symptom 1", "actions": [ "symptomone", "CONVERSATION_END" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "symptomone(*)", "occurrence": "currentStep" } } ] }, { "name": "Safe", "actions": [ "safe", "CONVERSATION_END" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "safe(*)", "occurrence": "currentStep" } } ] }, { "name": "Semi Safe", "actions": [ "semisafe", "CONVERSATION_END" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "semisafe(*)", "occurrence": "currentStep" } } ] }, { "name": "Semi Risk", "actions": [ "semirisk", "CONVERSATION_END" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "semirisk(*)", "occurrence": "currentStep" } } ] }, { "name": "Symptom 2", "actions": [ "symptomtwo" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "symptomtwo(*)", "occurrence": "currentStep" } } ] }, { "name": "Symptom 2a", "actions": [ "symptomtwoa" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "symptomtwoa(*)", "occurrence": "currentStep" } } ] }, { "name": "Symptom 2b", "actions": [ "symptomtwob" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "symptomtwob(*)", "occurrence": "currentStep" } } ] }, { "name": "Symptom 2c", "actions": [ "symptomtwoc" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "symptomtwoc(*)", "occurrence": "currentStep" } } ] }, { "name": "Symptom 3", "actions": [ "symptomthree" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "symptomthree(*)", "occurrence": "currentStep" } } ] }, { "name": "Goodbye", "actions": [ "say_goodbye", "CONVERSATION_END" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "goodbye(*)" } } ] }, { "name": "Thank", "actions": [ "thank" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "thank(*)" } } ] }, { "name": "how are you", "actions": [ "how_are_you" ], "conditions": [ { "type": "inputmatcher", "configs": { "expressions": "how_are_you" } } ] } ] } ] }
- Click the Send button to make the request. If your request is successful, you will see a status:
201 Created
in your postman. - Click on the
Headers
to view the response. - You can see a
Location
header with a URL something likeeddi://ai.labs.behavior/behaviorstore/behaviorsets/<UNIQUE_BEHAVIOR_ID>?version=<BEHAVIOR_VERSION>
. Make a note of the<UNIQUE_BEHAVIOR_ID>
as shown.
- Click the Send button to make the request. If your request is successful, you will see a status:
Note: The
<UNIQUE_BEHAVIOR_ID>
will be used in Packaging, please make a note of it.
Step 4.3: Create output sets
Output is defined to answer the users’ request based on the results from the behavior rule execution.
Make a POST
to <eddi-url>/outputstore/outputsets
with a JSON in the body as follows.
Note: You will use the
<eddi-url>
generated in step 1.
In Postman, enter the <eddi-url>
followed by /outputstore/outputsets
, make sure you select the following parameters:
- Select the request type to be
POST
- Select
Body
- Select
raw
- Select type as
JSON
Copy and paste the JSON body given below
{ "outputSet": [ { "action": "welcome", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Hi!, I am COVID-19 Chatbot" ] }, { "type": "text", "valueAlternatives": [ "Visit https://www.mohfw.gov.in/ to get more information regarding COVID-19 in India" ] }, { "type": "text", "valueAlternatives": [ "I will assess you today!" ] } ], "quickReplies": [ { "value": "Sounds Good!", "expressions": "taketest(yes)" }, { "value": "No Thanks I'm Fine.", "expressions": "goodbye(bye)" } ] }, { "action": "greet", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Hi there! Nice to meet up! :-)", "Hey you!" ] } ], "quickReplies": [] }, { "action": "taketest", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Are you experiencing any of the following symptoms?" ] }, { "type": "text", "valueAlternatives": [ "• severe difficulty breathing (for example, struggling for each breath, speaking in single words) \n • severe chest pain \n • having a very hard time waking up \n • feeling confused \n • lost consciousness" ] } ], "quickReplies": [ { "value": "YES", "expressions": "symptomone(yes)" }, { "value": "NO", "expressions": "symptomtwo(yes)" } ] }, { "action": "symptomone", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Self-assessment result: AT RISK!" ] }, { "type": "text", "valueAlternatives": [ "Please call 104 or 97456-97456 Immediately" ] } ], "quickReplies": [] }, { "action": "symptomtwo", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Are you experiencing any of the following symptoms (or a combination of these symptoms)?" ] }, { "type": "text", "valueAlternatives": [ "• fever \n • new cough \n • difficulty breathing (for example, struggling for each breath, cannot hold breath for more than 10 seconds)" ] } ], "quickReplies": [ { "value": "YES", "expressions": "symptomtwoa(yes)" }, { "value": "NO", "expressions": "symptomthree(yes)" } ] }, { "action": "symptomtwoa", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Have you travelled outside of India in the last 1 Month?" ] } ], "quickReplies": [ { "value": "YES", "expressions": "semirisk(yes)" }, { "value": "NO", "expressions": "symptomtwob(yes)" } ] }, { "action": "symptomtwob", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Does someone you are in close contact with have COVID-19 (for example, someone in your household or workplace)?" ] } ], "quickReplies": [ { "value": "YES", "expressions": "semirisk(yes)" }, { "value": "NO", "expressions": "symptomtwoc(yes)" } ] }, { "action": "symptomtwoc", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Are you in close contact with a person who is sick with respiratory symptoms (for example, fever, cough or difficulty breathing) who recently travelled outside of India?" ] } ], "quickReplies": [ { "value": "YES", "expressions": "semirisk(yes)" }, { "value": "NO", "expressions": "semisafe(yes)" } ] }, { "action": "symptomthree", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Are you experiencing any of the following symptoms (or a combination of these symptoms)?" ] }, { "type": "text", "valueAlternatives": [ "• muscle aches \n • fatigue \n • headache \n • sore throat \n • runny nose" ] } ], "quickReplies": [ { "value": "YES", "expressions": "symptomtwoa(yes)" }, { "value": "NO", "expressions": "safe(yes)" } ] }, { "action": "safe", "timesOccurred": 1, "outputs": [ { "type": "text", "valueAlternatives": [ "Self-assessment result: SAFE" ] }, { "type": "text", "valueAlternatives": [ "It is unlikely that you have COVID-19." ] } ], "quickReplies": [] }, { "action": "semisafe", "timesOccurred": 1, "outputs": [ { "type": "text", "valueAlternatives": [ "Self-assessment result: MOSTLY SAFE" ] }, { "type": "text", "valueAlternatives": [ "It is unlikely that you have COVID-19 but you should self-isolate at home until you are symptom-free." ] } ], "quickReplies": [] }, { "action": "semirisk", "timesOccurred": 1, "outputs": [ { "type": "text", "valueAlternatives": [ "Self-assessment result: MOSTLY AT RISK" ] }, { "type": "text", "valueAlternatives": [ "Please seek clinical assessment for COVID-19 over the phone." ] } ], "quickReplies": [] }, { "action": "greet", "timesOccurred": 1, "outputs": [ { "type": "text", "valueAlternatives": [ "Did we already say hi ?! Well, twice is better than not at all! ;-)" ] } ], "quickReplies": [] }, { "action": "say_goodbye", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "See you soon!" ] } ], "quickReplies": [] }, { "action": "thank", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Your Welcome!" ] } ], "quickReplies": [] }, { "action": "how_are_you", "timesOccurred": 0, "outputs": [ { "type": "text", "valueAlternatives": [ "Pretty good.. having lovely conversations all day long.. :-D" ] } ], "quickReplies": [] } ] }
- Click the Send button to make request. On successful requests, you can see a status:
201 Created
in your Postman. - Click on the
Headers
to view the response - You can see a
Location
header with a URL something likeeddi://ai.labs.output/outputstore/outputsets/<UNIQUE_OUTPUTSET_ID>?version=<OUTPUTSET_VERSION>
. Make a note of the<UNIQUE_OUTPUTSET_ID>
as shown.
- Click the Send button to make request. On successful requests, you can see a status:
Note: The
<UNIQUE_OUTPUTSET_ID>
will be used in Packaging, please make a note of it.
Step 4.4: Packaging
Now that you’ve created the dictionary, behavior rules, and output sets, you should align them in the package.
Make a POST
to <eddi-url>/packagestore/packages
with a JSON in the body as follows.
Note: You will use the
<eddi-url>
generated in step 1.
In Postman, enter the <eddi-url>
followed by /packagestore/packages
, make sure you select the following parameters:
- Select the request type to be
POST
- Select
Body
- Select
raw
- Select type as
JSON
Copy and paste the JSON body given below replacing it with the
<UNIQUE_DICTIONARY_ID>
,<UNIQUE_BEHAVIOR_ID>
and<UNIQUE_OUTPUTSET_ID>
copied from step 2.1, step 2.2 and step 2.3{ "packageExtensions": [ { "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>" } } ] }
Click the Send button to make a request. If it succeeds, you should see a status:
201 Created
in your postman- Click on the
Headers
to view the response - You can see a
Location
header with a URL something likeeddi://ai.labs.package/packagestore/packages/<UNIQUE_PACKAGE_ID>?version=<PACKAGE_VERSION>
. Make a note of the<UNIQUE_PACKAGE_ID>
and<PACKAGE_VERSION>
as shown.
Note: The
<UNIQUE_PACKAGE_ID>
and<PACKAGE_VERSION>
will be used in creating a Bot, please make a note of it.
Step 4.5: Create a chatbot
Now it’s time to build a chatbot that will use the different packages and channels.
POST
to <eddi-url>/packagestore/packages
with a JSON file in the body as follows.
Note: You will use the
<eddi-url>
generated in step 1.
In Postman, enter the <eddi-url>
followed by /packagestore/packages
, make sure you select the following parameters:
- Select the request type to be
POST
- Select
Body
- Select
raw
- Select type as
JSON
Copy and paste the JSON body below, replacing it with the
<UNIQUE_PACKAGE_ID>
and<PACKAGE_VERSION>
copied from step 2.4.json { "packages": [ "eddi://ai.labs.package/packagestore/packages/<UNIQUE_PACKAGE_ID>?version=<PACKAGE_VERSION>" ], "channels": [] }
Click the Send button to make the request. Once your request succeeds, you will see a status message that says:
201 Created
in your Postman.- Click on the
Headers
to view the response. - You can see a
Location
header with a URL. The URL will be similar to this:eddi://ai.labs.bot/botstore/bots/<UNIQUE_BOT_ID>?version=<BOT_VERSION>
. Make a note of the<UNIQUE_BOT_ID>
and<BOT_VERSION>
.
Note: The
<UNIQUE_BOT_ID>
and<BOT_VERSION>
will be used to check the status of the Bot, please make a note of it.
Step 4.6: Check the status of the deployment
To check the deployment status of the chatbot, make a GET
API call to <eddi-url>/administration/unrestricted/deploymentstatus/<UNIQUE_BOT_ID>?version=<BOT_VERSION>
.
You can expect a NOT_FOUND
, IN_PROGRESS
, ERROR
and READY
message to be returned in the body. As soon as the chatbot is deployed and has a READY
status, you can invoke it and start using it.
Step 5: Access the E.D.D.I Dashboard to manage the chatbot
To see the results of the commands you ran in the earlier steps, access the E.D.D.I dashboard using the URL you obtained in step 1.
In the dashboard, click on Go to Bot Manager as shown.
In the Bot Manager in your E.D.D.I dashboard, you can see the Conversation ID of the chatbot that you deployed through API calls.
Rename the chatbot to avoid ambiguity. Click on the three-dot menu and select Rename.
Give the chatbot a meaningful name such as
Covid19 helth check chatbot
and save it.Finally to interact with the chatbot, click Open Chat.
Step 6: Explore the chatbot
You can see the chatbot in action once you are in the chat window.
The chatbot asks you a set of standard questions to assess your risk of getting infected to COVID-19. You can answer the questions to self assess yourself or share the link with your family and friends to help them take the assessment.
Summary
Hopefully you now have an understanding of how to build an E.D.D.I Operator hosted on Red Hat Marketplace.
Reference
You can refer the following documentation from E.D.D.I labs to learn more about the operator and its features.