1.19.0 • Published 1 month ago

conversational-ui v1.19.0

Weekly downloads
2
License
ISC
Repository
github
Last release
1 month ago

conversational-ui

Regular expression based natural language interface to functions.

Installation

npm i conversational-ui

Initialize

const cui = require('conversational-ui');

Register Handlers

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 (?<name>[a-z ]+)`, 'i', function(options){
  return `Hello ${options.name.trim()} how are you`;
});

Example 1

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?

Example 2

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

Example 3

cui.register(`My name is (?<name>[a-z ]+)`, 'i', function({name}){
  return `Hello ${name} how are you!`;
});
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

Example 4, server.js

$> 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
1.19.0

1 month ago

1.18.0

3 months ago

1.17.0

4 months ago

1.15.0

7 months ago

1.16.0

6 months ago

1.14.0

12 months ago

1.13.0

1 year ago

1.12.0

1 year ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago