googlesamples/assistant-sdk-nodejs

Name: assistant-sdk-nodejs

Owner: Google Samples

Description: null

Created: 2018-05-07 21:27:51.0

Updated: 2018-05-15 04:34:39.0

Pushed: 2018-05-07 21:39:21.0

Homepage: null

Size: 9

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Google Assistant SDK for devices - Node.js

Setup
  1. Create or open a project in the Actions Console
  2. Follow the instructions to register a device model
  3. Download credentials.json
  4. Install the [google-oauthlib-tool][https://github.com/GoogleCloudPlatform/google-auth-library-python-oauthlib] in a [Python 3][https://www.python.org/downloads/] virtual environment:
on3 -m venv env
bin/python -m pip install --upgrade pip setuptools
bin/pip install --upgrade google-auth-oauthlib[tool]
  1. Use the [google-oauthlib-tool][https://github.com/GoogleCloudPlatform/google-auth-library-python-oauthlib] to generate credentials:
bin/google-oauthlib-tool --client-secrets credentials.json \
                         --credentials devicecredentials.json \
                         --scope https://www.googleapis.com/auth/assistant-sdk-prototype \
                         --save
  1. Run cd google-assistant-grpc
  2. Run npm install
  3. Run node googleassistant.js
t GoogleAssistant = require('./googleassistant');
t deviceCredentials = require('./devicecredentials.json');

t CREDENTIALS = {
ient_id: deviceCredentials.client_id,
ient_secret: deviceCredentials.client_secret,
fresh_token: deviceCredentials.refresh_token,
pe: "authorized_user"


t assistant = new GoogleAssistant(CREDENTIALS);
Usage

The GoogleAssistant class has several methods and helpers.

stant.assist('what time is it')
hen(({ text }) => {
console.log(text); // Will log "It's 12:30"
;

You can chain together several requests and responses with Promises, as shown below.

stant.assist('what is the weather')
hen(({ text }) => {
console.log(text);
return assistant.assist('what about the weather tomorrow')

hen(({ text }) => {
console.log(text);
;
License

See LICENSE.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.