Reputation: 99
I am building a chatbot in Node.js and have been using aiml-high. I am trying to access the predicates of the AIML so that I can store them in variables which I will use later on. I know that in Python there is a way to get the predicates like so:
name = kernel.getPredicate("name", sessionId)
So, here is my question in more detail. Below is a category from my AIML file.
<category>
<pattern>DO YOU SPEAK <set name="language">*</set></pattern>
<condition name="language">
<li value="english">Yes. I do speak <get name="language"/>.</li>
<li value="English">Yes. I do speak <get name="language"/>.</li>
<li>Sorry. I don't speak <get name="language"/>. Maybe one day I will learn though.</li>
</condition>
</category>
If the user says "Do you speak French", the language, which in this case is "French", is stored here:
<set name="language:>*</set>
Now, the language is remembered and can respond accordingly.
<li>Sorry. I don't speak <get name="language"/>. Maybe one day I will learn though.</li>
...replacing the <get name="language"/>
with the language that the user had input. I would like to access that language predicate in my JavaScript so I can use it later. So, I was wondering if anyone has built a chatbot in Node.js and would have insight as to how I would save these predicates.
Upvotes: 1
Views: 511
Reputation: 99
So, since posting this question I have continued to look through the code for the aiml-high node package. I ended up finding out where the user generated variables are stored and added two new methods to aiml-high.js in the aiml-high node package.
The first method I added is one that returns all of the stored variables:
this.getStoredVariables = function() {
return storedVariableValues;
}
This next method allows you to single out which stored variable that you want returned instead of the entire object.
this.getSpecificStoredVariable = function(v) {
return storedVariableValues[v];
}
So, even though these two methods are simple and most developers would be able to do what I did by just looking through the aiml-high code itself, I hope that someone looking for a similar answer in the future comes across this answer so they don't have to look through the code themselves.
Also, I added a third method to get the bot's attributes.
this.getAttributes = function() {
return botAttributes;
}
Upvotes: 0