Creating a Free Bot with IBM Software
I've written about creating a bot before in "Understanding and Creating ChatBots." In this article, I'll show you how to use software from a more mainstream company, IBM, to build a bot.
As a reminder, a bot is an automated system that operates as an artificial intelligence and natural language recognition to work by responding to a user's queries and requests. Bots generally are intelligent enough to pull meaning from what is asked rather than simply responding to literal requests.
Creating an IBM Cloud Account (a Free One!)
To create a bot using IBM software, you'll first need to create an IBM Cloud account. The bot you build will live and run from this account. If you already have a cloud account, you can skip ahead, otherwise, to create your free account, go to https://cloud.ibm.com/. You'll be greeted with a screen like Figure 1.
Figure 1: Welcome to IBM Cloud
Fill out the information to create your free IBM Cloud account. Once you've been thanked as shown in Figure 2, you can confirm your new account via an email that will be sent to you. Once you confirm via the email that is sent, you'll receive a "Success!" message similar to the "Thanks" message.
Figure 2: Confirmation of registration for IBM Cloud
Once your IBM Cloud account has been created, you'll be able to log into it. Your IBM ID will be the email you used to create the account. The first time you log in, you'll need to acknowledge IBM's privacy statement in order to proceed. Once you do proceed, you will be taken to the IBM Cloud dashboard, which should be similar to what is shown in Figure 3. With your cloud access in place, you'll be ready to get to work on a bot!
Figure 3: The IBM Cloud Dashboard
Building the IBM Chat Bot
It is important to note that another name for a bot is an Assistant. With IBM, the word "assistant" will be used instead of bot. In this article, you can consider the two words as interchangeable.
To create your assistant, start by clicking on the Create resource button on the upper right side of the dashboard. This will open the catalog of resources that can be created. A bot or assistant use artificial intelligence, so you'll select the AI from the left list. This will display the various AI options as shown in Figure 4.
Figure 4: The AI Options
From the AI options, select Watson Assistant. This will display a screen as shown in Figure 5 for creating a service that will contain your bot (aka assistant).
Figure 5: Setting up an Assistant Service
Give your service a name and then click the Create button. I've named my service "My Test Assistant." Once you hit create, you'll be taken a page similar to Figure 6, which is where you'll being building your bot.
Figure 6: Building the bot.
Click the Launch tool button to begin. This will display a page with instructions for building your assistant. Scroll down to the Create a Skill button to begin the process. Clicking on this button will start the process of creating a skill, which will contain items that define your assistant's conversation and interaction with the user. This will take you to a Skills page that will start the process of creating a new skill.
You'll need to click on the Create new button on this page, which will then present the dialog you see in figure 7. Note that I didn't show screen shots of the previous two steps because they are simply clicking a button to move forward. I'm not exactly sure why these steps were required by IBM since they didn't seem to do much!
Figure 7: The Add Dialog Skill window
Give your skill a name. I've named my skill "My Example Skill." If you are using a language other than English, you can change this in the Language drop down. You can also add an optional description. Once done, click Create. This will create the skill dialog and take you to the Intents dialog.
The intents will be used to define the various ways that users will interact with your assistant. You can add new intents, browse existing intents, or import intents from elsewhere. After setting up your intents, you'll create dialogs to use with them. IBM provides a number of existing intents that you can use for your assistant, so for creating the sample assistant, you'll use an existing intent. Select the Browse content catalog button, which will display a list of existing intents similar to Figure 8.
Figure 8: IBM Assistant Intents (I added red highlight)
As you can see in the dialog, there are several existing intents that align with various areas you might want your assistant to interact. These range from Banking to Utilities. For the example you are creating here, select the General intent. If you click on "General" in the list on the left side, you will see a list of specific intents. For now, however, click on the Add to skill button on the right side of the table. When you do this, a small dialog will pop up saying you added 10 intents to your project.
With the skills added, you can now click on the Intents tab in the dialog to show the intents in you assistant. You'll see that several are now listed as shown in Figure 9.
Figure 9: The intents in the "My Example Skill" project
The items listed in Figure 9 are skills that you've now included in your assistant. You can see that these include things such as a greeting, an ending, and jokes. Each of these items include functionality that is prebuilt by IBM.
With the skills in place, the next step is to build the dialog that your assistant will use. The dialog is the flow of conversation that will happen between the AI and the user. When the user interacts with the assistant, they will indicate an intent. These intents will be matched by the AI to the intents you've included (figure 9).
To create the dialog, start by clicking on the Dialog tab (two items over from the Intents tab also shown in Figure 9. This will open the dialogs page. On the page shown, click on the Create button to create your first dialogs as shown in Figure 10.
Figure 10: Creating an IBM assistant dialog
Two nodes are included in the initial dialogs that are created. The Welcome dialog is used when the user first interacts with the assistant. The Anything else box is a default dialog that is used whenever the user provides input that is not recognized. You'll be able to add additional nodes to handle specific interactions.
The Welcome node is special. It is kicked off when the user first interacts with your assistant. Other nodes will kick off when there is a match with the intention. The default Welcome node displays a message. You can update this message by clicking on the node in the dialog. This will display the screen shown in Figure 11.
Figure 11: Customizing the Welcome message
You can add a new welcome message by clicking on the "Enter response variation" text and typing. You can see in Figure 11 that a new welcome message was added to the sample. You can remove the defaulted message by clicking the dash in the circle to the right of the message. You can enter more than one response and allow them to e used sequentially or randomly.
With the text updated, you can click the X on the upper right of the dialog to go back to the nodes page.
While your bot could now welcome a person with a message, you'll likely want it to do more! To do more, you need to add a new dialog node. To add a new node, you can click on the New node button. Alternatively, you can click on the three vertical dots on the right side of the Welcome node, which will display a menu for adding a new node. This will add a new node with no condition included as shown in Figure 12.
Figure 12: A new node added to your dialog
Select the new node by clicking on it. This will allow you to edit its functionality. Earlier you included the #General intents, so you can take advantage of that now. In the new node dialog, you can enter one of the intents that you saw in Figure 8. Enter this into the intent line as shown in Figure 13.
Figure 13: Adding the #General_Jokes intent
In addition to adding #General_Jokes into the dialog, three responses were also added in the same way the welcome message was changed earlier. You can see this in Figure 13. Once you've added the intent and any jokes you like (the jokes are responses), click the X button to save the changes.
With your Welcome and Joke nodes in place, it is a good time to test your assistant. You can do this by clicking on the Try it button on the upper right corner of the window. This will display the test dialog as shown in Figure 14.
Figure 14: Testing your IBM Assistant
In your test, you should see the text you entered in the Welcome dialog back in Figure 11. You can interact with your assistant by typing in the lower left area where it says, "Enter something to test your virtual assistant." Because you entered the Joke intention, you can enter "Tell me a Joke." The assistant should recognize this and associate it to your #General Jokes node and tell one of the jokes that were entered as a response in Figure 13. The testing will tell you which dialog node was used for its response. If it doesn't recognize something, you'll see that it responds with a different node. Figure 15 shows the interaction with my sample.
Figure 15: Testing my example Bot
You can click "clear" at the top of the testing area to clear the test and start over. You can click the X to close it and go back to the dialog display.
To further the test, add an additional node to the dialog. This time, with the #General_Jokes node selected, click the Add node button to add a new after it. Add #General_Ending as the Intent condition and "Thanks for Visiting! Talk to you next time!" as the response. This is shown in Figure 16. Now if you say "bye," "See ya," "later" or some other message indicating you are leaving, you'll get the general ending response!
Figure 16: The #General_Ending dialog.
At this point, you've set up the features for an IBM bot assistant. By using the Try It button, you can interact with your assistant to see how it responds. In the next article, you'll see how to take what you've built and create a stand-alone assistant that you can also embed in your site or use elsewhere.