Node.js idiomatic client for Google Assistant SDK (unofficial).
The Google Assistant SDK 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.
Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in Client Libraries Explained.
Table of contents:
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
to get started quickly.
Installing the client library
npm install --save nodejs-assistant
Using the client library
const {Assistant, AssistantLanguage} = require('nodejs-assistant');
const credentials = require('path-to-your-credentials.json');
const assistant = new Assistant( {
type: 'authorized_user',
client_id: credentials.client_id,
client_secret: credentials.client_secret,
refresh_token: credentials.refresh_token,
}, {
locale: AssistantLanguage.ITALIAN,
deviceId: 'your device id',
deviceModelId: 'your device model id',
});
assistant.query('Hi!')
.then(response => {
console.log(`Response: ${response.text}`);
})
.catch(err => {
console.error('ERROR: ', err);
});
Head over the API docs for
more information.
Samples
Samples are in the samples/
directory. The samples' README.md
has instructions for running the samples.
You might also want to check out Google Assistant Desktop (Unofficial)
for a more concrete example.
Contributing
Contributions welcome! See the Contributing Guide.
License
MIT
See LICENSE