{"id":1259,"date":"2011-03-14T00:46:13","date_gmt":"2011-03-14T07:46:13","guid":{"rendered":"http:\/\/www.nathalielawhead.com\/candybox\/?p=1259"},"modified":"2014-03-18T22:50:35","modified_gmt":"2014-03-19T05:50:35","slug":"programe-e-alice-aiml-bot-using-flash-php-actionscript-walkthrough-source-files","status":"publish","type":"post","link":"http:\/\/www.nathalielawhead.com\/candybox\/programe-e-alice-aiml-bot-using-flash-php-actionscript-walkthrough-source-files","title":{"rendered":"Programe E ALICE AIML Bot Using Flash (PHP &#038; Actionscript Walkthrough + Source Files)"},"content":{"rendered":"<p><strong>System requirements:<\/strong><br \/>\n*PHP (4.0.4 and up)<br \/>\n*MySQL<br \/>\n*Apache Server<br \/>\n*Flash<br \/>\n(If you found this via a google search&#8230; <strong><a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/Chatbot_Programe_E_Flash\" target=\"_blank\">Source files for the Flash<\/a><\/strong> are at the end of the post&#8230;)<\/p>\n<p><strong>Short Summary:<\/strong><br \/>\n<strong>Update: <\/strong>For a tutorial, and source code, on integrating <a href=\"http:\/\/www.nathalielawhead.com\/candybox\/pandorabots-to-flash-actionscript-tutorial\" target=\"_blank\">Pandorabots with Flash, click here<\/a>.<br \/>\nThis is a concise collection of all the information that&#8217;s out there (as far as my research leads me to believe &#8211; since I last checked), + some personal trial-error-experimeddling on installing Program&#8217;s to host your own ALICE bot.<br \/>\nThis also walks you through the basics for building your own Flash interface (for your bot).<br \/>\nMy goal was to make a tutorial for people that don&#8217;t want to use pandorabots.<br \/>\nI hope to build on this in the near future.<\/p>\n<p><strong>Extended Summary:<\/strong><br \/>\nI love playing around with <a href=\"http:\/\/www.google.com\/search?&#038;q=Pattern+Matching+for+Natural+Language+Applications\" target=\"_blank\">bots<\/a>, and especially love lurking on lists like <a href=\"http:\/\/tech.groups.yahoo.com\/group\/Robitron\/\" target=\"_blank\">Robitron<\/a>. Projects like <a href=\"http:\/\/sourceforge.net\/projects\/chatscript\/files\/\" target=\"_blank\">ChatScript<\/a> &#038; <a href=\"http:\/\/www.kirsle.net\/rivescript.html\" target=\"_blank\">RiveScript<\/a> are excellent ways of tickling the inner geek and keeping you busy in all your free time&#8230;<br \/>\nOf course, this completely devastates your social life, but hell&#8230; Who needs friends when you can MAKE them. Ha! <a href=\"http:\/\/instantrimshot.com\/classic\/?sound=rimshot\" target=\"_blank\">Pun intended!<\/a><br \/>\nChatbots in games is something that I&#8217;m particularly passionate about, and sell everyone on. I&#8217;ve successfully incorporated them into a number of my client&#8217;s projects. They&#8217;ve fit beautifully into these every-time.<br \/>\nNaturally, if you want to see them in action visit <a href=\"http:\/\/tetrageddon.com\">Tetrageddon Arcade<\/a>, or <a href=\"http:\/\/alienmelon.com\">chat with Minibyte on the front page of AlienMelon<\/a>&#8230;<\/p>\n<p>This is going to cover a means of making a Flash based <a href=\"http:\/\/www.alicebot.org\/aiml.html\" target=\"_blank\">ALICE AIML<\/a> bot that <em>you<\/em> can host without <a href=\"http:\/\/pandorabots.com\" target=\"_blank\">pandorabots<\/a>.<br \/>\nYou&#8217;ll need a host provider like <a href=\"http:\/\/mediatemple.net\/\" target=\"_blank\">MediaTemple<\/a> where you have basic control over your own database, ect&#8230;<br \/>\nNow, I know that <a href=\"http:\/\/www.pandorabots.com\/pandora\/pics\/wallaceaimltutorial.html\" target=\"_blank\">AIML<\/a> is not necessarily &#8220;the best&#8221; solution out there.<br \/>\nThere are fucktoneries of technologies\/experiments, like <a href=\"http:\/\/www.jabberwacky.com\/\" target=\"_blank\">Jabberwacky<\/a>, <a href=\"http:\/\/www.google.com\/search?q=VoiceXML+bots\" target=\"_blank\">VoiceXML<\/a>, <a href=\"http:\/\/i5.nyu.edu\/~mm64\/x52.9265\/january1966.html\" target=\"_blank\">ELIZA<\/a> (<a href=\"http:\/\/search.cpan.org\/~jnolan\/Chatbot-Eliza-1.04\/Chatbot\/Eliza.pm\" target=\"_blank\">of course<\/a>), <a href=\"http:\/\/www.google.com\/search?q=IBM's+Watson\" target=\"_blank\">IBM&#8217;s Watson<\/a>, the list <a href=\"http:\/\/www.chatterbots.info\/\" target=\"_blank\">goes on and on<\/a>&#8230; <a href=\"http:\/\/www.alicebot.org\/TR\/2001\/WD-aiml\/\" target=\"_blank\">In terms of authoring<\/a>, AIML is difficult to look at, BUT it makes the most effective and believable personality I know of&#8230; Especially if you don&#8217;t have years to develop your own personality.<br \/>\nI turn to it because of all the AIML sets that are so freely available out there, allowing you to quickly and easily customize your own personality&#8230; Not because it is necessarily &#8220;better&#8221;, but because there are so many sets available, you don&#8217;t need to spend years on creating something that is somewhat believable.<br \/>\nI terms of &#8220;building from the ground up&#8221;, I notice users still pick up on the &#8220;fakeness&#8221; of other bots too easily&#8230;<br \/>\nNevertheless, picking your own solution is for you to decide, besides this is a post about building and hosting your own Flash <a href=\"http:\/\/www.alicebot.org\/articles\/wallace\/dont.html\" target=\"_blank\">ALICE bot!<\/a><br \/>\nAgain, like I said, if you want to see a Flash front-end and AIML back-end in full frontal wackiness (crazy little character) then check out these two examples:<br \/>\n<a href=\"http:\/\/alienmelon.com\" target=\"_blank\">Alienmelon<\/a> (minibyte, the most popular)<br \/>\n<a href=\"http:\/\/spam.alienmelon.com\" target=\"_blank\">They Came From My Inbox<\/a> (talk to the spam via the text input field at the bottom of the menu)<br \/>\nSo&#8230;<\/p>\n<p><strong>INSTALLING THE BOT<\/strong><\/p>\n<p>Head on down to<br \/>\n<a href=\"http:\/\/www.alicebot.org\/downloads\/programs.html\" target=\"_blank\">http:\/\/www.alicebot.org\/downloads\/programs.html<\/a><br \/>\nAnd grab yourself a copy of <a href=\"http:\/\/sourceforge.net\/projects\/programe\/\" target=\"_blank\">Programe E<\/a>&#8230; That&#8217;s their PHP version.<br \/>\nNotice that there are a plethora of other funky awesome implementations there, and that makes things all the more exciting!<\/p>\n<p><a href=\"http:\/\/sourceforge.net\/projects\/programe\/\" target=\"_blank\">Program E<\/a> is a platform for running artificial intelligence robots written in PHP. It runs bots written in AIML (Artificial Intelligence Markup Language). Custom tags are a feature of AIML engines such as Programe E and it uses MySQL for its database bits and pieces.<br \/>\nYou&#8217;ll have to know a little thing or two about running sql scripts, which is not hard!<br \/>\nIn fact, it can be a lot of fun!<br \/>\nNote that AIML is really easy to understand if you know XML. It basically is a funked up version of XML.<br \/>\nA noteworthy collection of AIML sets are the <a href=\"http:\/\/www.alicebot.org\/aiml\/aaa\/\" target=\"_blank\">Annotated A.L.I.C.E. AIML<\/a> files found here:<br \/>\n<a href=\"http:\/\/www.alicebot.org\/aiml\/aaa\/\" target=\"_blank\">http:\/\/www.alicebot.org\/aiml\/aaa\/<\/a><br \/>\nOn the other hand, if you are crazy enough to start from complete scratch I suggest investigating other solutions.<\/p>\n<p>You&#8217;ll also need a noteworthy AIML editor. For most people I suggest just heading down to <a href=\"http:\/\/pandorabots.com\" target=\"_blank\">Pandorabots<\/a> and using that as a development environment.<br \/>\nThey already have something like an &#8220;editor&#8221; there where you can keep testing &#038; uploading.<br \/>\nGo to &#8220;<em>Create a Pandorabot<\/em>&#8220;, there you can also select whatever set you wish&#8230;<br \/>\nCreate it and then go to &#8220;AIML&#8221;. You can download sets there as well.<br \/>\nYou can do your testing and personality forging there, and then upload the sets to your own server. It&#8217;s one good way of having a reliable environment.<br \/>\nAnother great desktop editor is the GAITObot AIML editor (Windows only, <a href=\"http:\/\/www.apple.com\/support\/bootcamp\/\" target=\"_blank\">MAC users must use bootcamp<\/a>):<br \/>\n<a href=\"http:\/\/www.gaitobot.de\/gaitobot\/AIMLEditor\/download.aspx\" target=\"_blank\">http:\/\/www.gaitobot.de\/gaitobot\/AIMLEditor\/download.aspx<\/a><br \/>\nIt&#8217;s another good starting point for learning.<br \/>\nThere is also <a href=\"http:\/\/riotsw.com\" target=\"_blank\">SAE (Simple AIML Editor)<\/a>. It&#8217;s Free by <a href=\"http:\/\/riotsw.com\" target=\"_blank\">Riot Software<\/a>&#8230;<br \/>\nAND <a href=\"http:\/\/www.ai-dealer.com\/AIML_Editor.html\" target=\"_blank\">AI Dealer<\/a>&#8230;<br \/>\nPick your point of entry!<\/p>\n<p>Setting up a local testing environment is also something I highly recommend for safety reasons&#8230;<br \/>\nI suggest <a href=\"http:\/\/www.mamp.info\/en\/index.html\" target=\"_blank\">MAMP<\/a> for that:<br \/>\n<a href=\"http:\/\/www.mamp.info\/en\/index.html\" target=\"_blank\">http:\/\/www.mamp.info\/en\/index.html<\/a><br \/>\nIt&#8217;s for godless MAC users like me.<br \/>\nIt&#8217;ll simulate Apache, MySQL, and PHP environments.<br \/>\nIt works charms and keeps you from making killer mistakes that&#8217;ll down all your sites because you&#8217;ve accidentally failed to terminate a loop on line 34 and it overloaded the server&#8230; or some freak shit like that&#8230;<br \/>\nWhatever!<br \/>\nDon&#8217;t judge me.<br \/>\nFor setting up <a href=\"http:\/\/www.mamp.info\/en\/index.html\" target=\"_blank\">MAMP<\/a> <a href=\"http:\/\/wordpress.org\/\" target=\"_blank\">wordpress.org<\/a> has a wonderful walk through:<br \/>\n<a href=\"http:\/\/codex.wordpress.org\/Installing_WordPress_Locally_on_Your_Mac_With_MAMP\" target=\"_blank\">Installing WordPress Locally On Your Mac With MAMP<\/a><br \/>\nAnd here is another good walkthrough:<br \/>\n<a href=\"http:\/\/jayrobinson.org\/2009\/08\/10\/setting-up-your-mac-for-local-development-using-coda-wordpress-mamp\/\" target=\"_blank\">Setting Up Your Mac For Local Development Using Coda WordPress Mamp<br \/>\n<\/a><br \/>\nEither way. This is LOTS OF FUN and IS NOT HARD. :D<br \/>\nIf I can do it, a monkey can!<\/p>\n<p>So! After you&#8217;ve got all your settings upped, safeties strapped, balls secured, and your copy of <a href=\"http:\/\/www.alicebot.org\/downloads\/programs.html\" target=\"_blank\">Program E<\/a> downloaded&#8230;<\/p>\n<p>1) Create a directory (on your server) called &#8220;<code>programe<\/code>&#8220;. Here is where you&#8217;ll install your little robot friend.<br \/>\nUnzip and upload all the Program E files into this directory.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_11.jpg\" alt=\"Unzip in Program E\" \/><\/p>\n<p>2) Create a database for the program to use in MySQL. Call it something like &#8220;<code>programe<\/code>&#8220;.<\/p>\n<p>3) Here&#8217;s the fun part. In the Program E install you downloaded navigate to:<br \/>\n<code>sql > mysql > db.sql<\/code><br \/>\nOpen that up. You&#8217;ll need to run that script.<br \/>\nIf you have phpMyAdmin, then do the following&#8230;<br \/>\nHit the SQL tab at the top:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_14.jpg\" alt=\"The SQL Tab...\" \/><\/p>\n<p>Paste the contents of &#8220;<code>db.sql<\/code>&#8221; into the &#8220;<code>RUN SQL query \/ queries on database<\/code>&#8221;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_13.jpg\" alt=\"Run SQL Query\" \/><\/p>\n<p>And hit &#8220;<code>go<\/code>&#8220;!<\/p>\n<p>Booya! You got bot.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_12.jpg\" alt=\"U got bot\" \/><\/p>\n<p>4) By default, AIML files and <code>startup.xml<\/code> are in the <code>aiml<\/code> directory. Use the <code>startup.xml<\/code> file included in the distribution.<br \/>\nDO NOT use the <code>startup.xml<\/code> you get with AIML files from <a href=\"http:\/\/www.alicebot.org\/\" target=\"_blank\">alicebot.org<\/a>. AIML files that work well with <a href=\"http:\/\/sourceforge.net\/projects\/programe\/\" target=\"_blank\">Program E<\/a> can be found at <a href=\"http:\/\/sourceforge.net\/project\/showfiles.php?group_id=43190\" target=\"_blank\">http:\/\/sourceforge.net\/project\/showfiles.php?group_id=43190<\/a><br \/>\nOnce you&#8217;ve got your AIML sets unzip and upload all the files to the AIML directory.<br \/>\nDelete &#8220;<code>std-65-percent.aiml<\/code>&#8221; &#038; &#8220;<code>std-pickup.aiml<\/code>&#8220;.<br \/>\nYou don&#8217;t need those.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_9.jpg\" alt=\"u dont need\" \/><\/p>\n<p>Booya! Bot got brain.<\/p>\n<p>5) In the &#8220;<code>aiml<\/code>&#8221; directory there is a &#8220;<code>startup.xml<\/code>&#8220;:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_6.jpg\" alt=\"aiml startup.xml\" \/><\/p>\n<p>Edit that to fit your bot&#8217;s personality. You can also do this later, but this is an important 1st step in forging your own bot.<br \/>\nNote that this is like the Pandorabots &#8220;<code>properties<\/code>&#8220;:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_8.jpg\" alt=\"pandorabots properties\" \/><\/p>\n<p>Same thing&#8230; It&#8217;s basically predefined character traits (values) that you continuously refer to in the AIML files. <\/p>\n<p>6) Go to &#8220;<code>\/src\/admin\/dbprefs.php<\/code>&#8220;, and edit <code>dbprefs.php<\/code> with your database information and aiml directory information.<br \/>\nIf you have AIML files in the default directory you don&#8217;t have to change that. See <code>dbprefs.php<\/code> for other options that can be configured.<br \/>\nThe values you need to edit are:<br \/>\n<code>$DB_HOST<\/code> (database host name)<br \/>\n<code>$DB_UNAME<\/code> (database username)<br \/>\n<code>$DB_PWORD<\/code> (password)<br \/>\n<code>$DB_DB<\/code> (name of the programe database)<br \/>\nFor the AIML directory for <code>$rootdir<\/code> use the absolute path and include &#8220;\/&#8221;. If this is wrong you may have to revisit this. You&#8217;ll get an error, and then you&#8217;ll know if you did it wrong. <a href=\"http:\/\/images2.memegenerator.net\/ImageMacro\/3875151\/Im-sorry-man-IM-NOT-PRO-BRO.jpg?imageSize=Medium&#038;generatorName=jesus-says\" target=\"_blank\">Sorry maaaaan<\/a>.<\/p>\n<p>For example if you&#8217;re on a (mt) gridserver:<\/p>\n<p><code>$rootdir=\"\/..\/..\/aiml\/\";<br \/>\n$DB_HOST=\"internal-db.sxxxxx.gridserver.com\";<br \/>\n$DB_UNAME=\"username\";<br \/>\n$DB_PWORD=\"password\";<br \/>\n$DB_DB=\"dbxxxx_programe\";<\/code><\/p>\n<p>Note that <code>src\/admin<\/code> needs to be writable by the web server because <code>botloader.php<\/code> will create a file <code>subs.inc<\/code>. You can also create an empty <code>subs.inc<\/code> file and make that writable.<\/p>\n<p>8) From your site access <code>botloader.php<\/code>&#8230;<br \/>\nExample:<br \/>\n<code>http:\/\/MYSITE.com\/programe\/src\/admin\/botloader.php<\/code><br \/>\nTo load the AIML into the database. This&#8217;ll take a bit so be patient!<br \/>\nOn a dual PIII it takes approx. 1 minute for 10,000 categories.<br \/>\nIf your PHP is running in safe mode you might need to use <code>botloaderinc.php<\/code> to load the AIML files one at a time. <\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_5.jpg\" alt=\"botloaderinc\" \/><\/p>\n<p>If you experience timeouts then access <code>botloaderinc.php<\/code> instead.<br \/>\nNote that whenever you load <code>botloader.php<\/code> it DELETES ALL the patterns and templates that you have in your database and then loads\/reloads them from the AIML files you have. This is basically how you re-load\/update your bot&#8230; by accessing that file.<\/p>\n<p>9) Navigate to:<br \/>\n<code>http:\/\/MYSITE.com\/programe\/src\/talk.php<\/code><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_4.jpg\" alt=\"talk.php\" \/><\/p>\n<p>To give it a test ride.<br \/>\nIf it talks back, you know you dundidit right!<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_3.jpg\" alt=\"Sup, bro.\" \/><\/p>\n<p>10) For safety reasons: <strong>PASSWORD PROTECT THE ADMIN DIRECTORY WITH A .htaccess FILE SO NO ONE CAN ACCESS THAT DIRECTORY.<\/strong><br \/>\nLock it down, or remove it and re-upload later when needed.<\/p>\n<p>11) Finally you&#8217;ll need a PHP script for the Flash end of things to access.<br \/>\nIn your <code>aiml\/startup.xml<\/code> there is a bit at the top <code> < bot id=\"TestBot\" ... > <\/code><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/bot_7.jpg\" alt=\"This\" \/><\/p>\n<p>Substitute &#8220;<code>TestBot<\/code>&#8221; with your bot name first. That&#8217;s going to be hardcoded into the following PHP script.<br \/>\nStart a blank .php file then copy &#038; paste the following:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #557799\">&lt;?php<\/span>\r\n<span style=\"color: #888888\">\/\/load in contents of respond file for use...<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">include<\/span> <span style=\"background-color: #fff0f0\">&quot;respond.php&quot;<\/span>;\r\n<span style=\"color: #008800; font-weight: bold\">if<\/span> (<span style=\"color: #007020\">isset<\/span>(<span style=\"color: #996633\">$_POST<\/span>[<span style=\"background-color: #fff0f0\">&#39;theinput&#39;<\/span>])){\r\n\t<span style=\"color: #996633\">$numselects<\/span><span style=\"color: #333333\">=<\/span><span style=\"color: #0000DD; font-weight: bold\">0<\/span>;\r\n\t<span style=\"color: #007020\">session_start<\/span>();\r\n\t<span style=\"color: #888888\">\/\/unique session id for user<\/span>\r\n\t<span style=\"color: #996633\">$sessionid<\/span><span style=\"color: #333333\">=<\/span><span style=\"color: #007020\">session_id<\/span>();\r\n\t<span style=\"color: #996633\">$response<\/span><span style=\"color: #333333\">=<\/span>replybotname(<span style=\"color: #996633\">$_POST<\/span>[<span style=\"background-color: #fff0f0\">&#39;theinput&#39;<\/span>],<span style=\"color: #996633\">$sessionid<\/span>,<span style=\"background-color: #fff0f0\">&#39;TestBot&#39;<\/span>);\r\n\t<span style=\"color: #008800; font-weight: bold\">echo<\/span> <span style=\"background-color: #fff0f0\">&quot;theoutput=&quot;<\/span><span style=\"color: #333333\">.<\/span>trim(<span style=\"color: #996633\">$response<\/span><span style=\"color: #333333\">-&gt;<\/span><span style=\"color: #0000CC\">response<\/span>);\r\n}\r\n<span style=\"color: #557799\">?&gt;<\/span>\r\n<\/pre>\n<\/div>\n<p>Save that as &#8220;<code>talk_flash.php<\/code>&#8221;<\/p>\n<p>Notice in <code>( $_POST ['theinput'] , $myuniqueid, 'TestBot' );<\/code> The &#8216;<code>TestBot<\/code>&#8216; is your <em>bot id<\/em>. Rename that to the name you chose for your bot. Else your shit wont work for shit.<\/p>\n<p>Done! The non-Flash end is all setup<br \/>\nNext up&#8230;<br \/>\nPlanet Flash.<\/p>\n<p><strong>PROGRAMMING AND CREATING THE FLASH FRONT END<\/strong><\/p>\n<p>In a new Flash document you&#8217;ll need two text fields.<br \/>\nOne named &#8220;<code>txt_output<\/code>&#8221; set as a <code>Dynamic Text field<\/code>.<br \/>\nOne named &#8220;<code>txt_input<\/code>&#8221; set as an <code>Input Text field<\/code>.<\/p>\n<p>And the following actions that do something along the lines of&#8230;<\/p>\n<p><strong>ACTIONSCRIPT 3.0 would look like:<\/strong><br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">var<\/span> url_php:<span style=\"color: #333399; font-weight: bold\">String<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"background-color: #fff0f0\">&quot;http:\/\/www.nathalielawhead.com\/programe\/src\/talk_flash.php&quot;<\/span><span style=\"color: #333333\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">var<\/span> bool_firstrun:<span style=\"color: #333399; font-weight: bold\">Boolean<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">true<\/span><span style=\"color: #333333\">;<\/span>\r\n<span style=\"color: #888888\">\/\/Run<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">run<\/span><span style=\"color: #333333\">():<\/span><span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #888888\">\/\/Set up url vars<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">var<\/span> url_vars:<span style=\"color: #333399; font-weight: bold\">URLVariables<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">URLVariables<\/span><span style=\"color: #333333\">();<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">var<\/span> request:<span style=\"color: #333399; font-weight: bold\">URLRequest<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">URLRequest<\/span><span style=\"color: #333333\">();<\/span>\r\n\t<span style=\"color: #888888\">\/\/if its first run send an initial message<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>bool_firstrun<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\t<span style=\"color: #888888\">\/\/then set to false...<\/span>\r\n\t\tbool_firstrun <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">false<\/span><span style=\"color: #333333\">;<\/span>\r\n\t\t<span style=\"color: #888888\">\/\/firstrun message to establish a connection<\/span>\r\n\t\turl_vars<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">theinput<\/span><span style=\"color: #333333\">=<\/span><span style=\"background-color: #fff0f0\">&quot;Hello. My name is visitor.&quot;<\/span><span style=\"color: #333333\">;<\/span>\r\n\t<span style=\"color: #333333\">}<\/span> <span style=\"color: #008800; font-weight: bold\">else<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\t<span style=\"color: #888888\">\/\/if not do default<\/span>\r\n\t\turl_vars<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">theinput<\/span><span style=\"color: #333333\">=<\/span>txt_input<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">text<\/span><span style=\"color: #333333\">;<\/span>\r\n\t\ttxt_input<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">text<\/span><span style=\"color: #333333\">=<\/span><span style=\"background-color: #fff0f0\">&quot;&quot;<\/span><span style=\"color: #333333\">;<\/span>\r\n\t<span style=\"color: #333333\">}<\/span>\r\n\t<span style=\"color: #888888\">\/\/Post<\/span>\r\n\trequest<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">url<\/span><span style=\"color: #333333\">=<\/span>url_php<span style=\"color: #333333\">;<\/span>\r\n\trequest<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">method<\/span><span style=\"color: #333333\">=<\/span>URLRequestMethod<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">POST<\/span><span style=\"color: #333333\">;<\/span>\r\n\trequest<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">data<\/span><span style=\"color: #333333\">=<\/span>url_vars<span style=\"color: #333333\">;<\/span>\r\n\t<span style=\"color: #888888\">\/\/URL loader for above<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">var<\/span> loader:<span style=\"color: #333399; font-weight: bold\">URLLoader<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">URLLoader<\/span><span style=\"color: #333333\">();<\/span>\r\n\tloader<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">dataFormat<\/span><span style=\"color: #333333\">=<\/span>URLLoaderDataFormat<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">VARIABLES<\/span><span style=\"color: #333333\">;<\/span>\r\n\tloader<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>Event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">COMPLETE<\/span><span style=\"color: #333333\">,<\/span> sendcompletehandler<span style=\"color: #333333\">);<\/span>\r\n\tloader<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">load<\/span><span style=\"color: #333333\">(<\/span>request<span style=\"color: #333333\">);<\/span>\r\n\t<span style=\"color: #888888\">\/\/receive all the above and throw it into txt_output<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">sendcompletehandler<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">Event<\/span><span style=\"color: #333333\">):<\/span><span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\ttxt_output<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">text<\/span><span style=\"color: #333333\">=<\/span>event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">target<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">data<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">theoutput<\/span><span style=\"color: #333333\">;<\/span>\r\n\t<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #888888\">\/\/Keyboard<\/span>\r\ntxt_input<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>KeyboardEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">KEY_UP<\/span><span style=\"color: #333333\">,<\/span> key_run<span style=\"color: #333333\">);<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">key_run<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">KeyboardEvent<\/span><span style=\"color: #333333\">):<\/span><span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">keyCode<\/span><span style=\"color: #333333\">==<\/span>Keyboard<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">ENTER<\/span><span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\trun<span style=\"color: #333333\">();<\/span>\r\n\t<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #888888\">\/\/start<\/span>\r\nrun<span style=\"color: #333333\">();<\/span>\r\n<\/pre>\n<\/div>\n<p><strong>ACTIONSCRIPT 2.0 version would look like:<\/strong><br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">var<\/span> myfilename:<span style=\"color: #333399; font-weight: bold\">String<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"background-color: #fff0f0\">&quot;http:\/\/YOURSITE.com\/programe\/src\/talk_flash.php&quot;<\/span><span style=\"color: #333333\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">var<\/span> keyListener:<span style=\"color: #333399; font-weight: bold\">Object<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">Object<\/span><span style=\"color: #333333\">();<\/span>\r\nkeyListener<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">onKeyDown<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">function<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>Key<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getCode<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #333333\">==<\/span> Key<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">ENTER<\/span><span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\tsubmit<span style=\"color: #333333\">();<\/span>\r\n\t<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #333333\">};<\/span>\r\nKey<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addListener<\/span><span style=\"color: #333333\">(<\/span>keyListener<span style=\"color: #333333\">);<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">submit<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">var<\/span> result_lv:<span style=\"color: #333399; font-weight: bold\">LoadVars<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">LoadVars<\/span><span style=\"color: #333333\">();<\/span>\r\n\tresult_lv<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">onLoad<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">function<\/span><span style=\"color: #333333\">(<\/span>success<span style=\"color: #333333\">:<\/span>Boolean<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>success<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\t\ttxt_output<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">text<\/span> <span style=\"color: #333333\">=<\/span> result_lv<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">theoutput<\/span><span style=\"color: #333333\">;<\/span>\r\n\t\t<span style=\"color: #333333\">}<\/span> <span style=\"color: #008800; font-weight: bold\">else<\/span> <span style=\"color: #333333\">{<\/span>\r\n\t\t\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;error&quot;<\/span><span style=\"color: #333333\">);<\/span>\r\n\t\t<span style=\"color: #333333\">}<\/span>\r\n\t<span style=\"color: #333333\">};<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">var<\/span> send_lv:<span style=\"color: #333399; font-weight: bold\">LoadVars<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">LoadVars<\/span><span style=\"color: #333333\">();<\/span>\r\n\tsend_lv<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">theinput<\/span> <span style=\"color: #333333\">=<\/span> txt_input<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">text<\/span><span style=\"color: #333333\">;<\/span>\r\n\tsend_lv<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">sendAndLoad<\/span><span style=\"color: #333333\">(<\/span>myfilename<span style=\"color: #333333\">,<\/span> result_lv<span style=\"color: #333333\">,<\/span><span style=\"background-color: #fff0f0\">&quot;POST&quot;<\/span><span style=\"color: #333333\">);<\/span>\r\n\ttxt_input<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">text<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"background-color: #fff0f0\">&quot;&quot;<\/span><span style=\"color: #333333\">;<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n<\/pre>\n<\/div>\n<p>[swfobj src=&#8221;http:\/\/nathalielawhead.com\/sourcefiles\/Chatbot_Programe_E_Flash\/pflash.swf&#8221; height=&#8221;400&#8243; width=&#8221;400&#8243;]<br \/>\n<em>Type above to test<\/em><br \/>\n<a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/Chatbot_Programe_E_Flash\/pflash.html\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/noodles\/botshots\/bot_1.jpg\" alt=\"Flash Chat Bot\" \/><\/a><\/p>\n<p>You get the idea&#8230;<br \/>\nThis is a <em>veeeeeery<\/em> super simple barebones example that really just does the basic sending \/ receiving of variables.<br \/>\nYou can easily take this example and extend it.<br \/>\nMake a class out of it. Have the text write itself out a character at a time, as if the bot is typing to you. Have multiple text fields that connect to multiple bots to create a virtual chatroom. Or have an isometric game where each character is hooked to a bot that you talk to, and they give you information to send you on your quest&#8230; You get the idea&#8230; Bots are fucking awesome, and this is how simple they are.<br \/>\nNow go and have some creative fun on your great bot master adventures!<\/p>\n<p>Source Files <a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/Chatbot_Programe_E_Flash\" target=\"_blank\">Here<\/a>:<br \/>\n<a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/Chatbot_Programe_E_Flash\" target=\"_blank\">http:\/\/nathalielawhead.com\/sourcefiles\/Chatbot_Programe_E_Flash<\/a><\/p>\n<p><strong>Further Links:<\/strong><\/p>\n<p><a href=\"http:\/\/www.interactivestory.net\/\" target=\"_blank\">Fa\u00e7ade<\/a><\/p>\n<p><a href=\"http:\/\/www.rivescript.com\" target=\"_blank\">RiveScript<\/a><br \/>\n(Perl) A text-based scripting language for giving responses to chatterbots.<br \/>\nThis one&#8217;s worth keeping an eye on.<\/p>\n<p><a href=\"http:\/\/www.gamasutra.com\/view\/feature\/6305\/beyond_fa%C3%A7ade_pattern_matching_.php\" target=\"_blank\">Beyond Fa\u00e7ade: Pattern Matching for Natural Language Applications<\/a><\/p>\n<p>ChatScript<br \/>\n<a href=\"http:\/\/sourceforge.net\/projects\/chatscript\/files\/\" target=\"_blank\">http:\/\/sourceforge.net\/projects\/chatscript\/files\/<\/a><\/p>\n<p>suzette<br \/>\n<a href=\"http:\/\/www.chatbots.org\/chatbot\/suzette\/\" target=\"_blank\">http:\/\/www.chatbots.org\/chatbot\/suzette\/<\/a><br \/>\n<a href=\"http:\/\/ai.bluemars.com\/chat\/\" target=\"_blank\">http:\/\/ai.bluemars.com\/chat\/<\/a><br \/>\n<a href=\"http:\/\/bluemars.com\/\" target=\"_blank\">http:\/\/bluemars.com\/<\/a><\/p>\n<p>cleverbot<br \/>\n<a href=\"http:\/\/www.cleverbot.com\/\" target=\"_blank\">http:\/\/www.cleverbot.com\/<\/a><\/p>\n<p>ultra hal<br \/>\n<a href=\"http:\/\/www.zabaware.com\" target=\"_blank\">http:\/\/www.zabaware.com<\/a><\/p>\n<p><a href=\"http:\/\/www.personalityforge.com\/\" target=\"_blank\">http:\/\/www.personalityforge.com\/<\/a><\/p>\n<p><a href=\"http:\/\/www.chatbots.org\/\" target=\"_blank\">http:\/\/www.chatbots.org\/<\/a><\/p>\n<p><a href=\"http:\/\/crriam.over-blog.com\/categorie-12526759.html\" target=\"_blank\">French version of installing here!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>System requirements: *PHP (4.0.4 and up) *MySQL *Apache Server *Flash (If you found this via a google search&#8230; Source files for the Flash are at the end of the post&#8230;) Short Summary: Update: For a tutorial, and source code, on integrating Pandorabots with Flash, click here. This is a concise collection of all the information that&#8217;s out there (as far as my research leads me to believe &#8211; since I last checked), + some personal trial-error-experimeddling on installing Program&#8217;s to host your own ALICE bot. This also walks you through the basics for building your own Flash interface (for your&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":4522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[12],"tags":[],"class_list":["post-1259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-resources"],"_links":{"self":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts\/1259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/comments?post=1259"}],"version-history":[{"count":53,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts\/1259\/revisions"}],"predecessor-version":[{"id":3021,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts\/1259\/revisions\/3021"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/media\/4522"}],"wp:attachment":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/media?parent=1259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/categories?post=1259"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/tags?post=1259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}