This project demonstrates the use of an Auth0 Webtask to integrate Google Home, IFTT, and MongoDB for keeping track of IOUs. Just say, "Hey Google. Create an IOU for Daryl for ten dollars", and a document is created in the database to record the person's name and the amount you owe them.
These instructions use the Webtask command line interface (CLI). Alternatively, you could adapt these instructions to use the Webtask Code Editor. Before proceeding with the install, ensure you have Node.js and Node Package Manager (npm, included in in Node.js), which can be downloaded here: (https://nodejs.org/).
In order to create the webtask, you'll need to provide a MongoDB URI which includes the login name and password for a MongoDB user that can write to the database.
Since the procedures for creating the database and user credentials vary slightly from hosting providers, the details for doing so are not included here. Once you have completed these steps, you should have a MongoDB URI such as
mongodb://<dbuser>:<dbpassword>@ds123456.mlab.com:23456/<dbname>
.
- Install the Webtask CLI by executing the following terminal command...
npm install wt-cli -g
- Initialize Webtask by executing the following command. Follow the prompts to provide an e-mail address of phone number to receive an activation code...
wt init
-
Clone or download this github repository. Alternatively, you can simply create the
i-o-who.js
file manually since it's the only source code you need.This example code uses ES6 arrow functions, but you can of course use the ES5 "function" keyword instead if you prefer.
-
Create the webtask on the webtask.io server by executing the following command. Make sure you substitue your MongoDB URI obtained previously...
wt create --secret MONGO_URI=mongodb://<dbuser>:<dbpassword>@ds123456.mlab.com:23456/<dbname> i-o-who.js
-
Copy the URL that was output in the last step. It should be similar to
https://wt-xxxxxxxxxxxx.run.webtask.io/i-o-who
- Login to ifttt.com.
- Create a new Applet
- For the +this part of the applet, choose the Google Assistant service.
- For the trigger, choose the Say a phrase with both a number and a text ingredient
- In the What do you want to say? field, enter Create an IOU for $ for # dollars. Optionally, you can provide other ways to say the phrase. Make sure the "$" is in the place where the user will speak the person's name (the text ingredient), and the "#" is in the place where the amount (the number ingredient) that is owed is spoken.'
- In the What do you want the Assistant to say in response?, enter Okay, I've added an IOU for $ for # dollars, again making sure the "$" and "#" are included to respresent the name and amount respectively.
- Click the Create Trigger button.
- For the +that part of the applet, choose the Maker Webhooks service.
- Click the Make a web request action.
- In the action fields, paste the URL that was returned from the
wt create...
command that run previously, adding querystring parameters for the name and amount values. For example,https://wt-xxxxxxxxxxxx.run.webtask.io/i-o-who?name={{TextField}}&amount={{NumberField}}
- Leave the Method field as GET, and the other fields blank.
- Click the Create action button.
- Click the Finish button.
Go to your Google Home, and say, "Hey Google, create an IOU for Daryl for ten dollars." If all goes according to plan, the Assistant will respond that it has created the IOU, and you will see the corresponding documenent in your database!
If things don't work out correctly, try adding console.log()
statements to your webtask script, recreate the webtask on the server, then run wt logs
on your local machine to watch log output.
One other thing I have found is that Google Home Assistant doesn't like certain phrases. For instance, I initially set the trigger phrase to, "I owe $ # dollars". However, Google Home responded that it didn't know how to help with that. I also tried, "Make a note that I owe $ # dollars", to which it responded, "Sorry, I can't take notes yet."
Another thing I have encountered is that the Google Assistant doesn't always recognize the phrase. For example, if I say, "Create an IOU for Daryl for ten dollars", it seems to consistently work fine. But if I change the amount, and say, "Create an IOU for Daryl for fifteen dollars", it usually responds that it doesn't know how to help with that.