Integrating Google Home And IFTTT Webhooks

In this post I’ll be integrating Google Home and IFTTT Webhooks. Before we begin it is important to understand you are not specifically targeting Google Home devices but rather Google Assistant. Google Assistant can be running on a multitude of different devices like phones or tablets that are not necessarily on the same local network as your Google Home device. With that in mind it makes sense that any HTTP connections made from Google Assistant and IFTTT will be executing in the cloud not the device your are using. To reach local endpoints from Google Assistant you need a publicly accessible endpoint which means you have to open ports on your firewall, have a static IP or DNS name and a web server running to respond to the HTTP calls. Alternatively you can use a relay service like Azure Relay Hybrid Connections or one of the self hosted open source options like Thinktecture RelayServer to enable public connections without opening firewall ports. Both solutions bring up a host of security considerations which I decided to bypass for now by using Azure Functions as the target for the HTTP calls for testing.

The Solution

Connect Your Google Account And IFTTT
This is pretty straight forward so I won’t be explaining the process, just follow this example it.

Create The Azure Function
You can start with a basic HTTP triggered function using this example. For added security I’ll be making a few changes to the function.

  • Under Function App settings -> Networking -> SSL, switch on HTTPS only.
  • Under Integrate  -> Selected HTTP Methods uncheck everything except POST.
  • Under Integrate -> Authorization level select anonymous.

At the time of writing IFTTT didn’t support custom headers in their WebHooks but I needed a way to send an auth key to the Azure Function. I decided to add the auth key to the body of the request and confirm the key myself. Usually you rely on the Azure Functions builtin authentication functionality that requires an “x-functions-key” header.

To test the WebHook call I wanted to extract information like the auth key, ingredient and calling IP address to display it in the log file. You can find the C# code I used in my function here.

Create The IFTTT Applet
In IFTTT create a new applet and choose Google Assistant as the service and “Say a phrase with a text ingredient” as the trigger. Select Webhooks as the action. For this fictional scenario I wanted to shut down devices remotely so I configured my trigger and action like this.

Integrating Google Home And IFTTT Webhooks

Take note of the request JSON body, it contains the auth key and the text ingredient you specified in the trigger using the $ sign. You also have the option to use a number ingredient in which case you use a # sign to represent the number. Use the Add Ingredient button to add your ingredient to the request body or URL, don’t type $ or #.

And here is the result.

Integrating Google Home And IFTTT Webhooks

I tested from my phone but it worked the same from Google Home, just no screenshots 🙂

Francois Delport

Published by

Francois Delport

I am a cloud and devops consultant, technology fan and previously a professional C# developer with a keen interest in system design and architecture. Currently I am involved in projects using Azure, the Microsoft stack and DevOps. I am based in Melbourne, Australia. Email: [email protected]

Leave a Reply

Your email address will not be published. Required fields are marked *