# codelane-nodejs-assistant

> Google Assistant SDK for Node.js

Latest version **0.7.1** (published 2019-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install codelane-nodejs-assistant
pnpm add codelane-nodejs-assistant
yarn add codelane-nodejs-assistant
bun add codelane-nodejs-assistant
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2019-09-12 |
| First published | 2019-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 255.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Giorgio Garasto |
| Maintainers | code-lane |

## Links

- npm: https://www.npmjs.com/package/codelane-nodejs-assistant
- Repository: https://github.com/code-lane/codelane-nodejs-assistant
- Homepage: https://github.com/code-lane/codelane-nodejs-assistant#readme
- Issues: https://github.com/code-lane/codelane-nodejs-assistant/issues
- npm.io page: https://npm.io/package/codelane-nodejs-assistant

## Dependencies (4)

- [grpc](https://npm.io/package/grpc.md) ^1.20.2
- [@grpc/proto-loader](https://npm.io/package/@grpc/proto-loader.md) ^0.5.0
- [google-proto-files](https://npm.io/package/google-proto-files.md) ^0.20.0
- [google-auth-library](https://npm.io/package/google-auth-library.md) ^3.1.2

## Recent versions

- 0.7.1 (latest) — 2019-09-12

## README

<img src="https://upload.wikimedia.org/wikipedia/commons/c/cb/Google_Assistant_logo.svg" alt="Google Assistant logo" title="Google Assistant" align="right" height="96" width="96"/>

# [Google Assistant SDK: Node.js Client](https://github.com/Dabolus/nodejs-assistant)

<!-- TODO: Add some badges here -->

> Node.js idiomatic client for [Google Assistant SDK][product-docs] (unofficial).

The [Google Assistant SDK][product-docs] lets you add hotword detection, voice 
control, natural language understanding and Google’s smarts to your devices. 
Your device captures an utterance (a spoken audio request, such as 
_What's on my calendar?_), sends it to the Google Assistant, and receives a 
spoken audio response in addition to the raw text of the utterance.


* [Google Assistant SDK Node.js Client API Reference][client-docs]
* [github.com/Dabolus/nodejs-assistant](https://github.com/Dabolus/nodejs-assistant)
* [Google Assistant SDK documentation][product-docs]

Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].

[explained]: https://cloud.google.com/apis/docs/client-libraries-explained

**Table of contents:**

* [Quickstart](#quickstart)
  * [Before you begin](#before-you-begin)
  * [Installing the client library](#installing-the-client-library)
  * [Using the client library](#using-the-client-library)
* [Samples](#samples)
* [Contributing](#contributing)
* [License](#license)

## Quickstart

### Before you begin

Some configuration steps are needed to make this library work correctly, for 
example creating a Cloud Platform project, creating a device and generating 
OAuth2 credentials. Please, follow 
[the Google Assistant Library for Python guide](https://developers.google.com/assistant/sdk/guides/library/python/) 
to get started quickly.

### Installing the client library

    npm install --save nodejs-assistant

### Using the client library

```javascript
// Imports the Google Cloud client library
const {Assistant, AssistantLanguage} = require('nodejs-assistant');

// Your credentials
const credentials = require('path-to-your-credentials.json');

// Creates a client
const assistant = new Assistant(/* required credentials */ {
  type: 'authorized_user',
  client_id: credentials.client_id,
  client_secret: credentials.client_secret,
  refresh_token: credentials.refresh_token,
}, /* additional, optional options */ {
  locale: AssistantLanguage.ITALIAN, // Defaults to AssistantLanguage.ENGLISH (en-US)
  deviceId: 'your device id',
  deviceModelId: 'your device model id',
});

// Sends a text query to the assistant
assistant.query('Hi!')
  .then(response => {
    // response contains all the fields returned by the assistant, such as the text and audio
    console.log(`Response: ${response.text}`);
    // response.audio is a Buffer containing the audio response by the assistant
  })
  .catch(err => {
    console.error('ERROR: ', err);
  });
```

Head over the [API docs](https://dabolus.github.io/nodejs-assistant/api/) for 
more information.

## Samples

Samples are in the [`samples/`](samples/) directory. The samples' `README.md`
has instructions for running the samples.

| Sample                      | Source Code                       | Try it |
| --------------------------- | --------------------------------- | ------ |
| Quickstart | [source code](https://github.com/Dabolus/nodejs-assistant/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/Dabolus/nodejs-assistant&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
| Text Conversation | [source code](https://github.com/Dabolus/nodejs-assistant/blob/master/samples/text.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/Dabolus/nodejs-assistant&page=editor&open_in_editor=samples/text.js,samples/README.md) |
| Audio Conversation | [source code](https://github.com/Dabolus/nodejs-assistant/blob/master/samples/audio.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/Dabolus/nodejs-assistant&page=editor&open_in_editor=samples/audio.js,samples/README.md) |

You might also want to check out [Google Assistant Desktop _(Unofficial)_](https://github.com/Dabolus/google-assistant-desktop-unofficial) 
for a more concrete example.

## Contributing

Contributions welcome! See the [Contributing Guide](CONTRIBUTING.md).

## License

MIT

See [LICENSE](https://github.com/Dabolus/nodejs-assistant/blob/master/LICENSE)

[client-docs]: https://dabolus.github.io/nodejs-assistant/
[product-docs]: https://developers.google.com/assistant/sdk/
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png

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