apiai-promise

Node.js SDK for api.ai with Promise

Usage no npm install needed!

<script type="module">
  import apiaiPromise from 'https://cdn.skypack.dev/apiai-promise';
</script>

README

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