3

How do I use AIML (Artificial Intelligence Markup Language) with Node.js? I am building a chatbot using JavaScript and Node.js for which I need AIML. How do i use it? I have tried using the AIML Interpreter but I am facing problems while accessing the AIML libraries and tags in my Server.js file. Error which i get sometimes when i input chat and do not get a response from the bot.

Joshua Varghese
  • 5,082
  • 1
  • 13
  • 34
  • Have you run `npm install aiml`? What's the specific error you're running into? What have you tried so far? – Jonas Jun 06 '18 at 04:10
  • I have a project folder with a server.js file and an index.html file. Now where do I install npm install aiml? And how do use it in socket.io code which i have used in server.js? – Brijesh Choudhary Jun 06 '18 at 04:48
  • What operating system are you on? Google "how to install node.js npm on " and then "how to install node.js packages with npm on " – Jonas Jun 06 '18 at 04:50
  • I am on windows. Please refer my code which i have updated. I am trying to build a chatbot. Now how do i use AIML responses in my server.js file? – Brijesh Choudhary Jun 06 '18 at 04:52
  • Step 1: install npm. Step 2: install AIML. Step 3: Read aiml documentation: https://www.npmjs.com/package/aiml Step 4(optional): Post a specific problem you're having with using aiml in node.js: https://stackoverflow.com/help/mcve – Jonas Jun 06 '18 at 04:58
  • I have added the screenshot of the error i am getting. please have a look. – Brijesh Choudhary Jun 07 '18 at 04:54

1 Answers1

0

hope this would be helpful.

Installation

npm install aiml

Parameters

authorData - (required) message author metadata (name, age, etc.).
message - (required) just message.
callback - (required) classic js callback, nothing special: ).

Sample

var aiml = require('aiml')

aiml.parseFile('sample.aiml', function(err, topics){
  var engine = new aiml.AiEngine('Default', topics, {name: 'Jonny'});
  var responce = engine.reply({name: 'Billy'}, "Hi, dude", function(err, responce){
    console.log(responce);
  });
});

I assume that you already know basic concepts of AIML and the file structure.

Asiri Hewage
  • 577
  • 3
  • 16