Skip to content

How Does the Watson IPA Demo Work

biosopher edited this page Apr 5, 2016 · 10 revisions

Watson IPA Demo Architecture

This graphic shows a rough flow diagram for how the IPA demo interacts with the NLC and Dialog services.

The best place start understanding this diagram is to first read through the documentation on the Watson Natural Language Classifier service and the Watson Dialog service.

Steps #1-3: Capture Input from User

The web page created by index.jade allows users to enter text. When index.jade loads, ipaRemote.js validates that Watson Dialog and NLC services are setup properly. This is the important flow to understand

1 $(document).ready(function()
2 retrieveDialogs() {ensures the Watson Dialog service is ready)
3 retrieveClassifiers() {ensures the NLC service is ready)
4 initConversation() {Calls the Watson Dialog service to start a conversation)

The web pages then waits for the user to press enter or click submit.

$('.input-btn').click(conductConversation);
$userInput.keyup(function(event){
    if(event.keyCode === 13) {
        conductConversation();
    }
});

conductConversation() determines whether the intent received from the NLC is handled locally by the web page or is passed along to Watson Dialog.

displayHumanChat(userIntentText);
if (isDialogRequiredIntent()) {
    handOffToDialog(userIntentText);
}else{
    determineUserIntent(userIntentText);
}

isDialogRequiredIntent() determines whether the intent predicted by NLC is one of the three intent types currently handled by Dialog:

// Intent Types
var INTENT_TYPE_DIALOG_EMAIL = "action-email-create";
var INTENT_TYPE_DIALOG_MEETING = "action-meeting-create";
var INTENT_TYPE_DIALOG_SMS = "action-sms-create";

You can see how the Dialog service handles its intents by looking at ipa-v1.xml.

<item>action-meeting-create *</item>
<item>action-email-create *</item>
<item>action-sms-create *</item>

AJAX calls from the browser are passed to (app.js) running on the server.

The NLC classifier uses the machine-learning-based model we trained earlier to determine which pre-defined classification best matches the user's input and returns the value to us. You can view all the pre-defined classes and training rows in the NLC training file that we used.

Steps #4-5: Respond to User

The pre-defined NLC classification (e.g. action-meeting-create or action-email-create) is pre-pended to the user's text and passed along to the Watson Dialog service. The Dialog service uses this classification to route the user's text to the correct dialog flow within the Dialog XML file that we used earlier when we configured the Watson Dialog service earlier. The Dialog service determines the correct path for the user's input within our Dialog XML file and returns the appropriate response back to the user (step #5) along with additional information (e.g. var-invite_type or var-invite_attendee1).