UNPKG

854 BMarkdownView Raw
1# Node.js SDK for Api.ai
2
3This plugin allows integrating agents from the [Api.ai](http://api.ai) natural language processing service with your Node.js application.
4
5* [Installation](#installation)
6* [Usage](#usage)
7
8# Installation
9
10* Install [Node.js](https://nodejs.org/)
11* Install Api.ai SDK with `npm`:
12```shell
13npm install apiai
14```
15
16# Usage
17* Create `main.js` file with the following code:
18```javascript
19var apiai = require('apiai');
20
21var app = apiai("<your client access token>", "<your client subscription key>");
22
23var request = app.textRequest('<Your text query>');
24
25request.on('response', function(response) {
26 console.log(response);
27});
28
29request.on('error', function(error) {
30 console.log(error);
31});
32
33request.end()
34```
35* Run following command.
36```shell
37node main.js
38```
39* Your can find more examples in [`examples`](examples) directory.