1.0.0 • Published 7 years ago

apiai-promise v1.0.0

Weekly downloads
86
License
MIT
Repository
github
Last release
7 years ago

Node.js SDK for Api.ai with Promise

This package helps you use Node.js SDK for Api.ai with Promise. You can write more elegant code if you use this with async/await.

Installation

  • Install Node.js
  • Install apiai-promise with npm:
npm install apiai-promise

Usage

  • Create main.js file with the following code:
var apiai = require('apiai-promise');

var app = apiai("<your client access token>");

app.textRequest('<Your text query>', {
    sessionId: '<unique session id>'
}).then(function(response) {
    console.log(response);
}).catch(function(error) {
    console.log(error);
})

Elegant code with ES2017 async/await

const response = await app.textRequest('<Your text query>', {
    sessionId: '<unique session id>'
})
  • Run following command.
node main.js