View on GitHub

nodejs-assistant

Google Assistant SDK for Node.js.

Google Assistant logo

Google Assistant SDK: Node.js Samples

Open in Cloud Shell

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.

Table of Contents

Before you begin

Before running the samples, make sure you’ve followed the steps in the Before you begin section of the client library’s README.

Samples

Quickstart

A really basic example that sends a text query to the Assistant using the query method and prints its response.

View the source code.

Open in Cloud Shell

Usage: node quickstart.js

Text Conversation

An example that shows how to open a text conversation with the Assistant, send text queries and receive text responses.

View the source code.

Open in Cloud Shell

Usage: node text.js

Audio Conversation

An example that shows how to detect an hotword using Snowboy, open an audio conversation with the Assistant, send audio queries and receive audio responses. Note that the two hotwords (“Ok Google” and “Hey Google”) were trained against my voice, so you might want to train your own hotwords from Snowboy’s dashboard. The great thing is that Snowboy lets you train any keyword you want, not just “Ok Google” and “Hey Google”.

View the source code.

Open in Cloud Shell

Usage: node audio.js