This plugin allows the integration of agents from the api.ai natural language processing service with your Node.js application.
npm install --save api.ai
Your client access token can be obtained in your Dashboard.
const apiai = require("api.ai");
const nlp = new apiai({
token: "<your client access token>",
session: "<unique session id>"
});
This module supports both callbacks and promises to deliver your data.
nlp.text("Hello World!", function (error, response) {
if (error) {
// Handle Error
}
else {
// Do what you wish with response
}
});
nlp.text("Hello World!")
.then(function (response) {
// Do what you wish with response
})
.error(function (error) {
// Handle error
});
This module supports making 3 different types of requests to api.ai:
- Text requests
- Voice requests
- User entities requests
These are the simplest of the above. Simply send text to api.ai to be processed:
nlp.text("Hello World", callback);
To send a voice request, you may either provide a buffer or the path of an audio file:
nlp.voice("hello_world.wav", callback);
You may also specify additional options, for instance - language:
nlp.voice("hello_world.wav", {
language: "en"
}, callback);
nlp.userEntities(user_entities, callback);
This module was created by David Tesler, using the original Node.JS SDK for api.ai
Awesomeness supplied by api.ai.