This is an Alexa skill that spits out facts about Buildit
Alexa is awesome. It's the future. It's a technical challenge:
- To not use Lambda (like most of the demos do), but rather host the skill's implementation on a server, forcing us to learn how to install certificates.
- To not use JS (like most of the demos do), but rather use Ruby/Rails.
- To find a way to TDD our way out of this, as most demos do not refer to command-line testing frameworks.
- To write an Alexa skill that's backed by a data store
- To be able to handle conversations.
'Alexa, tell buildit to list people in the NY office'
- Install bundler
Run
bundle
The database connection use the following environment variables:
export ALEXA_DB_USERNAME=<insert your db username here>
export ALEXA_DB_PASSWORD=<insert your db password here>
rake # => Will run RSpec unit and integration tests (audio integration tests are excluded)
rake spec
bundle exec rake
bundle exec rake spec
rspec
rspec --tag audio # => Will run the full integration suite with audio. Make sure ngrok is running.
Before installing certificates that are needed for real Alexa interactions, you may use postman to simulate them, posting to localhost:3000.
You can test intents and their replies when Amazon against your local dev by using ngrok.
Run it in a shell and take note of the public DNS you get, for example:
http://c68d7548.ngrok.io
.
When you run the app locally, anything sent to that address will end up on your localhost:3000.
Install a self-signed certificate so that Amazon will route Alexa interactions to the ngrok address. Once that is done, register the skill with Amazon, and test live by issuing Alexa requests.
- Create a configuration file
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = US
ST = $your-state$
L = $your-city$
O = $your-organization$
CN = $your-skill-name$
[v3_req]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @subject_alternate_names
[subject_alternate_names]
DNS.1 = $ngrok-address$
Make sure to replace the keywords enclosed in '$' to have your own data.
- Create the certificate
openssl genrsa 2048 > private-key.pem
openssl req -new -x509 -days 365 -key private-key.pem -config cert.cnf -out certificate.pem
Your server certificate is certificate.pem and will be needed when you create the app. Copy the contents into the certificate text field in the portal.
-
Enable for testing It's not very intuitive, but the progress-UI does not change when you select 'enable for testing'. Effectively, you can skip the production version questions if you're in testing mode.
-
Certificate Paste the contents of
certificate.pem
in the text box. -
Language selection Note that Alexa classifies English US and UK as two different languages. So if you program for US, but Alexa is set to UK, your skill will not be called.
-
Enable skill on device Use the Alexa app on your phone or Alexa device to enable the skill.
- Run
ngrok
to forward traffic to the app (assuming it's in /usr/local/bin)
/usr/local/bin/ngrok http -hostname=alexa01.ngrok.io 3000
- Run Rails in debug mode:
rails s
- Go to the Alexa dev page to the 'test' section and make sure your app gets called.
You can also see
ngrok
status athttp://localhost 4040
brew update
brew install awsebcli
See file.
Creative commons, see file.
- Repo owner or admin: [email protected] ([email protected])