[0:00]Hello, my name is Paul, and I'm a developer advocate for the Google Assistant. And today, I'm going to take you through how to use the Google Assistant to control smart home devices and services. This is important because these are some of the most popular uses for the Google Assistant, and they make it very compelling to a large audience. And this is not just to control individual devices. Your users can control multiple devices at once. They can control devices based on routines, and they can do this using many different types of Google Assistant devices like smart displays, smart speakers, and their phones. And it makes it very compelling for developers to bring their smart devices and services into the Google Assistant because it means that they're connecting to this large ecosystem of Google Assistant devices and users. So, let's take a look at what we're going to cover today. We're going to start by going through how smart home works and how it connects into the Google Assistant. Then we're going to talk about building your first smart home action. We'll show you how to start the development process and set up your development environment. Then we're going to go through how to test your smart home action using the Google Home app and the Assistant simulator. Then we're going to dive into some more advanced topics that include how to actually deploy your smart home action and maintain it in production and look at some of the things that you should be considering for going to production with your smart home action. And then we'll wrap up with some additional resources that are available for you to learn more about developing for smart home on the Google Assistant. So let's start with how smart home works. And there are three main components that connect together to make a smart home action work with the Google Assistant. And the first is your cloud infrastructure. And this is where all of your smart devices connect into and get their commands and send their state to your cloud infrastructure. And you as the developer will have access to this cloud infrastructure to do things like send commands and get the state of your devices. Then the second component is the Google Assistant. And this is what the users are going to be interacting with to send commands to their devices and ask questions about the devices and their state. And then finally, the third component is the cloud-to-cloud connection between the Google Assistant and your cloud infrastructure. And this is an important part of the architecture, because it means that you don't actually need to write any code to integrate with the Google Assistant. You just need to provide an API that the Google Assistant can then use to connect into your cloud infrastructure and send commands and get state. And this also makes the experience of developing and using smart home devices very fast and very responsive, because the connection is directly between the Google Assistant in the cloud and your cloud infrastructure. And so, there are two key parts to connecting your cloud infrastructure to the Google Assistant. And the first is the authentication. And so, the Google Assistant will use something like OAuth to connect into your cloud infrastructure and make sure that the user is properly authenticated and authorized to use the device. And then the second part is the fulfillment, which is your API that the Google Assistant will call to send commands to your devices and also to query the state of your devices. And then there's a third component that is available as part of the smart home architecture, which is local fulfillment. And this is an SDK that you can use to add to your existing local area network to allow your smart devices to directly connect to the Google Assistant on devices like smart speakers and smart displays, and it enables two key things. The first is that it makes your smart home actions even more responsive, because the connection is going directly from the Google Assistant to the device without having to make a round trip into the cloud. And the second is that it adds more reliability for your smart home actions, because if the internet connection is not available, the user can still use the Google Assistant to control their devices and query their state. So now that we've gone through how smart home works, let's take a look at building your first smart home action. And there are four key steps that you'll need to follow. The first is to register as a developer. The second is to create a new project in the Google Cloud console. The third is to implement your authentication and fulfillment in your API, and then the fourth is to connect it into the Google Assistant. So let's start by registering as a developer. And you'll go to the actions on Google console to get started, and this is where you can manage your actions, see analytics, and get access to other developer tools. So after you've registered as a developer, you'll want to go into the Google Cloud console to create a new project. And this is where you can manage things like your authentication, your APIs, your identity, and your security. And in the Google Cloud console, you'll be able to create new projects and also manage your existing projects. And then in the Google Cloud console, you'll also want to go to the API and services section to enable the Google Assistant API, which will then give you access to using smart home and other functionality provided by the Google Assistant. Then after you've created your project, you'll go back to the Actions on Google console to start building your smart home action. And you can start by clicking on the new project button, and that will take you through the wizard to create a new project. And in the new project wizard, you'll see a selection of the different types of actions that you can create with the Google Assistant, and you'll want to choose the smart home action. And that will take you into the smart home development console. And this is where you can start to provide the information that the Google Assistant needs to connect to your smart devices and services. And the first section that you'll want to pay attention to is the account linking section. And this is where you'll tell the Google Assistant about how to connect to your authentication to authenticate the users and authorize them for their devices. And as part of the account linking section, you'll provide the OAuth client ID and the client secret, the authorization URL and the token URL, which is how the Google Assistant will then connect to your cloud infrastructure to handle the authentication and authorization. And it's important to keep in mind that your smart home action is directly connecting to your existing authentication infrastructure, so you don't need to write any new code or manage any new authentication just for the Google Assistant. Then after you've provided the information for the account linking, you'll want to make sure that you go to the development environment and make sure that you turn on the testing on device, which will then make your smart home action available for you to test on your own devices. So now that we've gone through how to start building your first smart home action, let's take a look at how to actually test your smart home action. And there are three key steps for testing your smart home action. The first is to test the account linking and the authentication and authorization. The second is to use the Google Home app to set up your smart home devices. And then the third is to use the Assistant simulator to then test the actual commands and queries for your smart home action. So let's start with testing the account linking. And in the Google Home app, you'll go to the plus button at the top left of the home screen, and that will then take you to the add and manage screen. And then you'll want to choose the set up device and then you'll want to choose the works with Google option. And this is where you'll find the different devices and services that are available for the Google Assistant. And at the bottom of the list, you'll find your own test app, which will be available with the name that you provided as part of the setup. And when you click on your test app, that will then take you to your own authentication login screen, which will then use the OAuth client ID and client secret to then authenticate the user and then authorize them for the devices. And after the user is authenticated and authorized, they'll then be redirected back to the Google Home app, and then the Google Assistant will call your fulfillment and ask for a list of the devices that are available to the user. And this is when you'll be able to see the devices that you've connected to your smart home action. And then finally, after you've successfully connected your smart home action, you'll be able to use the Assistant simulator to start sending commands and queries for your smart home action. And so for example, you can say turn on my lights, or set the temperature to 72 degrees. So now that we've gone through how to test your smart home action, let's take a look at how to deploy your smart home action and maintain it in production. And there are four key steps that you'll need to go through. The first is to implement the local fulfillment SDK if you want to use local fulfillment. The second is to use the reporting state to report the state of your devices back to the Google Assistant. The third is to use Google Cloud logging to get access to logs from the Google Assistant about the requests and responses. And then the fourth is to go through the release process to then make your smart home action available to all users. So let's start with the local fulfillment SDK. And this is an optional SDK that you can include with your smart home action to enable local fulfillment. And the key component is the local fulfillment app, which is a JavaScript bundle that you can then host on your local area network devices like your smart hubs or your smart devices. And this local fulfillment app will then handle the communication with the Google Assistant and then send the commands to your local area network devices. So the next part is the reporting state. And this is an important part of the smart home architecture because it allows you to then report the actual state of your devices back to the Google Assistant, so that the Google Assistant has the most up-to-date and accurate information about your devices. And so, for example, if a user turns on their lights using a light switch, your cloud infrastructure can then report the state back to the Google Assistant to let them know that the lights are on. And this also means that when a user asks, are my lights on, the Google Assistant will have the most up-to-date information about the lights being on. The next part is Google Cloud logging. And this is an important tool that's available to you to get access to the logs from the Google Assistant about the requests and responses that are going to your fulfillment. And this is a really important tool for you to debug and understand what's happening with your smart home action and make sure that everything is working properly. And then finally, after you've implemented all of the functionality for your smart home action, you'll go through the release process, which includes filling out some directory information and providing your privacy policy and other information that's required for the Google Assistant. And then after your smart home action has been approved, it will then be available to all users on the Google Assistant. So now that we've gone through how to deploy your smart home action and maintain it in production, let's take a look at some additional resources that are available. And the first is the smart home documentation. And this is a great resource for you to learn more about developing for smart home on the Google Assistant. And it includes things like getting started guides, tutorials, and also references for all of the different APIs and functionality that's available for smart home. The next resource is the smart home codelab. And this is a self-guided tutorial that takes you through how to build a smart home action from start to finish. And this is a great way for you to get hands-on experience with building a smart home action and seeing how everything connects together. The next resource is the sample smart home action. And this is a complete smart home action that you can then use as a reference for your own smart home action. And it includes all of the code and functionality that's required for a smart home action, so you can then use it as a starting point for your own development. The next resource is the smart home community form. And this is a great place for you to ask questions, get help, and connect with other developers who are building for smart home on the Google Assistant. And the final resource is the smart home office hours. And these are weekly office hours where you can connect with the Google Assistant team directly and ask questions, get help, and get feedback on your smart home action. So thank you for taking the time to learn about developing for smart home on the Google Assistant. And I hope you have a great time building your own smart home actions.
Watch on YouTube
Share
MORE TRANSCRIPTS



