You have probably come from our project here where building the hardware for the Smart Kitchen Cube is explained in detail. In case you feel like tinkering with the software stack, this is the right place to pick up from where you left. We will go through the steps to create your own skill, get a copy of the skill's sourcecode and set up the Lambda function for the skill to i
AWS LambdaIf you create your own skill it needs to be linked to a Lamda function which takes care of handling requests and creates the binding to the Particle Cloud, which will then handle communication to your Arduino and Particle Photon devices. Again, you can skip this step if you use our published Alexa Skill. You will just have to activate it from your Alexa App and link it to your Particle account.
For those of you who would like to tinker with the Lambda and the Skill, here is the detailed writeup of steps necessary to get your Lambda function running. First head over to https://aws.amazon.com/lambda/ and sign in to the console via the big yellow button in the right top corner.
After logging in, click on "Lambda" in the AWS services area of the website. Click on "Create function", note how the one used by our skill is already present in the list.
... to be finished ...
select java 8
obtain endpoint id for skill
done.
Obtain the source code & deployYou can download or clone or fork the sourcecode at GitHub. Either way, you will have to set up a Eclipse project and download the AWS integration for Eclipse. This exceeds this projects scope, so head over to Amazon for further details in case you don't know how to set this up.
When you deploy your Lambda via Eclipse, you should be able to see the Lambda function created in the previous chapter and select it. After successful deployment, which should only take a couple of seconds, your Lambda is good to go!
Alexa SkillFirst stop for getting started is Amazon Alexa which you have to sign up to on the Amazon developer website. Head to the skill creation page at the Developer Console. Select the Smart Home Skill API and enter a name, leave the language set to English (U.S.), as this is a requirement for Smart Home Skills for cooking appliances.
On the left you see a list with checkmarks that indicate what else you will have to set up, so lets get going. There is no Interaction Model for Smart Home Skills, so leave it as is.
On the Configuration tab, you need to set up quite a few things and this step requires some of the data from the previous chapters, so make sure you finished setting that up.
- Endpoint: Copy your endpoint id (starts with arn:aws:lambda:...) to the default field.
- Provide geographical region endpoints?: Check yes, tick "North America" and enter the same endpoint id.
- Account Linking . Authorization URL: We want to authorize against the particle cloud, so we need to fill their OAuth2 URL which is https://api.particle.io/oauth/authorize
- Client Id: We will create this in a moment.
- Domain list: Don't add anything.
- Scope: Enter "profile" in field 1.
- Redirect URLS: Take note of the one with pitangui.amazon.com in it.
- Authorization Grant Type: "Auth Code Grant"
- Access Token URI: https://api.particle.io/oauth/token
- Client Secret: We will create this in a moment.
- Client Authentication Scheme: Leave set to HTTP Basic.
- Privacy Policy URL: In case you want to publish your skill, fill in a link to a website where you have a Privacy Policy set up. Otherwise leave blank.
We do not have to fill in anything at the Publishing Information and Privacy & Compliance tabs, so lets create the data for the "Client Id" and "Client Secret" fields.
Fill in the
- YOUR_APPLICATION_NAME (choose to your liking)
- YOUR_PARTICLE_ACCESS_TOKEN (from chapter Particle Cloud)
- YOUR_PITANGUI_REDIRECT_URI (from this chapter)
and run this from your terminal (mac, linux) or Ubuntu shell (Windows 10):
curl https://api.particle.io/v1/clients -d name=YOUR_APPLICATION_NAME -d type=web -d access_token=YOUR_PARTICLE_ACCESS_TOKEN -d redirect_uri="YOUR_PITANGUI_REDIRECT_URI”
It will return a JSON string with your "secret" and "id" which you need to fill in to "Client Secret" and "Client ID" fields. Your Alexa Skill is now ready for testing, i.e. available in your Alexa App or via alexa.amazon.com.
Done!You have successfully build your own Smart Kitchen Cube and connected it to your own Alexa Skill with an AWS Lambda function for communication between your skill and the particle cloud. Good work, we hope you enjoyed the project!
Comments