Pages

Alexa to IFTTT to D-Link in the UK Pt 2

**UPDATE - IFTTT now supports Alexa in the UK.  This is posting isn't the best way to do this anymore! It's still useful if you want to know how to call a REST API form Alexa though **

This follows on from part one, but if you know how to create IFTTT Maker recipes and just want to know how to do the Alexa bit then this is all you need.

Here's the first part of the tutorial:

http://www.mwebb.me.uk/2016/12/alexa-to-ifttt-to-d-link-in-uk-pt-2.html

The short version is:

1) Follow this tutorial:


2) Then replace the bits with files from this repo:

https://github.com/michaeldwebb/alexa-itfff-uk

a) Take the .js file, replace <myIFTTTkey> with your IFTTT key and paste it into the code
b) Take the intent.json file are replace the the contents of the intent box.
c) Take the utterances file and replace the content of the utterances box.

btw my activation word is 'Helper Monkey' (Alexa seems to understand that ... and http://simpsons.wikia.com/wiki/Mojo_the_Helper_Monkey)

How it works

I don't think the Amazon documentation does a great job of explain how things work. Here's my attempt.

Your application needs one or more 'Intents'.  These are things the use wants to do.  In my simple case,  there are two possible intents - turn the lights on, and turn the lights off.  You give these a name in the json file (LightsOnIntent, LightsOffIntent).

Then you need to think of all the things your users might say to trigger the intent. So if they want to turn the lights on they make say things like 'Lights on','Turn the lights on' etc.  You just need to associated each of these phases in the utterances file.

eg: 

LightsOnIntent lights on
LightsOnIntent start my lights
LightsOnIntent turn the lights on

So if the user says any of those phrases (lights on, start my lights, turn the lights on)  then the lights will turn on.

So the basic structure of the code is as follows:

Does the user just say the activation phrase (the one you set when setting up the skill)?
If yes:  do the welcome action (in our case, just saying hello).

Does the user just say a phrase associated with an Intent?
If yes: call the function to do that action.

In our case the function just used the node.js https function to call the IFTTT function.

Pretty straight forward.

As I said in the first tutorial, the big problem is the way IFTTT works - there can be lag of 15 minutes before the function is called, so really this is just a proof of concept than a working solution.






No comments:

Post a comment