2

I want to make a chatbot using java, similar to those bots back in the MSN days like cleverchild or whatever his name was. I've figured out how to use program-ab, and how to use wildcards for responses in the aiml files, but I dont know how to add functionality. For example, how would I add a calculator, or maybe the access to some files on my computer? I dont need help on making the code for those functions but just, how do I give the bot some variables, and it would run a function with those variables?

Me: I need to delete files
//The bot would process: _delete files * 
Bot: which files?
Me: C://folder/file.doc  
//Bot runs function deleteFile(path) 

1 Answers1

1

Two ways come to my mind:

  1. Write your own pre-processor and deal with those special tasks on your own, and feed the rest to program-ab https://code.google.com/p/program-ab/wiki/ProgrammingInterface

  2. Write a post-processor to catch and query Google, which does a good job calculating formulas.

As opposed to generic Google, you may also want to check out Wolfram Alpha's API http://products.wolframalpha.com/api/

Tsan-Kuang Lee
  • 1,454
  • 1
  • 14
  • 10
  • Thank you for the solution. Could you suggest any kind of example just to implement a simple java function to print something or a calculator function for reference? – Dev_Man May 11 '17 at 05:47
  • 1
    I haven't used ab for a while, but the general idea works like this: `Web front-end input -> web server -> ab backend -> web server -> web front-end output`. So your front-end talks to a web service (probably Tomcat, but you can use anything), which talks to ab backend. That way, your can intercept anything on the web server level. Calling Google or Wolfram Alpha is just a regular web API call. – Tsan-Kuang Lee May 13 '17 at 21:16
  • 1
    Or if you are thinking Android, your pre/post-processors will wrap ab in the center. Again, it's just a regular 3rd party API call. – Tsan-Kuang Lee May 13 '17 at 21:22
  • Thanks a lot for help! – Dev_Man May 14 '17 at 03:55
  • @Tsan-KuangLee The ab program brings up chatbot in console, how could I make it interact with api's using spring? can you elaborate it. – Rajath M S Dec 06 '17 at 09:20
  • Rajath, if I remember correctly, you'll have to change those System.out lines to intercept the output; similarly for input. Or, using shall pipes to communicate with ab. – Tsan-Kuang Lee Dec 07 '17 at 16:15