Coloring books for grown-ups are a growing trend. Usually, they are meant for kids, but now there are a lot of adults that seek the calmness and zen moment a coloring session can bring.
My wife is, at the moment of the writing, 31 weeks pregnant. We have two more children and she is also studying a Master degree. So she gets a bit stressed at times. When that happens she likes to color. Looking for something to color on internet can easily spoil the moment when you are trying to relax and relieve some stress. That's when we thought that Alexa could help us to just print something. No computer, no tablet, no phone, easy and fast.
Installing and using the Coloring Pages skillYou can find the Alexa Skill in the Amazon Alexa Skills store:
You'll need to link you Google Account and have a printer associated with it.
Now I'll walk you through the process of installing this skill on your own infrastructure.
Instructions to install your own copyGOOGLE DEVELOPERS
API KEY and OAuth Client ID
You'll need a Google Developers account. At the console, you will be able to set up an API key and an OAuth application.
For the API key, you just click the API key option in the create credentials button and you'll be able to copy the key.
When you create the OAuth client ID, you'll get a Client ID and a Client secret which you'll use later.
Also, you need to add the authorized redirect URLs that you'll get from the Alexa Skill Developer Console.
Custom Search
You'll need to create a Custom Search so you can get images from google results. https://cse.google.com
When you add a search engine, you'll need to specify in what domains the search will be performed in the "Sites to search" fields.
Then go to the control panel for the newly created search engine. Make sure you have enabled the images search.
Click on the Search engine ID button to and take note of that code.
ALEXA SKILL
Ok, now we need to create the Alexa Skill in the Amazon Developers console.
- Create a new custom skill
- Choose an invocation name
- Set up the interaction model. Intent schema, custom slots types and sample utterances are provided in the
/speechAssets
folder in the code repository.
- In the configuration tab you need to setup the account linking.
- Set up the endpoint, we'll use a lambda function, we'll setup this step after we have created the lambda function and obtain an ARN. (Lambda function id)
A skill ID will be assigned to your newly created skill.
Account Linking
Account linking well let you authorize the skill to do manage the user printers.
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline
You got the client id in the Google developers console
https://www.googleapis.com/auth/cloudprint
https://www.googleapis.com/auth/cse
These are the Redirect URLs you have to authorize in the Google OAuth configuration step.
https://www.googleapis.com/oauth2/v2/token
You got the client secret from the Google developers console
Lambda Function
We need to set where the skill should make a call with the payload after it already understood the voice input using the interaction model.
In this case, we are using AWS Lambda function.
You'll get the ARN from the lambda function after you create it.
ENDPOINT USING LAMBDA FUNCTIONS
Go to de AWS console to create a new lambda function with the application that will provide the skill the functionality.
- Create a new function starting from the blank template
- Configure the triggers
- Configure function
- Add environmental variables to configure de application
- Build and upload the code
Once you create the function, you'll get the ARN which you need to setup the Alexa Skill endpoint.
Configure the triggers
Choose the Alexa Skills Kit
Configure function
You'll need to choose a name and choose Node.js 4.3
as a runtime
Setup the application
Set the following environmental variables:
- ALEXA_APP_ID: is the skill ID you got when the skill was created.
- CSE_API_KEY: is the API key you created in the developers console
- CSE_CS: is the Search Engine ID you got when setting up custom search
Build and upload the application
You'll need to clone the git repository from Github.
git clone https://github.com/blackjid/coloring-pages-skill
cd coloring-pages-skill
Install the project dependencies
npm install
The project is written in Typescript so you'll need to compile it before uploading it to lambda.
npm run build
The build script on the package.json
will compile the typescript into javascript, install production dependencies in the built
folder and compress the built
folder into dist/coloring-ages.zip
Now you can upload the zip file to your lambda function.
Comments