node-wit
is the Node.js SDK for Wit.ai.
In your Node.js project, run:
npm install --save node-wit
Create index.js
, containing:
'use strict';
const Wit = require('node-wit').Wit;
const actions = {
say: (sessionId, msg, cb) => {
console.log(msg);
cb();
},
merge: (context, entities, cb) => {
cb(context);
},
error: (sessionId, msg) => {
console.log('Oops, I don\'t know what to do.');
},
'my-action': (context, cb) => {
context['name'] = 'Julien';
cb(context);
},
};
const client = new Wit('YOUR_TOKEN', actions);
client.interactive();
Then run in your terminal:
node index.js
See examples
folder for more examples.
The Wit module provides a Wit class with the following methods:
message
- the Wit message APIconverse
- the low-level Wit converse APIrunActions
- a higher-level method to the Wit converse APIinteractive
- starts an interactive conversation with your bot
See the docs for more information.