Chat with the bot - Edit the test script - View the recent chats.
This bot uses SchoolMapperArguments.txt and YesNo.txt, and maps the user's input to an appropriate type.
/* class=gwtchat.server.JavascriptBot */
var argumentCategorizer = Transformer.recall(wiki, 'SchoolMapperArguments.txt');
var yesNoTransformer = Transformer.recall(wiki, 'YesNo.txt');
/* Greeting for a new user: */
function greet(chatter) {
chat.say("Hi, "+chatter.name+"! <br/>"+
" Please select a location for a school on the map: <br/>" +
" <img src='http://farm1.static.flickr.com/28/57610620_66f7f80692_o.jpg' style='width:100px; height:100px' /> <br/>" +
"Please also explain why you chose this spot.");
}
/* Main algorithm: */
function hear(chatter, message) {
var yesNoTag = yesNoTransformer.transform(message);
if (yesNoTag && yesNoTag.length()>0) {
chat.say("You just said something that means '"+yesNoTag+"'");
return;
}
var argumentType = argumentCategorizer.transform(message);
if (argumentType && argumentType.length()>0 && argumentType!='noargument') {
chat.say("I see, you think "+argumentType+".");
return;
}
chat.say("Sorry, I didn't understand your argument ("+argumentType+"). Please say this in different words.");
}
End of bot SchoolMapper.js