A Node.js Cleverbot API wrapper library. Go make a chat bot in a flash!
It supports both cleverbot.com and cleverbot.io
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. I recommend installing the latest LTS version of Node.js.
Installation is done using the npm install
command:
$ npm install cleverbot.js --save
new Cleverbot.com(options);
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
options |
Object |
❌ | - | The options for initializing cleverbot.js |
options.APIKey |
String |
❌ | - | The API key that you got from the cleverbot website |
options.preserveState |
Boolean |
✔ | false |
Whether to preserve the state of the conversations. |
const Cleverbot = require('cleverbot.js');
let options = {
APIKey: 'CFDoi4234falFOFaSfwepxXhBRW',
preserveState: true
};
cleverbot = new Cleverbot.com(options);
cleverbot.write('Hi how\'re you?').then(response => {
console.log(response.output); // Fine, how're you?
}).catch(e => {
console.error(e);
});
new Cleverbot.io(options);
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
options |
Object |
❌ | - | The options for initializing cleverbot.js |
options.APIUser |
String |
❌ | - | The API user that you got from the cleverbot website |
options.APIKey |
String |
❌ | - | The API key that you got from the cleverbot website |
const Cleverbot = require('cleverbot.js');
let options = {
APIUser: 'FaSfwepxX34falFO',
APIKey: 'CFDoi4234falFOFaSfwepxXhBRW'
};
cleverbot = new Cleverbot.io(options);
cleverbot.init().then(nick => {
cleverbot.write('Hi how\'re you?', nick).then(response => {
console.log(response.output); // Good, and you?
}).catch(e => {
console.error(e);
});
}).catch(e => {
console.error(e);
})
If you liked this project you can ⭐ Star it on GitHub to show your love and/or send a thank you note.