Advertising sustains the DA. Ads are hidden for members. Join today

Tutorial

Last updated on
11 May 2017

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 to set up your interaction model for Alexa Skills. Please see: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/get...

Requirements

There are some requirements for your Drupal site that must be met to integrate with the Alexa Service:

  1. Your site has to be accessible online - Amazon's Alexa Service will be sending requests to the /alexa/callback path on your site.
  2. Alexa Service callbacks can only be made via HTTPS, so your site must support it. A self-signed certificate can be used during Skill development, but a certificate signed by a trusted Certificate Authority is required to publish Skills.

Create an Amazon Skill

  1. Go to https://developer.amazon.com and sign in with your Amazon account.
  2. Click Alexa in the top menu.
  3. 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
  • Give your skill a descriptive Name
  • For Invocation Name, use a short phrase of your choice such as My Application
  • On the Interaction Model tab
  • On the Configuration tab
    • For Service Endpoint Type, choose HTTPS
    • Choose the geographical region(s) nearest your customers
    • Enter the endpoint URLs in the text boxes for your region(s). They should be in the form: https://your.site/alexa/callback
    • Choose No for Account linking
  • On the SSL Certificate tab, choose what kind of SSL certificate your site is using. If you're using a self-signed certificate, you'll need to upload it.
  • Save the configuration.
  • Write down the Application Id back on the Skill information tab. It should be something like: amzn1.ask.skill.11111111-2222-3333-4444-555555555555

Integrate with Drupal

  1. Install the Alexa module using Composer:
    composer require "drupal/alexa". You should run this command from wherever your composer.json for your entire Drupal site is located.
  2. Enable the Alexa module.
  3. Enable Alexa Demo (alexa_demo) module.
  4. While logged into your site as an administrator, go to Config -> Alexa Configuration and put in the Application Id you noted earlier.

Test

If you have Amazon Echo and it's linked to the same Amazon account you're using to developing this skill, you can now say: Alexa, ask {your invocation name} hello drupal from {your city}

If you don't have Amazon Echo yet or you want to quickly test the skill integration, go back to your Alexa Skill on the Amazon Developer console. From the Test tab you can type in the text equivalent of what you'd speak into an Amazon Echo device into the Service Simulator. Try it out by typing in "help" and clicking the Ask {your invication name} button. You should receive a JSON 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": {}
}

Help improve this page

Page status: No known problems

You can: