# dialogflow-api-utils

> Utility lib for working with the Dialogflow (formerly api.ai) API response data

Latest version **0.5.3** (published 2019-09-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install dialogflow-api-utils
pnpm add dialogflow-api-utils
yarn add dialogflow-api-utils
bun add dialogflow-api-utils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.3 |
| Published | 2019-09-06 |
| First published | 2018-01-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 814.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Joshua Salwen |
| Maintainers | smalltalk-jsalwen |
| Keywords | api.ai, dialogflow |

## Links

- npm: https://www.npmjs.com/package/dialogflow-api-utils
- Repository: https://github.com/smalltalk-ai/dialogflow-api-utils
- Homepage: https://github.com/smalltalk-ai/dialogflow-api-utils#readme
- Issues: https://github.com/smalltalk-ai/dialogflow-api-utils/issues
- npm.io page: https://npm.io/package/dialogflow-api-utils

## Dependencies (1)

- [merge](https://npm.io/package/merge.md) ^1.2.1

## Alternatives

- [react-native-root-siblings](https://npm.io/package/react-native-root-siblings.md) — 102.9K weekly downloads
- [post-robot](https://npm.io/package/post-robot.md) — 93.7K weekly downloads
- [@praxisui/dialog](https://npm.io/package/@praxisui/dialog.md) — 2.0K weekly downloads
- [easy-toggle-state](https://npm.io/package/easy-toggle-state.md) — 350 weekly downloads
- [ngx-lightbox-evp](https://npm.io/package/ngx-lightbox-evp.md) — 19 weekly downloads

## Recent versions

- 0.5.3 (latest) — 2019-09-06
- 0.5.2 — 2019-09-06
- 0.5.1 — 2018-01-12
- 0.5.0 — 2018-01-12

## README

# dialogflow-api-utils
[![npm](https://img.shields.io/npm/v/dialogflow-api-utils.svg)](https://www.npmjs.com/package/dialogflow-api-utils)

Utility lib for working with [Dialogflow (formerly api.ai) API](https://dialogflow.com/docs/reference/agent) response data

## Installation

* Requires Api.ai/Dialogflow SDK or similar to get data from Dialogflow (formerly api.ai)
* Install module with `npm`:
```shell
npm install --save dialogflow-api-utils
```

## Usage
Below is an example how to use the module along with the `api` module.

```javascript
const apiai = require('apiai');
// Utilities for v1 of the Dialogflow API
const dfUtils = require('dialogflow-api-utils').v1;

const app = apiai("<your client access token>");

var request = app.textRequest('<Your text query>', {
  sessionId: '<unique session id>'
});

request.on('response', function(response) {
  // get all the parameters
  var params = dfUtils.Query.getResultParameters(response);
  // get the value of parameter 'foo', if it isn't set, the return 'bar'
  var fooParam = dfUtils.Query.getResultParameter(response, 'foo', 'bar');

  // get all the messages from fulfillment
  var messages = dfUtils.Query.getFulfillmentMessages(response);
  // only get the messages for Facebook Messenger
  var fbMessages = dfUtils.Query.getFulfillmentMessages(response, 'facebook');
  // only get the messages for Slack
  var slackMessages = dfUtils.Query.getFulfillmentMessages(response, 'slack');

  // get the context 'userProfile'
  var userProfileContext = dfUtils.Query.getResponseContext(response, 'userProfile');

  // code to send messages
});

request.on('error', function(error) {
  console.log(error);
});

request.end();
```

## Documentation
[View documentation](docs/README.md) for an overview of all functions and their parameters

## License
See [LICENSE](LICENSE).

---
_Source: https://npm.io/package/dialogflow-api-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
