This is a sample application showing how you can talk(literally!) to the front-end of a Rails application using the Alexa Skills Kit API and the Pusher API.
- You should have access to a server that can serve content via https. Amazon's Alexa API requires an SSL enabled endpoint.
- You'll want to create an account with Pusher and an Amazon Developer Account if you don't have them already.
- You will need
Rails 5.0.0
andRuby 2.2.4
installed locally. - You will need to handle deploying your app, which is not covered in this tutorial.
Login to your Pusher account, and create a new app. Take note of the app id, key, and secret, as you'll need them for the rails app.
Login to the Alexa developer's portal and follow the instructions to create a new Alexa Skills Kit
:
-
Skill Information: pick any names you want. Do not enable the audio player.
-
Interaction Model: copy and paste the contents
aws/intent_schema.json
andaws/sample_utterances.txt
into the appropriate fields. -
Configuration: select
https
and enter your endpoint, iehttps://your-website.com/api/alexa
-
SSL Certificate: You will need to provide an SSL certificate here. One option is to follow Amazon's instructions for how to generate a certificate for testing.
I did not do this. Instead, I copied and pasted an existing SSL certificate from my server. I used let's encrypt to configure SSL. If you are also using let's encrypt, your SSL cert should live here:
/etc/letsencrypt/archive/{name-of-your-website.com}/{your-certname-here}.pem
. All you need to do is copy and paste the contents when asked for an SSL cert. -
Test: You should now be ready to test your app. If you have not yet setup and deployed the rails app, do that first. Otherwise, try it out.
Before starting this, make sure you have the required Ruby version and Rails versions installed as specfied in the Gemfile
.
-
$ bundle install
install required gems
-
$ cp application.yml.example application.yml
-
- Replace the placeholder values in
application.yml
with your Pusher app id, key, and secret.
- Replace the placeholder values in
-
$ mkdir -p shared/pids shared/sockets shared/log
- add dirs for Puma
-
$ cp database.yml.example database.yml
-
$ rake db:create
- this is just to get the app running, we're not using a database for anything in this demo.
Once you've completed steps 1-3 and have deployed the application to your SSL enabled production server, you're ready to try it out. Either use the Alexa service simulator, or try it out with your alexa device.