[alicebot-general] Setting predicates to value of a variable
Noel Bush
noel at aitools.org
Fri Apr 28 17:13:56 PDT 2006
In this case you may wish to ask on the pandorabots mailing list. AIML
does not provide any specification for how to assign predicate values
from the "client side" through any means other than regular pattern
matching (it does not really define anything like "client side" in any
case, since the client/server distinction doesn't always hold).
Please note that the server-side <javascript/> element included in the
AIML spec has no relation to client-side javascript that you may include
in a template as you've shown below.
Also, when you do:
document.write("<set name="topic">Hi. What is your name</set>");
This just writes some markup to the HTML page which will be ignored and
not displayed by the browser. It doesn't somehow "feed back" to the
AIML interpreter (unless Pandorabots provides some kind of
postprocessing of the output HTML, which it might well, I don't know).
I suppose you could try to do something really weird like send, from
javascript, a user input to the bot that would match a specially
constructed category that could set a predicate value for you. But it
would be a pain (you'd need a special category for each predicate, since
predicate names cannot be computed dynamically).
I would suggest either submitting a feature request for Pandorabots to
provide some kind of "Ajax"-like capability like what I described below.
Or maybe somebody else (a developer of one of the many other AIML
interpreters) has another idea. What we're really looking at here is
whether there should be / could be some kind of standardized AIML API, I
guess.
Noel
Alan Haymes wrote:
> I should have said that I was using Pandorbots and my javascript is within an
> aiml category therefore presumably client side.
>
> My code is below (the line giving me the problem is in bold):
>
> <category><pattern>HI</pattern>
> <template>
> <script language="JavaScript">
> function get_cookie ( cookie_name )
> {
> var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );
>
> if ( results )
> return ( unescape ( results[1] ) );
> else
> return null;
> }
>
> if ( ! get_cookie ( "visitor" ) )
> {
> document.write("<set name="topic">Hi. What is your name</set>");
> }
> else
> {
> var visitor = get_cookie ( "visitor" );
> document.write ( "Hi " + visitor + ", welcome back to my website!" );
> }
> </script>
> <set name="name"><javascript>visitor</javascript></set>
> </template>
> </category>
>
>
> --
> View this message in context: http://www.nabble.com/Setting-predicates-to-value-of-a-variable-t1523359.html#a4142994
> Sent from the Alicebot General forum at Nabble.com.
>
> _______________________________________________
> This is the alicebot-general mailing list
> Reply to alicebot-general at list.alicebot.org
> Unsubscribe and change preferences at http://list.alicebot.org/mailman/listinfo/alicebot-general
> Learn netiquette at http://www.dtcc.edu/cs/rfc1855.html
> Learn to read at http://www.literacy.org/
More information about the alicebot-general
mailing list