Creating an Alexa Skill

I have been trying to use the self-hosted HTTPS version for months (with the valid-request PHP code to handle certificates, etc.) and have never been able to get it to complete their validation/submission process.

I even attended a Q&A session with Amazon Developers and nothing was ever solved. They said they would look into it but nothing has changed. I would recommend switching to the Lambda option.

Screen Shot 2016-08-16 at 11.22.32 AM

After switching everything was much faster. So here are some tips and even the exact code I used to make the Skill.

1. Follow the example to get the Lambda setup

They have a good example to set up the function and get your accounts linked. I would recommend following their instructions on creating the Lambda function in AWS.

Notes on process:

  • I used node.js so my sample code will be that.
  • I used alexa-skills-kit-color-expert as the blueprint.
  • I got a little tripped up with having different options of the Role/Policy stuff. In the end, I used ‘Create new role from template’ and selected ‘Simple Microservice Permissions’

Screen Shot 2016-08-16 at 11.30.00 AMScreen Shot 2016-08-16 at 11.30.12 AM

2. Example Code

I built the Alexa skill for and you can access the entire node.js function and the PHP code here:

bibletalk_alexa.js bibletalk_alexa.php bibletalk_event_handler.php



The ‘pingReturn’ function calls my API for data and simply returns JSON properly formatted so there is no extra work in the lambda function needed.

The PHP functions calling the intent: intent_latest('sermon') for example, returns a simple Object:

$rtn = new stdclass;
$rtn->speech = "This is what is said";
$rtn->item = "Item object used to fill the Card in the Alexa App";

The API endpoints are very simple. Here is an endpoint on the site which looks like this:

Screen Shot 2016-08-16 at 11.34.36 AM

This data matches the response that is required to return in the Lambda function, we simply just pass it back through.

Example callbacks

Here are a few of the other intents just to see how data is returned:

Here are some intents for playing Audio:

Intent: PlayAnything play {Keyword}

Intent: PlayAnItemInSeries play lesson number {Lesson} of {Series}

A few hiccups

My first submission failed for the following reason:

The skill does not exit appropriately when users say “stop” and “cancel”.

So if a user would say ‘Launch BibleTalk’ my response would end with “What do you want to do?” and if the user said ‘Cancel’ it would launch the LaunchRequest again instead of the CancelRequest.

To fix this I needed to include the built-in Help, Cancel and Stop Intents to my Intent Schema:

Screen Shot 2016-08-16 at 11.39.30 AM

I hope this helps you get your Alexa Skill made. It can be fun to experiment with new technology but when it never works properly, it can turn sour quick. Thanks for reading!