1 | # Node.js SDK for Api.ai
|
2 |
|
3 | This 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
|
13 | npm install apiai
|
14 | ```
|
15 |
|
16 | # Usage
|
17 | * Create `main.js` file with the following code:
|
18 | ```javascript
|
19 | var apiai = require('apiai');
|
20 |
|
21 | var app = apiai("<your client access token>", "<your client subscription key>");
|
22 |
|
23 | var request = app.textRequest('<Your text query>');
|
24 |
|
25 | request.on('response', function(response) {
|
26 | console.log(response);
|
27 | });
|
28 |
|
29 | request.on('error', function(error) {
|
30 | console.log(error);
|
31 | });
|
32 |
|
33 | request.end()
|
34 | ```
|
35 | * Run following command.
|
36 | ```shell
|
37 | node main.js
|
38 | ```
|
39 | * Your can find more examples in [`examples`](examples) directory.
|