Aigents server configuration and web API use
Aigents server configuration
The following procedure describes configuration of Aigents server operating in command-line (so called “Aigents Farm”) mode with no user interface.
Download Aigents.jar file from http://aigents.com/en/products.html and copy it to binary folder, for example - /var/www/aigents/bin
Disable access to binary folder to web users so its content could not be opened by web server
Download Aigents web files from http://aigents.com/ui/aigents-wui.zip and unzip them to web folder, for example - /var/www/aigents/html
Configure web server, so it points to index.html file in web folder, for example - aigents.mysite.org pointing to /var/www/aigents/html/index.html
Edit aigents-wui.js file, changing the line
var base_url = "http://cigents.com:1180";
to your web site internet address domain and port intended to host Aigents API, for example
var base_url = "http://aigents.mysite.org:1180";
Configure port intended to host Aigents API (for exampe - 1180) so it is made available for access from the internet (or intranet if you are going to access Aigents locally)
Download Oracle Java Mail bundle from http://www.oracle.com/technetwork/java/javamail/index.html and copy its mail.jar file to binary folder (for current example - /var/www/aigents/bin)
Start Aigents server in binary folder:
#java -cp .:Aigents.jar:mail.jar net.webstructor.agent.Farm -Xms128m -Xmx256m
Setup administrative account (need to fill properties name, surname, email, birth date, secret question, secret answer) - from Aigents command line interface:
I:Started TCP at 1123.
I:Started HTTP at 1180.
my name admin
Login:name admin.
I:What your email, surname, birth date?
my email admin@mysite.org
Login:email admin@mysite.org, name admin.
I:What your surname, birth date?
my surname admini, birth date 1/1/2001
Login:birth date 1/1/2001, email admin@mysite.org, name admin, surname admini.
I:What your secret question, secret answer?
my secret question password, secret answer 12345
I:What your password?
my password 12345
...
I:Ok. Hello Admin Admini!
My Aigents 1.0.9 Copyright 2014 Anton Kolonin, Aigents Group.
Setup web API for access via http protocol, filling properties http origin, http port, cookie domain, cookie name (port 1180 for our exampe) - from Aigents command line interface:
your http origin http://aigents.mysite.org, http port 1180, cookie domain aigents.mysite.org, cookie name myaigent.
...
I:Ok.
what your http origin, http port, cookie domain, cookie name?
...
I:My cookie domain aigents.mysite.org, cookie name myaigent, http origin http://aigents.mysite.org, http port 1180.
Setup email account for access via email (POP3 and SMTP) and for sending notifications (SMTP), filling properties email, email login, email password, mail.pop3s.host, mail.smtp.host (for example, based on mysite.org) - from Aigents command line interface:
your email aigent@mysite.org, email login aigent, email password qwerty, mail.pop3s.host mail.mysite.org, mail.smtp.host mysite.org.
...
what your email, email login, email password, mail.pop3s.host, mail.smtp.host?
...
My email aigent@mysite.org, email login aigent, email password 'qwerty', mail.pop3s.host mail.mysite.org, mail.smtp.host mysite.org.
Setup TCP/IP port for telnet terminal access, filling tcp port property (for example, port 1123) - from Aigents command line interface:
your tcp port 1123
I:Ok.
what your tcp port?
...
I:My tcp port 1123.
Exit Aigents server altogether with command-line interface:
bye
...
#Connection closed by foreign host.
Start Aigetns over per step 8 above, but now better using screen or nohup Linux commands so that server keeps running uninterruptedly upon current console session termination.
For remote control of Aigents server from console, use the tcp/ip port specified above to connect to Aigents via telnet:
$ telnet aigents.mysite.org 1123
Trying 111.22.0.33...
Connected to aigents.mysite.org.
Escape character is '^]'.
my name admin
What your password?
my password 12345
Ok. Hello Admi Admini!
My Aigents 1.0.9 Copyright © 2014 Anton Kolonin, Aigents®.
Aigents web API use
The following describes access to Aigents server operating in command-line (so called “Aigents Farm” mode) by means of its web API over http protocol – for the purpose of Web monitoring and news collection.
Authentication is based on cookies (configured with properties cookie domain and cookie name, as described above). That is, respective fields of the HTTP header should be filled.
When Aigents server parses the HTTP request, it reads Cookie field of HTTP header. If filled in, it keeps it to maintain the session. If not filled in, it generates new one to create new session.
When Aigents server builds the HTTP response, it fills Set-Cookie field of HTTP header with value of existing on newly created session cookie.
On the client side, the sessions and cookies may be maintained, for example, with PEST wrapper of CURL functions (https://github.com/educoder/pest), like in the following example:
$baseURL = "http://aigents.mysite.org:1180/?";
$cookie;
function url_pest( $url ) {
global $baseURL, $cookie;
$pest = new Pest($baseURL);
try {
$url = $baseURL.urlencode($url);
if (isset($cookie)) {
$pest->curl_opts[CURLOPT_COOKIE] = $cookie;
}
$result = $pest->get($url);
$cookie=$pest->last_headers['set-cookie'];
unset($pest);
return $result;
} catch( Exception $e ) {
unset($pest);
throw($e);
}
}
Requests and response are currently processed as HTTP GET requests, so the response is submitted to URL including domain name and optional port, followed by slash and question mark with following URI-encoded text of complete statement in Agent Language, to be parsed accordingly to language defintion (http://aigents.com/papers/2014AgentLanguageKolonin.pdf) while response is written to the stream, for example – the authentication is done as shown below.
INPUT: http://aigents.mysite.org:1180/?my%20name%20admin
OUTPUT: What your password?
INPUT: http://aigents.mysite.org:1180/?my%20password%2012345
OUTPUT: Ok. Hello Admi Admini! My Aigents 1.0.9 Copyright © 2014 Anton Kolonin, Aigents Group.
Operations with sites, things and news used for web monitoring are performed accordingly to belief ontology of Aigents for Web (http://aigents.com/papers/2014AgentWatchingKolonin.pdf), as described below. All of the following operations are possible after user is authenticated (logged in).
Listing sites is done with “my sites ...” statement, for example:
http://aigents.mysite.org:1180/?what%20my%20sites?
Your sites http://money.cnn.com/data/markets/dow/, http://wired.com, http://www.nytimes.com/pages/business/, http://www.reuters.com/.
Listing things is done with “my topics ...” statement, for example:
http://aigents.mysite.org:1180/?what%20my%20topics?
Your topics “goole $topic”, “dow jones $value”.
Listing news is done with “what times …, is … sources … ” statement, for example:
what times yesterday is “google $topic”, text?
There text google chrome helper; text google chrome helper.
what times 2014-10-18 is “google $topic”, topic?
There topic chrome helper; topic chrome helper.
what times 2014-10-18 is “google $topic”, text, sources?
There sources http://www.reuters.com/, text google chrome helper; sources http://www.wired.com/ text google chrome helper.
what sources http://www.reuters.com/ is “google $topic”, text, times?
There text google chrome helper, times 2014-10-18; text google glass technology, times 2014-10-19; text google now intelligence, times 2014-10-20.
Adding sites is done with “my sites … ” statement, for example:
http://aigents.mysite.org:1180/?my%20sites%20http://www.reuters.com/,%20http://www.wired.com/.
Ok.
Adding things is done with “my topics … ” statement, for example:
http://aigents.mysite.org:1180/?my%topics%kung-fu,%20'google $topic',%20“dow jones $value”.
Ok.
Configuring extra patterns for things is done with “... patterns …” statement, for example:
kung-fu patterns bruce-lee, kung-fu, “kung fu”, shaolin.
Ok.
Configuring typed variables (of types such as word, time, number and money) for patterns is done having variables explicitly specified for a thing with “... has ...” statement, for example:
“dow jones $value” has value.
Ok.
value is number.
Ok.
“Obama $action Putin” has action.
Ok.
action is word.
Ok.
“Operation starts at $hour_x” has hour_x.
Ok.
hour_x is time.
Ok.
offer_price pas patterns “offer price $price” has price.
Ok.
prices is money.
Ok.
Example:
For example, unit test for Aigents server can be downloaded from the following link:
http://aigents.com/download/api/aigents-php-demo.zip
To run the test, need to start Aigents server in one console session and then run the test in another console session:
#java -cp .:Aigents.jar:mail.jar net.webstructor.agent.Farm store path '', cookie domain localtest.com
…
#php -f agent_test.php