1.0.1 • Published 8 years ago
smartlyai v1.0.1
Smartly.ai node.js client
It's a node.js client for Smartly.ai; it simplifies calls to the api.
Installation
- Install Node.js
- Install Smartly.ai SDK with
npm:
npm install smartlyaiUsage
Sample use:
- Create
main.jsfile with the following code:
var smartlyai = require('smartlyai');
var dialog = smartlyai("<your client access token>");
dialog.newSession({
user_id: '<unique user id>', // Required
skill_id: '<your skill id>', // Required
lang: '<lang of the skill id>', // Required
[ input: 'your input', // Required for newInput method ]
[ user_data: {<your user data>} // Optional]
})
.then(data =>
console.log(data)
)
.catch(err => {
console.error(err.message)
})- Run following command.
node main.jsYou must first pass the token to the smartlyai module, then you can call newSession or newInput; the first create a new session (i.e. goes back to the Welcome State) while the second simulates user input (e.g. "Hello there.").
The two methods return native promises.
For more information, see our doc Smartlyai's API documentation on section API/Dialog