An Alexa skill to finally get the answer to the simple question : How much it costs ? Introduction of the skill enabling Alexa to let you know the price of anything you think about.
This project has been started through the live contest "Hey Alexa!" (The Amazon Alexa Skill Contest on Hackster.io).
Amazon is the leader of online retailing but the Alexa has not the ability yet to answer any question how much cost things (except the Amazon echo device itself). The idea was as well to not only limits this search to product that you can find on Amazon but any kind of stuff a user may have in mind such as Tesla model S, Kobe Bryant newport beach house, travel to space, etc. by combining Amazon and Google Search.
- Enable the skill in the Amazon Skills Section at alexa.amazon.com.
- Say "Alexa, How much is the tesla model 3" to your Amazon device that supports Alexa (Echo, FireOS, FireTV, etc.)
- Alexa will prompt you the price found by my skill by first checking on Amazon and if nothing have been found it will then try other search engine (Google custom search for now).
Reading advice: Getting started guide for the Alexa Skills Kit
Alexa, ask How much is a tesla model 3
Alexa, ask How much cost the latest mac book pro
Alexa, ask How much worth the kobe bryant's newport beach house
In order to make this code works, you will need:
- Register to Amazon affiliate (https://affiliate-program.amazon.com/gp/advertising/api/registration/welcome.html)
- Create a Google Custom Search Engine and associated API credentials (https://console.developers.google.com and https://cse.google.com/cse)
- Set your credentials into 'credentials.ini'
To facilitate testing and interaction, a really simple command line is as well available. To install it you can simply:
git clone https://github.com/flochaz/the-price/
cd the-price
pip install .
(python2.7-venv)florians-MacBook-Air:the-price flochaz$ ask-the-price --help
Usage: ask-the-price [OPTIONS] ITEM
Main function to get the price of an item from a specific shop. If no shop
provided, default strategy will apply
Options:
--shop TEXT Narrow done the search to a specific shop
--help Show this message and exit.
- Amazon Productizing API
- Google Custom Search API
- I ran into some troubles mainly due to the fact that Amazon Produtizing API does not support IAM and Amazon Lambda does not support environment variables. These limitations forced me to leverage Amazon KMS Service to encrypt/decrypt credentials (for the good at the end).
- Packaging python for AWS Lambda was kind of a pain as well since I was relying on a lib called lxml which needs specific .so files compiled for Lambda runtime. So I had to spin up an AIM similar to amazon lambda to compile and extract lxml .so (that is the reason why you have this lxml folder into the repo).
- The lack of Alexa testing API complexify automated integration testing
Simply run tox in the project folder:
tox
WORK IN PROGRESS : Leveraging the hack proposed by Sam Machin (https://github.com/sammachin/AlexaPi) I am developing a Lib for Robot Framework to automate Acceptance tests
- implement capability to ask a search on a specific search engine (supported only through command line today)
- implement capability to ask for the search engine complete item description
- implement capability to ask and store response regarding the accuracy of the answer ("Does the answer sounds correct ?")
- Normalize returned price format
- Add acceptance tests
Pull requests are more than welcome! Once merged, project is automatically build, packaged, and uploaded to the AWS Lambda. Which will end up updating the Alexa Skill people play with in one click!
MIT