AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Android Chat bot using Program-AB
 
 

Hi,
I am doing the same project as Matthew Calapai but when I follow the steps https://code.google.com/p/program-ab/wiki/ProgrammingInterface to make program AB work in android I get in trouble. the trouble is that whatever request I send to the bot in my directory the only reply I receive is ” I have no answer for that” but there’s a proper reply in the AIML files, can anybody please help me? I don’t know what to do!

 

 
  [ # 1 ]

All I can add here is a question or two based on guesswork, as I’m not familiar with Program AB or Android. that said, however, I’ll give it a shot.

Were I in your situation, I would first work on the functionality of Program AB, and test it as a stand alone app. So along those lines, have you tried using Program AB’s built-in interface, to see if it functions by itself? Determining this level of functionality will go a long way to reducing the amount of troubleshooting required, I would think. smile

 

 
  [ # 2 ]

Hi, thank you Dave Marton for your help.
program AB is a jar file which I guess it’s used only for connection to my bot’s brain to search through the categories and give the proper reply to the users request, so you mean I must decompile the jar file and see what’s in it?
what I did was writing a simple hello world to check the functionality of the program AB(Ab.jar) as a library and it didn’t work. what should I do?

 

 
  [ # 3 ]

Nope! Not what I meant at all, really. You can run Program AB as a stand-alone “app”. You should find some useful information on how to do that here. I took the liberty of downloading Program AB’s latest version and extracting the zip file to a temporary working directory. I also copied the alice2 folder (./bots/alice2) and renamed the new folder to Morti. I then removed all of the A.L.I.C.E. AIML files in the aiml folder and replaced them with the AIML files for my chatbot, Morti. Once done, I copied the file start.bat over to a new file (Morti.bat) and changed the contents to look like this:

java -cp lib/Ab.jar Main bot=Morti action=chat trace=false morph=false

And ran that file in a “command window”. Lo and Behold, my chatbot, Morti (for the most part) came to life in a new way!

So, now that I have found out at least this part of how Program AB works, let’s get your copy running. So please tell me, where do you have Program AB’s files stored on your computer? We’ll start from there, and go step by step until we get your copy working. cheese

 

 
  [ # 4 ]

Hi,
well I can chat with the bot in the command window, It works by itself for alice2.
I have my program AB in this directory: D:\university courses\A.terms\Final project\program-ab-0.0.6.26,
but I can’t make it work in android, I followed the instructions here: https://code.google.com/p/program-ab/wiki/ProgrammingInterface, but the only answer I receive from the bot is “I have no answer for that!

 

 
  [ # 5 ]

well, now I could run a java project and see the proper answers by copying the bots folder from program AB to my java project’s directory but when I do the same for my android project it doesn’t work!

 

 
  [ # 6 ]

Ok, so I’m assuming that, given the folder structure, this is on a Windows machine, which simplifies things greatly (I’ve been working for the past several hours trying to get Program AB to work in both CentOS and Ubuntu, only just now getting it to work in Ubuntu!), so now let me see what I can do about getting the Android part to work. then I’ll share what I find out. smile

 

 
  [ # 7 ]

Ok, so much for that. This is where my knowledge and expertise seem to be fairly useless, I think. Your best bet at this point is to see if someone else in the community who has successfully paired Java with Android is willing to help. My problem with helping here isn’t with willingness, but with ability. As I mentioned previously, I’m not familiar with either Android ro Java, from the standpoint of programming.

I will, however, point out that I got the same “I have no answer for that” issue with Program AB on CentOS, and that turned out to be a permissions issue with files in the AIMLIF folder not having the right permissions, but I’m currently not able to find a solution for it (Ubuntu doesn’t have the same issue, and works just fine). So that may well be a good place to start looking. That’s about the best I can come up with at the moment. Sorry I couldn’t help further. downer

 

 
  [ # 8 ]

Dave Morton, thank you so much for your help, I really really thank you for at least replying to my posts and If you didn ‘t answer I couldn’t even make it work on java, I’ll try to make it work with android and if I could I’ll share it here.
actually the only person that I found that could have worked with program AB was Matthew Calapai that have posted to these forums which I guess he’s so busy.
again thank you for your help.

 

 
  [ # 9 ]

Sara, if you are building the project in Android you will not have access to the same data directories; it’s different than the desktop. Even if you are using the Android emulator on a PC, the filesystem is not available. You will probably need to put the AIML data files into the ‘assets’ section of the android project and load them from there. (I’m assuming you’re using the standard Android SDK in Eclipse; that’s the only way I’ve built projects for Android.) The AIML files will then get sent to the phone or tablet as part of the application.

You can use the getAssets().open(<filename>) method call from your Activity or Service to load the data file as an InputStream, but I have no idea if ProgramAB can accept it that way. There may be a way to load AIML files from external memory, like an SD card in the phone, but I don’t know how to do that in Android.

 

 
  [ # 10 ]

carl, I don’t think if program AB will recognize that, the code below shows the functions I must use to create a chat session and use the AIML files:
  String botname = “alice2”;
  String path = “D:/university courses/A.terms/android projects workspace/test_program_ab/assets/A/bots/alice2”;
  Bot bot = new Bot(botname, path);
  Chat chatSession = new Chat(bot);
  String request = “pets”;
  String response = chatSession.multisentenceRespond(request);
  TextView t =  new TextView(this);
  t = (TextView) findViewById(R.id.text);
  t.setText(response);
I tried to put my bot files in the assets folder, but I guess that’s for android reading some files but in here program AB must connect to those files and find the response between the categories…
thank you

 

 
  [ # 11 ]

OK. I took a look at the source code for program AB, and it looks like it won’t work for Android as it is. However, it might be straightforward to make a version that looks for files in the right place. I won’t have the chance to try that until sometime in October, but I’ll see what I can do.

 

 
  [ # 12 ]

I’m not sure if this is still of interest to anyone, but I recently became interested in getting the Program AB framework running on Android, and have created a basic example here

https://github.com/bradleybossard/android-program-ab-demo

Two of the biggest hurdles were figuring out to add a bots.zip file to the Android assets folder such that it could be unzipped to the local filesystem at the start of the program, and creating an AsyncTask to initial the bot (trying to do this in the UI thread will cause a timeout and the program to fail).

I don’t currently at the time of this writing have a fully conversational back and forth app working, just the process of adding the AIML files, unzipping them, initializing the bot, feeding it a single sentence, and posting it’s reply back to the UI.

 

 
  [ # 13 ]

Hi, Brad (or do you prefer Bradley?) and welcome to chatbots.org. smile

It sounds like you’ve made a good start. One of the concerns with using Program AB on Android devices is the time it takes to load the AIML files into memory on startup. I’m curious as to the size of the zip file you’re using for testing, and how long it takes to initialize the chatbot. Got any information on that for ue? smile

 

 
  [ # 14 ]

I generally go by Bradley actually.  Thanks for the welcome!

The size of the .zip file I’ve included

https://github.com/bradleybossard/android-program-ab-demo/blob/master/app/src/main/assets/bots.zip

is actually an archive of the entire bots directory tree on Program AB here

https://code.google.com/p/program-ab/source/browse/#hg/bots

and includes the 4 bots alice2, currentevents, jokebot and wndef, although currently in my code, I am currently only creating a single bot, alice2

https://github.com/bradleybossard/android-program-ab-demo/blob/master/app/src/main/java/com/bradleybossard/androidprogramabdemo/MainActivity.java#L43

Without putting some timing code into to give you a super accurate count, I put a couple log statements in my count to timestamp the onCreate function to where it receives it response…

01-25 10:49:16.362 32538-32538/? I/MainActivity﹕ onCreate

01-25 10:50:16.900 32538-32556/? I/MainActivity﹕ response = Hi!  I can really feel your smile today.  I am alive.  It’s great to be alive isn’t it?  Call me ALICE 2.0.

As you can see, it takes roughly 1 minute to load.  Ouch…

Another strange behavior I see in the Android logcat is, I get a whole bunch of errors of the variety.  Like, literally, I am seeing probably almost 100 or more.  I haven’t looked into the Program AB code at this point, but I wonder there is something I could do to address this issue that might improve startup performance?

java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.bradleybossard.androidprogramabdemo/files/bots/alice2/aimlif/utilities.aiml.csv: open failed: ENOENT (No such file or directory)

01-25 10:50:06.984 32538-32556/? W/System.err﹕ java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.bradleybossard.androidprogramabdemo/files/bots/alice2/aimlif/reductions2.aiml.csv: open failed: ENOENT (No such file or directory)

 

 

 
  [ # 15 ]

Also, once I get a little more time this week, I’ll go ahead and try to get a full conversation interface demo so you can talk back and forth to the bot, then upload a compiled version to the Google Play store so it will be easy for someone to install it and just play around.

 

 1 2 > 
1 of 2
 
  login or register to react