Last updated 5 January 2017. Created on 6 April 2016.
Edited by yas, meba, hampercm. Log in to edit this page.

See Alexa for the contributed module. In this basic example we will create an Alexa Skill that you will be able to invoke from your Echo by saying "Alexa, ask hello drupal from New York City" and Alexa will respond "Hello Drupal to New York City".

There is extensive documentation on how your interaction model should look like for Alexa Skills, please see that: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/get...

There are minimal prerequisites for your application:

  1. Your site has to be accessible online - Amazon will be sending callbacks to a URL on your site.
  2. It has to use SSL, only HTTPS callbacks are allowed.

The steps are:

Create an Amazon application

Go to https://developer.amazon.com and sign in with your Amazon account
Click Alexa
Choose Alexa Skills Kit and add a new skill, call it Hello Drupal, and fill in the form:

  • For Skill Type, choose Custom Interaction Model
  • For Invocation name, use a short phrase of your choice such as my application
  • On the Interaction Model tab
  • On the Configuration tab
    • put in https://your.site/alexa/callback as your Endpoint
    • choose No for Account linking
    • On the SSL Certificate tab, choose what kind of SSL certificate is your site using
  • Save the configuration
  • Write down the Application Id back on the original Skill information screen

Integrate with Drupal

  1. Download the module and run Composer installation for the Alexa library:
    composer require jakubsuchy/amazon-alexa-php. You should run this command from wherever your composer.json for Drupal is.
  2. Enable Alexa Webhook module
  3. Enable Alexa Demo module
  4. Go to Config -> Alexa and put in the Application Id you noted from previous steps

Test

If you have Amazon Echo and it's linked to the same Amazon account you used when developing this skill you can now say Alexa, ask {your app invocation name} hello drupal from New York City

If you don't have Amazon Echo yet or you want to keep testing quickly, go to the Amazon Developer console and you can send custom commands on the Test tab. Type "help" and play. You should receive a response back that looks like this:

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "type": "PlainText",
      "text": "You can ask anything and I will respond with \"Hello Drupal\""
    },
    "shouldEndSession": false
  },
  "sessionAttributes": {}
}

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

semantictissue’s picture

Could we get a more detailed step by step for the "Integrate with Drupal" part? I'd appreciate a bit more clarification here.

Running into errors like "drupal-rebuild" doesn't exist. And how and where to integrate with the Alexa php module via composer.

meba’s picture

So that page is actually wrong - sorry for that.

You just need to do this from your Drupal install where your composer.json is:
composer require jakubsuchy/amazon-alexa-php

I'll update the page

mjsilverman’s picture

If you want to retrieve values from the Response use the following within the event listener.

$request = $event->getRequest();
$city = $request->data['request']['intent']['slots']['City']['value'];