KB113: Using the GetURL action with AIML

One application of AIML chatbots is to let a character help guide a user through a website. Since the AIML template portion of a rule can contain any character actions, the easiest way to do this is to use a <geturl/> action. Consider the following AIML rule:

You can see this in action here.

To download the sources, unzip kb113.zip to a Documents\Character Builder Projects\KB113 directory, open the project in Character Builder, and do a Render to Flash followed by a View in Browser. You must have installed and configured the Character Server on your development machine in order to run this locally. To view the complete project you should run the 'frameset.html' file, in order to demonstrate a geturl that affects a second frame.

This sample shows a few variations on the <geturl/> action.

Consider the REPLACE rule in the KB113Rules file. The template portion of the rule reads:

Ok, I will replace my page with a new one. <geturl url="'ReplacePage.html'"/>

Without a target, the new page replaces the page with the flash file. The new page might also have a Character Builder project, possibly even the same project. In the FRAME rule we add as target the name of a second frame beside the character:

Ok, I will bring up a page <lookleft/> in this frame. <pause/> <geturl url="'FramePage.html'" target="'mainframe'"/>

If you specify '_blank' as a target then it is assumed to be a secondary window.

Ok, I will open a secondary window for you. <geturl url="'SecondaryPage.html'" target="'_blank'"/>

Popup windows require that your user enable popups in their browser. To get full control over the popup window you can trigger a javascript event in the containing page, as follows:

Ok, I will popup another window for you. <geturl url="'javascript:doPopup()'"/>

Then, in the containing page, you can use a block of script such as:

<script type="text/javascript"> function doPopup() { win = window.open('PopupPage.html',null,'toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,width=400,height=275,top=100,left=100'); win.focus(); } </script>

However for the last version to work you must be running your project through a virtual directory, such as:

http://localhost/projects/kb113/output/frameset.html

The reason for this is that the Flash stream containing the geturl action is generated from a url of the form 'http://localhost/cs/cs.exe', which would be in a different domain from your containing file if you simply run the latter directly from the file system.







Copyright © 2008 Media Semantics, Inc. All rights reserved.
Comments? Write webmaster@mediasemantics.com. See also our privacy policy.