• Stars
    star
    851
  • Rank 53,558 (Top 2 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A sample of the Smart Home device control APIs in Actions on Google

Actions on Google: Smart Home sample using Node.js

This sample contains a fully functioning example of a Smart Home provider cloud service designed to work with Actions on Google. This can be used with a Actions Console project to create an Action interface to your IoT devices. This sample includes everything you need to get started, including a mocked user authentication service with sample users and a user web portal to demonstrate the user experience when controlling their lights with your action.

An example of a Smart Home IoT cloud engine is written here. This project can be integrated with a web portal for an interactive experience.

Setup Instructions

See the developer guide and release notes at https://developers.google.com/assistant for more details.

Clone the project and the included frontend as a subdirectory:

git clone https://github.com/actions-on-google/smart-home-nodejs.git
git clone https://github.com/actions-on-google/smart-home-frontend.git smart-home-nodejs/frontend
cd smart-home-nodejs

Steps for testing with Google Assistant

Create and set up project in Actions Console

  1. Use the Actions on Google Console to add a new project with a name of your choosing and click Create Project.
  2. Select Home Control, then click Smart Home.

Optional: Customize your action

  1. From the top menu under Develop, click on Invocation.
  2. Add your App's name. Click Save.
  3. From the top menu under DEPLOY, click on Directory Information.
  4. Add your App info, including images, a contact email and privacy policy. This information can all be edited before submitting for review.
  5. Click Save.

Add Request Sync and Report State

The Request Sync feature allows a cloud integration to send a request to the Home Graph to send a new SYNC request. The Report State feature allows a cloud integration to proactively provide the current state of devices to the Home Graph without a QUERY request. These are done securely through JWT (JSON web tokens).

  1. Navigate to the Google Cloud Console API Manager for your project id.
  2. Enable the HomeGraph API.
  3. Navigate to the Google Cloud Console API & Services page
  4. Select Create Credentials and create a Service account key
    1. Create a new Service account
    2. Use the role Service Account > Service Account Token Creator
  5. Create the account and download a JSON file. Save this as src/smart-home-key.json.

Configure Cloud Firestore

  1. Open your project in the Firebase console, and configure a Cloud Firestore database.
  2. Configure a users collection with a default user and a few default fields
    users\
        1234
            fakeAccessToken: "123access"
            fakeRefreshToken: "123refresh"
            homegraph: false

Deploy to Firebase Cloud Functions and Hosting

  1. Run the following commands:
npm install
npm --prefix frontend install
npm run deploy
  1. Open the web frontend URL.
  2. Configure the virtual devices shown as you please. Click the cloud icon shown above at least one of them to enable it for cloud control.

Start testing

  1. Navigate back to the Actions on Google Console.
  2. From the top menu under Develop, click on Actions (left nav). Click on Add your first action and choose your app's language(s).
  3. Enter the URL for fulfillment: PROJECT_ID.web.app/smarthome. and click Done.
  4. On the left navigation menu under ADVANCED OPTIONS, click on Account Linking.
    1. Select No, I only want to allow account creation on my website. Click Next.
    2. For Linking Type, select OAuth.
    3. For Grant Type, select 'Authorization Code' for Grant Type.
    4. Under Client Information, enter the client ID and secret as defined src/config-provider.ts:
      • Client Id: sampleClientId
      • Client Secret: sampleClientSecret
    5. The Authorization URL: PROJECT_ID.web.app/fakeauth path.
    6. The Token URL: PROJECT_ID.web.app/faketoken
    7. Click Save.
  5. On the left navigation menu under Test, click on Simulator, to begin testing this app.

Set up Account linking

  1. On a device with the Google Assistant logged into the same account used to create the project in the Actions Console, enter your Assistant settings.
  2. Click Home Control.
  3. Click the '+' sign to add a device.
  4. Find your app in the list of providers.
  5. Log in to your service.
  6. Start using the Google Assistant in the Actions Console to control your devices. Try saying 'turn my lights on'.

ℹ️ Assistant will only provide you control over items that are registered, so if you visit your front end and click the add icon to create a device your server will receive a new SYNC command.

References & Issues

Make Contributions

Please read and follow the steps in the CONTRIBUTING.md.

License

See LICENSE.

Terms

Your use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the Google APIs Terms of Service.

More Repositories

1

actions-on-google-nodejs

Node.js client library for Actions on Google
TypeScript
900
star
2

actions-on-google-java

Java/Kotlin library for Actions on Google
Kotlin
287
star
3

codelabs-nodejs

Actions on Google Codelabs
JavaScript
264
star
4

smart-home-local

Local Home SDK sample
TypeScript
255
star
5

dialogflow-webhook-boilerplate-nodejs

Webhook Boilerplate (using Dialogflow) in Node.js
JavaScript
187
star
6

dialogflow-facts-about-google-nodejs

Custom Entities, Contexts, and Deep Links sample (using Dialogflow) in Node.js
JavaScript
185
star
7

appactions-fitness-kotlin

A sample that shows how to make Android Apps available from the Assistant using App Actions.
Kotlin
173
star
8

assistant-conversation-nodejs

A developer friendly way to fulfill Actions SDK handlers for the Google Assistant
TypeScript
104
star
9

dialogflow-number-genie-nodejs

Localization sample (using Dialogflow) in Node.js
JavaScript
87
star
10

smart-home-java

Java
86
star
11

dialogflow-interactive-canvas-nodejs

A sample that demonstrates how to create an Interactive Canvas experience using Actions on Google for the Google Assistant.
JavaScript
76
star
12

actions-on-google-testing-nodejs

TypeScript
74
star
13

smart-home-dashboard

TypeScript
73
star
14

dialogflow-iosched-nodejs

The Action for the Google Assistant for Google I/O '18
JavaScript
71
star
15

dialogflow-transactions-nodejs

Physical transactions sample (using Dialogflow) in Node.js
JavaScript
67
star
16

local-home-sdk

Local Home SDK
CSS
67
star
17

dialogflow-conversation-components-nodejs

Rich Responses sample (using Dialogflow) in Node.js
JavaScript
66
star
18

dialogflow-updates-nodejs

Daily Updates & Push Notifications Sample (using Dialogflow) in Node.js
JavaScript
59
star
19

dialogflow-silly-name-maker

Parameters sample (using Dialogflow) in Node.js (no webhook)
59
star
20

actionssdk-say-number-nodejs

Say a number Actions SDK sample for Actions on Google
JavaScript
57
star
21

gactions

Go
49
star
22

dialogflow-name-psychic-nodejs

Permissions and Google Maps Static API sample (using Dialogflow) in Node.js
JavaScript
47
star
23

dialogflow-silly-name-maker-webhook-nodejs

Parameters sample (using Dialogflow) in Node.js
JavaScript
46
star
24

appactions-common-biis-kotlin

This sample Android app manages items on to-do lists using Google Assistant implemented via App Actions.
Kotlin
44
star
25

dialogflow-webhook-boilerplate-java

Webhook Boilerplate using the Java client library for Actions on Google
Java
35
star
26

actions-builder-canvas-nodejs

Interactive Canvas sample (using Actions Builder) in Node.js
JavaScript
26
star
27

dialogflow-google-sign-in-nodejs

Google Sign-In sample (using Dialogflow) in Node.js
HTML
25
star
28

smart-home-frontend

JavaScript
24
star
29

dialogflow-quotes-nodejs

External API sample (using Dialogflow) in Node.js
JavaScript
24
star
30

dialogflow-ssml-nodejs

SSML sample (using Dialogflow) in Node.js
JavaScript
23
star
31

assistant-conversation-testing-nodejs

Assistant conversation testing library
TypeScript
21
star
32

dialogflow-snowman-nodejs

Snowman Interactive Canvas Sample
JavaScript
19
star
33

smart-home-schema

19
star
34

dialogflow-gdg-nodejs

Localization, Meetup API & Cloud Translation API sample (using Dialogflow) in Node.js
JavaScript
19
star
35

assistant-conversation-schema

JSON Schema types for fulfilling Actions SDK handlers for the Google Assistant
19
star
36

actions-builder-conversation-components-nodejs

Conversation Components sample (using Actions Builder) in Node.js
TypeScript
15
star
37

dialogflow-quickstart-nodejs

Documentation samples for Actions on Google (Dialogflow/Node.js)
JavaScript
14
star
38

actions-builder-hello-world-nodejs

Hello World sample (using Actions Builder) in Node.js
JavaScript
13
star
39

create-local-home-app

Create a new Local Home SDK app.
TypeScript
13
star
40

dialogflow-helper-intents-nodejs

Helper Intents sample (using Dialogflow) in Node.js
JavaScript
13
star
41

actionssdk-conversation-components-nodejs

Rich Responses sample (using Actions SDK) in Node.js
JavaScript
12
star
42

assistant-actions-nodejs

Node.js Actions API Client Library
JavaScript
12
star
43

actionssdk-updates-nodejs

Daily Updates & Push Notifications Sample (using Actions SDK) in Node.js
JavaScript
12
star
44

actions-builder-codelab-level-1

Actions Builder Codelab (Level 1)
JavaScript
11
star
45

dialogflow-facts-about-google-java

Custom Entities, Contexts, and Deep Links sample (using Dialogflow) in Java
Java
11
star
46

interactive-canvas-devtools

A Chrome DevTools extension for Interactive Canvas development
CSS
10
star
47

dialogflow-digital-goods-nodejs

Digital Purchase API sample (using Dialogflow) in Node.js
JavaScript
9
star
48

dialogflow-google-sign-in-java

Google Sign-In sample (using Dialogflow) in Java
Java
8
star
49

dialogflow-conversation-components-java

Rich Responses sample (using Dialogflow) in Java
Java
8
star
50

dialogflow-name-psychic-java

Permissions, SSML, Surface Transfers, and Google Maps Static API sample (using Dialogflow) in Java
Java
8
star
51

actionssdk-shiritori-ja-nodejs

しりとり AoG サンプルゲーム
JavaScript
8
star
52

actions-builder-account-linking-nodejs

Account Linking sample (using Actions Builder) in Node.js
JavaScript
8
star
53

actions-builder-patterns-nodejs

Common design patterns for Actions Builder
JavaScript
8
star
54

user-engagement-codelab-nodejs

User Engagement Codelab - https://codelabs.developers.google.com/codelabs/actions-user-engagement
JavaScript
7
star
55

actions-builder-custom-nlu-nodejs

Custom NLU sample (using Actions Builder) in Node.js
JavaScript
7
star
56

actions-builder-codelab-level-2

Actions Builder Codelab (Level 2)
JavaScript
7
star
57

actions-builder-canvas-codelab-nodejs

JavaScript
6
star
58

dialogflow-transactions-java

Physical Goods Transactions API sample (using Dialogflow) in Java
Java
6
star
59

actionssdk-updates-java

Daily Updates & Push Notifications Sample (using Actions SDK) in Java
Java
6
star
60

actions-shortcut-convert

Kotlin
6
star
61

dialogflow-silly-name-maker-webhook-java

Parameters sample (using Dialogflow) in Java
Java
5
star
62

actions-builder-transactions-nodejs

Transactions sample (using Actions Builder) in Node.js
JavaScript
5
star
63

dialogflow-quickstart-java

Documentation samples for Actions on Google (Dialogflow/Java)
Java
5
star
64

actionssdk-say-number-java

SSML sample (using Actions SDK) in Java
Java
4
star
65

app-actions-dynamic-shortcuts

A sample app that demonstrates how to push dynamic shortcuts that can be displayed in Google Assistant.
Kotlin
4
star
66

actions-builder-updates-nodejs

Daily Updates and Notifications sample (using Actions Builder) in Node.js
JavaScript
4
star
67

smart-home-error-reporting

HTML
3
star
68

dialogflow-number-genie-java

Localization sample (using Dialogflow) in Java
Java
3
star
69

actionssdk-quickstart-java

Documentation samples for Actions on Google (Actions SDK/Java)
Java
3
star
70

actionssdk-vscode-extension

2
star
71

actions-on-google-linter-nodejs

JavaScript
2
star
72

dialogflow-session-entities-plugin-nodejs

TypeScript
2
star
73

dialogflow-helper-intents-java

Helper Intents sample (using Dialogflow) in Java
Java
2
star
74

dialogflow-interactive-canvas-codelab-nodejs

Interactive Canvas with Dialogflow Codelab
JavaScript
2
star
75

actionssdk-conversation-components-java

Rich Responses sample (using the Actions SDK) in Java
Java
2
star
76

dialogflow-updates-java

Daily Updates & Push Notifications Sample (using Dialogflow) in Java
Java
2
star
77

dialogflow-digital-goods-plugin-nodejs

TypeScript
1
star
78

actions-builder-canvas-angular

TypeScript
1
star
79

dialogflow-ssml-java

SSML sample (using Dialogflow) in Java
Java
1
star
80

actionssdk-quickstart-nodejs

Documentation samples for Actions on Google (Actions SDK/Node.js)
JavaScript
1
star
81

actions-builder-location-nodejs

JavaScript
1
star
82

dialogflow-quotes-java

External API sample (using Dialogflow) in Java
Java
1
star
83

.allstar

1
star
84

actions-builder-facts-about-google-nodejs

Facts About Google sample (using Actions Builder) in Node.js
JavaScript
1
star