Standard regular expression based natural language interface to functions.
npm install conversational-uinpm i conversational-ui
``JavaScript
const cui = require('conversational-ui');
`
`JavaScript
cui.register(what is the answer to the ultimate question of life, '', function(options){
return "Um, but what is the question?";
});
cui.register(My name is (?, 'i', function(options){Hello ${options.name.trim()} how are you
return ;
});
`
`JavaScript
const question = 'what is the answer to the ultimate question of life';
console.log('Q:',question)
const response = await cui.request(question);
console.log("A:", response);
`
Q: what is the answer to the ultimate question of life
A: Um, but what is the question?
`JavaScript
const question = 'My name is Slim Shady !!!!';
console.log('Q:',question)
const response = await cui.request(question);
console.log("A:", response);
`
Q: My name is Slim Shady !!!!
A: Hello Slim Shady how are you
`JavaScript
cui.register(My name is (?, 'i', function({name}){Hello ${name} how are you!
return ;
});
`
`JavaScript
const question = 'My name is Slim Shady !!!!';
console.log('Q:',question)
const response = await cui.request(question);
console.log("A:", response);
`
Q: My name is Slim Shady !!!!
A: Hello Slim Shady how are you
`Bash
$> curl "http://localhost:3000/my+name+is+shady"
Hello shady how are you!
$> curl "http://localhost:3000/i+am+very+well"
Oh, shady I am glad you are very well
``