Smart home Actions are structured differently than traditional Actions. The process for how users trigger actions and the actions' conversations are handled for you; all you need to do is handle smart home intents on your service.
For a full end to end sample of a Google smart home Action:
If you are not using the end to end sample, follow these instructions.
To create a smart home Action:
- Set up an OAuth 2.0 server for account linking.
- Create an Actions on Google developer project.
- Add authentication to your project
Set up an OAuth 2.0 server
Make sure that you have a public OAuth 2.0 server for authenticating users.
Authentication allows you to link your users' Google accounts with user accounts in your authentication system. This allows you to identifiy your users when you receive a smart home intent on your fulfillment. Google smart home only supports OAuth with an authorization code flow.
For smart home, you need to use OAuth with an authorization code flow, which required you to have two endpoints, the authorization and token exchange endpoints. See account linking with OAuth.
When you have authenticated a user, the user's third-party OAuth 2 access token
is sent in the Authorization header when smart home intents are sent to your
fulfillment. All users have to perform account linking, because device
information is sent to the Assistant with the
intent, which requires account linking.
Your smart home Action is expected to support multiple Google users connecting to the same user account (for example, when users give access to other users in their household). If your service can't support multiple user connections, it should provide errors at account linking time.
Create an Actions on Google developer project
To create a developer project:
- Go to the Actions console.
- Click Add/import project.
- Enter a name for the project and click CREATE PROJECT.
- Once your project is created, click Home control.
- Click Smart home.
- From the Quick Setup, click Name your first smart home Action. Then, click SAVE. This is the app name that you can connect to from the Google Home app.
- From the left Build navigation menu, click Actions.
- Click ADD YOUR FIRST ACTION.
- In the Add fulfillment URL text box, enter a URL for the backend server that will provide fulfillment for the smart home intents and then click DONE. For information on how fulfillment works, see fulfillment and authentication.
- Click TEST. This now lets you test your smart home Action from the Google Home app. The name of an app that has not been submitted beings with [test].
You have successfully created a smart home Actions project and provided a fulfillment URL. You can now add authentication to your project.
Add authentication to your project
- Go to the Actions console.
- Select your smart home Actions project.
- From the left Advanced Options navigation menu, click Account Linking.
- In the Account creation section, select No, I only want to allow account creation on my website. Voice account creation is not supported for Google smart home.
- In the Linking type section, select OAuth authentication and a Authorization code grant type. Then, click Next.
- Fill out the information for your authentication service and click Next.
- Optionally, add additional information for your users when they create an account.
- In Testing Instructions, a username and password for a test account for Google to review your smart home Action. Then, click Save.
You have successfully added authentication to your smart home Action project. You are now ready to create the logic to process smart home intents. See process intents.