<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Alexa - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Alexa - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 23 May 2026 22:21:19 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/alexa/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Improve Your Code With Alexa Response Interceptors ]]>
                </title>
                <description>
                    <![CDATA[ By Garrett Vargas I’ve published over a dozen Alexa skills over the last few years. I have run across several patterns and best practices in that time. One of the more powerful but under-hyped features of the SDK that I’ve made extensive use of in my... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-improve-your-code-with-alexa-response-interceptors-2b3e73721fc/</link>
                <guid isPermaLink="false">66c352cdd58e4fdd567d519e</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Alexa Skills ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 27 Dec 2018 16:39:57 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*d0I7athFoo0jgOpGMLPCKg.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Garrett Vargas</p>
<p>I’ve published over a dozen Alexa skills over the last few years. I have run across several patterns and best practices in that time.</p>
<p>One of the more powerful but under-hyped features of the SDK that I’ve made extensive use of in my code is the Response Interceptor. It is part of the <a target="_blank" href="https://www.npmjs.com/package/ask-sdk">Alexa Node SDK</a>. This SDK simplifies Alexa skill development.</p>
<p>When using it you may find your code getting messy with redundant error handling and clean-up tasks. Response interceptors allow you to insert a hook into the flow of handling Alexa intents. This keeps your code clean by performing last-minute actions in one central location before passing the response back to Alexa. This is extremely useful for <strong>debugging</strong>, <strong>resolving common tasks</strong>, and generally <strong>cleaning up responses</strong> to avoid some common errors encountered when using the Alexa ecosystem.</p>
<h4 id="heading-debugging">Debugging</h4>
<p>To add a response interceptor with the Alexa SDK, you pass a class that implements a <strong>process</strong> function to the addResponseInterceptors function on your SkillBuilder object as shown in the code sample below. We’ll get to the implementation details of this class in a moment.</p>
<p>This snippet also shows setting a request interceptor function which will run <em>before</em> a request is passed to your Alexa handlers. For example, I find it helps debugging to log each incoming request and the outgoing response. You can do this with the request interceptor and response interceptor as demonstrated in this code snippet. The snippet also shows the syntax for the process function returning an empty Promise.</p>
<h4 id="heading-resolving-common-tasks">Resolving Common Tasks</h4>
<p>Many of my skills process AMAZON.RepeatIntent so the user can re-hear the last response. If you have a complex skill, especially one that maintains state engines, you should provide additional detail when the user asks Alexa to repeat herself so the user knows exactly where they are. But in simpler skills, it’s fine to just replay the previous response back to the user. A response interceptor allows you to save each outgoing speech and reprompt cue so that you can re-play them easily:</p>
<p>Another common task is handling attributes. The Alexa SDK has several layers of attributes.</p>
<ul>
<li>request attributes (only good during a single request)</li>
<li>session attributes (good for the length of a session)</li>
<li>persistent attributes (saved in a store like DynamoDB to be used across sessions).</li>
</ul>
<p>I find juggling all of these can be overwhelming. I structured my code to only use session attributes, which I save to persistent storage at the end of the session. But there are two problems with this as a blanket approach — there are attributes that you may not want to save and there are times you want a value to pass between handlers but not across the session (what request attributes aim to solve).</p>
<p>I get around these problems by using a <strong>session</strong> and <strong>request</strong> object off my attributes. You can see an example of the session field in the above code snippet saving lastResponse and lastReprompt. I don’t want to save these persistently, so I clear this entire object before persisting to storage at the end of the session. In a similar fashion, I clear the request object each time at the end of my response interceptor, so those attributes truly remain request-only.</p>
<h4 id="heading-avoiding-common-errors">Avoiding Common Errors</h4>
<p>One of the limitations that plague many developers is that responses can’t contain more than 5 audio tags. Sometimes it can be difficult to avoid this with dynamic content.</p>
<p>For example in my Blackjack skill, I play a sound for each card that is dealt. Normally not a problem. But when reading out the dealer’s hand, if they end up drawing several cards you can go over this limit. Sure, I could try to catch this when I’m generating the response, but that convolutes the code. Who’s to say whether it hits every edge case?</p>
<p>Far better to remove the excess sound effects as part of the response handler. For this skill, I just remove excess audio files from the end of the response to get the count down to 5.</p>
<p>Another problem that I’ve encountered is that you aren’t allowed to return directives along with the Dialog.Delegate directive if you are eliciting slots from the user. This can be annoying if you are handling button input or using display directives. You might have to check in multiple places before adding directives to your response to make sure you don’t clash with the Dialog.Delegate. Keep your code clean and use a responseInterceptor to filter through your directives before returning instead:</p>
<p>I hope you enjoyed these tips and see the power of using response interceptors. Let me know your own best practices and share your own tips in the comments section!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to create a video channel for the Amazon Alexa Show without YouTube ]]>
                </title>
                <description>
                    <![CDATA[ By Terren Peterson I’m a software engineer that has published more than twenty custom skills on the Alexa platform. I’ve been recognized as an Alexa Champion, and have won multiple hackathons using the technology. The following highlights how I built... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-create-a-video-channel-for-the-amazon-alexa-show-without-youtube-92cea2cdcb7d/</link>
                <guid isPermaLink="false">66c351185a4b1b0639bef27f</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ videos ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 17 Jan 2018 13:04:08 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*yF98uEJJ2R1z3sxd8eAZ6Q.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Terren Peterson</p>
<p>I’m a software engineer that has published more than twenty custom skills on the Alexa platform. I’ve been recognized as an <a target="_blank" href="https://developer.amazon.com/alexa/champions/terren-peterson">Alexa Champion</a>, and have won multiple hackathons using the technology. The following highlights how I built a custom video skill for the Echo Show using native Amazon technology.</p>
<h3 id="heading-the-history-of-video-consumption">The History of Video Consumption</h3>
<p>Video broadcasting has been a successful medium for more than <a target="_blank" href="https://en.wikipedia.org/wiki/History_of_television">sixty years</a>. Television sets dominated the entertainment industry for decades with broadcast signals beaming directly into living rooms. In <a target="_blank" href="https://www.ncta.com/cables-story">1990,</a> Cable Television had reached 57% of US households. This rapidly expanded the variety of content consumed by viewers.</p>
<p>Live streaming officially began in <a target="_blank" href="https://www.theguardian.com/media-network/media-network-blog/2013/mar/01/history-streaming-future-connected-tv">1995</a>, but it wasn’t until 2007 that internet-based streaming began to use the standard HTTP protocol. Smartphones like the iPhone were added soon after using similar communication methods. With the push to mobile, smaller screens started gaining more of our time. YouTube has been a huge success during this phase, and now plays <a target="_blank" href="https://www.bluleadz.com/blog/25-eye-opening-youtube-statistics-infographic">5 billion videos a day</a>.</p>
<p>In 2015, <a target="_blank" href="https://www.androidcentral.com/amazon-echo-now-available-everyone-buy-17999-shipments-start-july-14">Amazon launched</a> the first device controlled solely by a user’s voice. Voice platforms like Alexa rapidly added another device to the home, with an <a target="_blank" href="https://techcrunch.com/2017/11/08/voice-enabled-smart-speakers-to-reach-55-of-u-s-households-by-2022-says-report/">estimated 35 million</a> already being used in the US. In <a target="_blank" href="https://www.macrumors.com/2017/05/09/amazon-echo-show-june/">2017</a>, Amazon officially launched their first version of Alexa with a screen, called the Echo Show. The <a target="_blank" href="https://www.theverge.com/circuitbreaker/2017/9/11/16287812/amazon-new-fire-tv-2017-alexa">new Amazon Fire TV</a> devices also have Alexa built in, enabling streaming video to a flat screen display to be controlled by your voice.</p>
<p>The Echo Show initially included the capability to play videos from YouTube, but lately, Google and Amazon <a target="_blank" href="http://variety.com/2017/digital/news/amazon-echo-show-sales-down-youtube-1202582660/">have been fighting</a> about it’s availability. This impacted the popularity of the product given how big of a feature video playing was.</p>
<p>At the <a target="_blank" href="https://www.cnet.com/news/google-home-assistant-smart-displays-echo-show-lenovo-lg-sony-jbl-ces-2018/">2018 CES</a>, multiple consumer electronics companies announced that they were launching a Google Home compatible device with a screen. This makes the voice market even more competitive. One solution to the YouTube compatibility challenge is to host video content directly on Amazon. The following describes how to create a custom skill for the Echo Show that does just that.</p>
<h3 id="heading-how-to-create-a-custom-video-skill-on-alexa">How to Create a Custom Video Skill on Alexa</h3>
<p>Building your own video channel is surprisingly easy using Alexa and a handful of AWS services. Here is the architecture featuring a custom Alexa skill that packages content to play on an Echo Show. The AWS storage service (S3) stores the media, and streams it to the device based on instructions given by the custom skill.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/2xU4Q2AmV3qQfrKVwBMppDWKgmt1hUjJmWGz" alt="Image" width="741" height="410" loading="lazy">
<em>Component Level Architecture for Custom Video Skill</em></p>
<p>Producing content for this is comparable to that required for a YouTube channel. The current version of the Echo Show (as well as the Echo Spot) have specifications around the media type to follow. For example, the video should use an mp4 extension and a standard <a target="_blank" href="https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC">H.264 compression</a> format. The resolution of the video quality should be no greater than 1280x720 in pixel size. These constraints provide a high quality video stream on the Show’s seven inch display comparable to that of a HD video player.</p>
<h3 id="heading-building-the-custom-video-skill">Building the Custom Video Skill</h3>
<p>Creating a video channel requires authoring a custom skill for Alexa and publishing it to the public skill store. There are a number of features needed for navigating the content in the channel and playing the videos. This section will cover these steps in detail. For a working example, try out the Piano Teacher skill that is already in the <a target="_blank" href="https://www.amazon.com/Piano-Teacher-video-Echo-Show/dp/B078M9843X/">Alexa store</a>. It is a skill that contains short videos with beginner lessons on how to play the piano, as well as note-by-note video instructions on how to play simple songs. <a target="_blank" href="https://github.com/terrenjpeterson/pianoplayer">Here</a> is the repo that contains all the source code needed, as well as detailed instructions to configure and deploy.</p>
<p>There are three features required to make a video channel.</p>
<p>1 — Render a background image when the skill is initially launched. This establishes the channel’s brand.<br>2 — Build navigation controls to browse and select which video to play. This includes handling touch gestures on the Echo Show screen.<br>3 — Delegate control to the device to play a video once content is selected.</p>
<h4 id="heading-1-brand-with-a-background-image">1 — Brand with a Background Image</h4>
<p>To facilitate the building of custom video skills, Alexa provides a series of templates. I use the “BodyTemplate1” template to render the background image when the skill is first invoked. When generating the metadata within the Alexa Developer Console, check the second and third boxes on the global fields screen (Video App &amp; Render Template).</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/8sZgyh5SKjVkQhGa7z0VXsUsfTy40xsVyG1T" alt="Image" width="800" height="287" loading="lazy"></p>
<p>Setting these attributes enables additional APIs within the custom skill. Additional standard intents are required to use the APIs. These are created when building the intent model in skills kit. They are as follows:</p>
<ul>
<li>AMAZON.NavigateSettingsIntent</li>
<li>AMAZON.NextIntent</li>
<li>AMAZON.PageDownIntent</li>
<li>AMAZON.PageUpIntent</li>
<li>AMAZON.PreviousIntent</li>
<li>AMAZON.ScrollDownIntent</li>
<li>AMAZON.ScrollLeftIntent</li>
<li>AMAZON.ScrollRightIntent</li>
<li>AMAZON.ScrollUpIntent</li>
</ul>
<p>No coding in the Lambda function is required for these events, as the device will handle them natively. They just need to be included in your custom skills intent model.</p>
<p>Rendering a background image requires two utility methods that are already distributed in the standard Alexa SDK. The skill creates two identifiers to illustrate how they are used.</p>
<pre><code class="lang-js"><span class="hljs-comment">// utility methods for creating Image and TextField objects</span>

<span class="hljs-keyword">const</span> makePlainText = Alexa.utils.TextUtils.makePlainText;
<span class="hljs-keyword">const</span> makeImage     = Alexa.utils.ImageUtils.makeImage;
</code></pre>
<p>Next, I add an identifier for the location of your jpg/png file that serves as the background image. This object needs to be publicly available. The pixel size is 1024x600 based on the dimensions of the Echo Show. You don’t need to provide a separate image for the smaller Echo Spot. Alexa creates the smaller image based on the original file sized for the Show.</p>
<pre><code class="lang-js"><span class="hljs-comment">// This is a public endpoint - the easiest way is to host in S3</span>
<span class="hljs-comment">// It needs to be SSL enabled (which S3 does for you)</span>

<span class="hljs-keyword">const</span> backgroundImage = ‘https:<span class="hljs-comment">//s3.amazonaws.com/.../image.jpg';</span>
</code></pre>
<p>Next, add the following code to render the background image when the skill gets launched, along with any other audio messages.</p>
<pre><code class="lang-js">‘LaunchRequest’: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ 
  <span class="hljs-keyword">const</span> builder = <span class="hljs-keyword">new</span> Alexa.templateBuilders.BodyTemplate1Builder();
  <span class="hljs-keyword">const</span> template = builder.setTitle(‘Your Personal Instructor’)
      .setBackgroundImage(makeImage(backgroundImage))
      .setTextContent(makePlainText(‘Piano Teacher’)) 
      .build();

  <span class="hljs-comment">// check if the device has a video screen</span>
  <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.event.context.System.device.supportedInterfaces.Display){      
    <span class="hljs-built_in">this</span>.response.speak(welcomeMessage)
        .listen(repeatWelcomeMessage).renderTemplate(template);
    <span class="hljs-built_in">this</span>.emit(‘:responseReady’);
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-comment">// handle error of not having a video screen to play</span>
    <span class="hljs-built_in">this</span>.emit(‘:tell’, nonVideoMessage);
  } 
},
</code></pre>
<h4 id="heading-2-content-navigation">2 — Content Navigation</h4>
<p>The navigation for the content takes advantage of the flexibility of the Alexa platform. The viewer can use either their voice or fingers to navigate the content catalog, selecting exactly what they would like to view. This requires using the list template within the Alexa SDK, as well as handling events triggered from the user touching the screen.</p>
<p>Here are the different options that the user may request using either their voice or touching the screen.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1DKSPxIQBKi6Zz8ile8GVUV4YzQL26Xh1Wr1" alt="Image" width="609" height="385" loading="lazy"></p>
<p>Rendering a list of what content is available is central to the user experience. I use ‘ListTemplate1’ from the Alexa SDK to render the list of videos. Scrolling up and down can be done through either voice or touch, and is handled by the device with no coding required.</p>
<p>The response object that is sent to list the content contains an array listing what is available on the channel. In my skill, this list is read by the Alexa voice, and is rendered visually on the screen. Here is an example of what it looks like.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ULRD5TKnXiNO4c35VuKDNOYhHO55e8jzUzEX" alt="Image" width="800" height="600" loading="lazy">
<em>Screenshot of Piano Teacher Skill on an Alexa Show</em></p>
<p>Within the code, the content is externalized into an array object (songs.json) that contains a list of videos, as well as metadata about the location of each media file. Each item in the list has a unique token assigned. Here is a sample of the layout written in standard Javascript object notation:</p>
<pre><code class="lang-json">[ 
  { “requestName”: “Silent Night”, 
    “listSong”:<span class="hljs-literal">true</span>, 
    “token”:”song001<span class="hljs-string">", 
    “difficulty”:”Moderate”, 
    “videoObject”: “SilentNight.mp4”, 
    “audioObject”: “SilentNight.mp3” 
  }, 
  { “requestName”: “Mary Had a Little Lamb”, 
    “listSong”:true, 
    “token”:”song002"</span>, 
    “difficulty”:”Easy”, 
    “videoObject”: “MaryHadLittleLamb.mp4”, 
    “audioObject”: “MaryHadLittleLamb.mp3” 
  },
...
]
</code></pre>
<p>Here is the code that converts the array into the response needed by Alexa. Included is embedding the token for each item in the array.</p>
<pre><code class="lang-js"><span class="hljs-comment">// these are the songs that recordings have been made for</span>
<span class="hljs-keyword">var</span> songs = <span class="hljs-built_in">require</span>(<span class="hljs-string">"data/songs.json"</span>);

<span class="hljs-comment">// create List</span>
<span class="hljs-keyword">const</span> itemImage = <span class="hljs-literal">null</span>; 
<span class="hljs-keyword">const</span> listItemBuilder = <span class="hljs-keyword">new</span> Alexa.templateBuilders.ListItemBuilder(); 
<span class="hljs-keyword">const</span> listTemplateBuilder = <span class="hljs-keyword">new</span> Alexa.templateBuilders.ListTemplate1Builder();

<span class="hljs-comment">// build an array of all available songs </span>
<span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; songs.length; i++ ) { 
  <span class="hljs-keyword">if</span> (songs[i].listSong) { 
    <span class="hljs-comment">// pull attributes from song array and apply to the list</span>
    listItemBuilder.addItem(<span class="hljs-literal">null</span>, songs[i].token,
      makePlainText(songs[i].requestName),
      makePlainText(songs[i].difficulty)); 
     message = message + songs[i].requestName + “, “;
  } 
} 
message = message + “Just select on the screen a song, or request by saying something “ + “like, Teach me how to play “ + songs[<span class="hljs-number">0</span>].requestName + “.”;

<span class="hljs-comment">// now create the response object using the SDK</span>
<span class="hljs-keyword">const</span> listItems = listItemBuilder.build(); 
<span class="hljs-keyword">const</span> imageLoc = pianoStrings; 
<span class="hljs-keyword">const</span> listTemplate = listTemplateBuilder.setToken(‘listToken’)
  .setTitle(‘Available Song List’) .setListItems(listItems)
  .setBackgroundImage(makeImage(imageLoc)) 
  .build(); <span class="hljs-built_in">this</span>.response.speak(message).listen(noSongRepeatMessage).renderTemplate(listTemplate); 
<span class="hljs-built_in">this</span>.emit(‘:responseReady’);
</code></pre>
<p>The Lambda function handles the ‘ElementSelected’ event invoked by the Echo Show. The request object sent by the device to the custom skill contains the token used to translate what was selected by the user.</p>
<pre><code class="lang-js"><span class="hljs-comment">// this function is invoked from the 'ElementSelected' event</span>
‘ScreenSongSelected’: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ 
  <span class="hljs-built_in">console</span>.log(“Element Selected:” + <span class="hljs-built_in">this</span>.event.request.token);
  <span class="hljs-keyword">var</span> videoName = “”;
  <span class="hljs-comment">// match token to song name and find the video object to play </span>
  <span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; songs.length; i++ ) { 
    <span class="hljs-keyword">if</span> (songs[i].token === <span class="hljs-built_in">this</span>.event.request.token) { 
      <span class="hljs-built_in">console</span>.log(“Play “ + songs[i].requestName);
      videoName = songs[i].videoObject;
    } 
  } 
  <span class="hljs-keyword">const</span> videoClip = videoLoc + videoName;
  <span class="hljs-built_in">this</span>.response.playVideo(videoClip); <span class="hljs-built_in">this</span>.emit(‘:responseReady’); 
},
</code></pre>
<p>The Lambda function uses the token it receives and finds the media file corresponding to the unique identifier. Control is then transferred to the device with the appropriate video.</p>
<h4 id="heading-3-delegate-control-to-the-video-player">3 — Delegate Control to the Video Player</h4>
<p>Once the video that needs to be played is found, the endpoint of the media is added to the response. This requires a few lines of code within the Lambda function.</p>
<p>First, identify a folder in the S3 bucket where the video files will be stored.</p>
<pre><code class="lang-js"><span class="hljs-comment">// These are the folders where the mp4 files are located</span>

<span class="hljs-keyword">const</span> videoLoc = ‘https:<span class="hljs-comment">//s3.amazonaws.com/…/media/';</span>
</code></pre>
<p>Then specify the exact file based on what was identified by the user. Metadata is added that contains more information about the video.</p>
<pre><code class="lang-js"><span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.event.context.System.device.supportedInterfaces.VideoApp) {
  <span class="hljs-keyword">const</span> videoClip = videoLoc + videoObject; <span class="hljs-comment">// endpoint of the file</span>
  <span class="hljs-comment">// this will be rendered when the user selects video controls</span>
  <span class="hljs-keyword">const</span> metadata = { 
    ‘title’: slots.SongName.value 
  };
  <span class="hljs-built_in">this</span>.response.playVideo(videoClip, metadata);
  <span class="hljs-built_in">this</span>.emit(<span class="hljs-string">':responseReady'</span>);
} <span class="hljs-keyword">else</span> {
  <span class="hljs-comment">// handle error - and close the session</span>
  <span class="hljs-built_in">this</span>.emit(‘:tell’, nonVideoMessage);
}
</code></pre>
<p>After this code executes, the Alexa device will take over navigation of playing the video. The user can either use their voice or touch the screen to pause, rewind, fast-forward, etc. Here is what the screen looks like when playing a video, including the Metadata title at the top.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/KK4CNJ0uzgbElT7u2Lr-CJ2lWJJLWlrDkLzy" alt="Image" width="800" height="600" loading="lazy">
<em>Screen shot of Piano Teacher Skill on an Alexa Show</em></p>
<p>When the video playing on the device is complete, the skill can be used again to select more content.</p>
<h3 id="heading-summary">Summary</h3>
<p>Building the custom skill can be done using the example above as a template in just a few hours. The Alexa certification process takes just a day or two, then the skill (and content within it) will be available for anyone with an Echo Show. As a fan of YouTube, I hope to be able to use it on my Alexa device soon, but there’s also a way for content publishers to go around it.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How serverless scales an idea to 100K monthly users — at zero cost ]]>
                </title>
                <description>
                    <![CDATA[ Eliminate friction to move closer to the customer experience — and closer to the functional value of technology Developing an Amazon Alexa skill within an AWS Lambda function is a simple way to demonstrate the power of ‘serverless’. Within an hour, ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-serverless-scales-an-idea-to-100k-monthly-users-at-zero-cost-160b41557b94/</link>
                <guid isPermaLink="false">66c34eb693db2451bd4414ac</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud Computing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ serverless ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 31 Dec 2017 23:34:09 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*7I28RRWH2pQEZsb2ETArAQ.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <h4 id="heading-eliminate-friction-to-move-closer-to-the-customer-experience-and-closer-to-the-functional-value-of-technology">Eliminate friction to move closer to the customer experience — and closer to the functional value of technology</h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*7I28RRWH2pQEZsb2ETArAQ.png" alt="Image" width="800" height="450" loading="lazy"></p>
<p>Developing an Amazon Alexa skill within an AWS Lambda function is a simple way to demonstrate the power of ‘serverless’.</p>
<p>Within an hour, you can design, develop and deploy an Alexa skill onto the Amazon.com marketplace — with instant access to millions of consumers.</p>
<p>Over the past couple of years, I’ve developed a bunch of simple Alexa skills to experiment with AWS Lambda and explore the Alexa Skills Kit. Along the way, some of the skills have even generated enough customers to qualify for a monthly payout from Amazon’s incentive program.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*lAMDxr20puXolqT-x7uKKA.png" alt="Image" width="800" height="472" loading="lazy"></p>
<p>The majority of the work involves coding an AWS Lambda function that expresses the business logic — using your choice of popular languages such as Node.js or Python. To get started, the Amazon Alexa team makes it really easy with a variety of <a target="_blank" href="https://github.com/alexa/">sample templates in their GitHub repositories</a>.</p>
<p>With much of the undifferentiated infrastructure heavy-lifting being done by AWS, you can focus attention on the actual product, marketing, and customer acquisition. For an Alexa skill, your results are easily measured by the volume of unique customers and their number of interactions.</p>
<h4 id="heading-amazon-alexa-metrics">Amazon Alexa metrics</h4>
<p>During the month of December, several of my custom Alexa skills — which are all based on AWS Lambda functions running in a single account — have collectively reached over 100K users in just 30 days.</p>
<p>Below are the 30-day metrics for a few of these skills, including Merry Christmas and Santa Claus — and cloud computing cult favorite <a target="_blank" href="https://www.amazon.com/Drew-Firment-Simon-Says/dp/B01NBLMM84/">Simon Says</a>. The data for each skill is accessible directly in the Alexa developer console.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*8PwGrCFkupdy16pnCk3gvA.png" alt="Image" width="800" height="301" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*1RPqAecU0Vwjjw3i6Y1nfw.png" alt="Image" width="800" height="297" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*AI7OW96ytXYSIp8ZsateLw.png" alt="Image" width="800" height="300" loading="lazy"></p>
<h4 id="heading-aws-lambda-metrics">AWS Lambda metrics</h4>
<p>So how does a large volume of customers, sessions, and interactions translate to the underlying utilization of AWS Lambda functions?</p>
<p>Over the same 30-day period, the Alexa skills have invoked the related AWS Lambda functions over 1M times.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*P4ymhlrZtYk8TIXbZCdJDw.png" alt="Image" width="800" height="196" loading="lazy"></p>
<p>All the Lambda functions share the same AWS account —and each function is allocated 512MB of memory and configured with a 7 second timeout. If needed, AWS provides a lot <a target="_blank" href="https://developer.amazon.com/blogs/alexa/post/546ab5a1-1d1a-49c2-85a5-92ada3e6e907/best-practices-for-scaling-your-alexa-skill-using-amazon-web-services">more levers to prepare your Alexa skill for scale</a>.</p>
<p>During the 30-day period, not a single function was throttled due to invocation rates exceeding the concurrency limits. The average invocation duration for the functions was 25 milliseconds.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*oSup3lk2BY94n1w6n3n57A.png" alt="Image" width="800" height="192" loading="lazy"></p>
<h4 id="heading-the-cost-of-serverless">The cost of serverless</h4>
<p>How much does hosting a dozen Alexa skills that connect to over 100K unique users in 30 days with 1M function invocations cost? <em>Zero. Zilch. Nada.</em></p>
<p>AWS provides developers access to 1M requests and 400,000 GB-seconds of compute time per month — at no cost. With the memory size of my functions set to 512MB, that equates to 800K free tier seconds per month.</p>
<p>Here’s the December invoice for my personal AWS account:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*kP2SyUQtX6msXgdpC2aNdA.png" alt="Image" width="800" height="413" loading="lazy"></p>
<p>The only cost incurred during the same period was a whopping $0.02 — the high cost of <a target="_blank" href="https://twitter.com/drewfirment/status/939567539734175744">experimenting with new AWS Kinesis Video Streams service</a>.</p>
<p>So what happens if your Alexa skills go viral and exceed 1M requests for the AWS Lambda service? For every 1M requests thereafter, you’ll get a charge of $0.20 to your bill — easily absorbed by the <a target="_blank" href="https://developer.amazon.com/alexa-skills-kit/alexa-aws-credits">$100 of promotional credits</a> provided to Alexa developers.</p>
<p>The economics of serverless technology also applies to the most heavily used Alexa skills. For example — even with over 50 million Lambda requests serving 175K users <em>per day,</em> the <a target="_blank" href="http://invokedapps.com/">sleep sound</a> apps developed by <a target="_blank" href="https://twitter.com/nickschwab">Nick Schwab</a> generates a frugal monthly bill under $30.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*_FGyTGcHzhH8t8jlcUlJgg.png" alt="Image" width="800" height="171" loading="lazy"></p>
<h4 id="heading-the-value-of-frictionless-innovation">The value of frictionless innovation</h4>
<p>Software engineers at leading startups and enterprises are deploying serverless architectures to convert innovative product ideas into consumable value — with minimal friction and negligible cost.</p>
<p>Serverless technologies like AWS Lambda functions are key enablers of frictionless innovation — allowing you to more easily deploy and scale products and services into the hands of a global customer base.</p>
<p>Despite the clear business advantages, there still seems to be a lot of debate and fear-mongering regarding the value of adopting serverless technology. Don’t believe the FUD — fear, uncertainty and doubt.</p>
<div class="embed-wrapper">
        <blockquote class="twitter-tweet">
          <a href="https://twitter.com/drewfirment/status/791913696918286336"></a>
        </blockquote>
        <script defer="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div>
<p>As the abstraction of platform services matures with serverless, the elimination of utility layers can move you closer to the customer experience — and closer to the functional value of technology.</p>
<p><em>Drew is an AWS Community Hero, Alexa Champion, and maker of dad jokes.</em><br><em>Follow on Twitter <a target="_blank" href="https://twitter.com/drewfirment">@drewfirment</a>. <a target="_blank" href="https://info.acloud.guru/we-power-tech">#WePowerTech</a></em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ A Visit from St. Nicholas — and Alexa ]]>
                </title>
                <description>
                    <![CDATA[ By Drew Firment Happy Christmas to all, and to all a good night! Inspired by the holiday season, emerging voice-first technology, and too much eggnog — I’ve twisted the classic poem from Clement Clarke Moore into a modern Christmas tale. My holiday w... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/a-visit-from-st-nicholas-and-alexa-8edf07b43795/</link>
                <guid isPermaLink="false">66d45e3dbc9760a197a10376</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud Computing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 13 Dec 2017 04:17:27 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*s-frHaV0lAPCkPJCq5lJ2w.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Drew Firment</p>
<h4 id="heading-happy-christmas-to-all-and-to-all-a-good-night">Happy Christmas to all, and to all a good night!</h4>
<p>Inspired by the holiday season, emerging voice-first technology, and too much eggnog — I’ve twisted the classic poem from Clement Clarke Moore into a modern Christmas tale.</p>
<p>My holiday wish is that a few developers are inspired to build their own Alexa skills and fill my Amazon Echo with cool custom skills in 2018. I hope you find this fun and filled with holiday cheer.</p>
<p>‘Twas the night before Christmas,<br>when all through the hills<br>Not an Alexa was stirring,<br>not even 5,000 cat skills;</p>
<p>The Echos were connected<br>to wi-fi with care,<br>In hopes that new features<br>soon would be there;</p>
<p>The devs were nestled<br>all snug it their beds;<br>While visions of incentives<br>danced in their heads;</p>
<p>And Bezos in his rocket,<br>and AWS on the map,<br>Had just fried our brains<br>with their re:Invent rap.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*h1jCata2PXOQjemFby5HHQ.png" alt="Image" width="800" height="243" loading="lazy"></p>
<p>When out from Alexa<br>there arose such a clatter,<br>I sprang from my bed<br>to listen to her chatter.</p>
<p>Away to the device<br>I flew like a flash,<br>Tripping over my Dot<br>and programmable dash.</p>
<p>The screen from my<br>brand new Echo Show,<br>Gave a lustre of midday<br>to devices below.</p>
<p>When what to my<br>developer eyes did appear,<br>But a miniature Spot<br>and eight Alexa pioneers.</p>
<p>With Alexa evangelists<br>so lively and quick,<br>I knew in a moment<br>he must be St. Nick.</p>
<p>More rapid than Lambda<br>his skills they came,<br>And he whistled, and shouted,<br>and invoked them by name:</p>
<p>“Now, Song Quiz! now, Rain Sounds!<br>now Flash Briefings and Jeopardy!<br>On, Beer Bot! on, Potterhead Quiz!<br>on, Mystic Mirror and Inspire Me!</p>
<p>To the top of the search!<br>to the top of Amazon’s leader wall!<br>Now invoke away! invoke away!<br>invoke away all!”</p>
<p>As keyboards that before<br>the developers fly,<br>When meet with an error,<br>give another try;</p>
<p>So up to the rankings<br>the Alexa skills they flew<br>With the sleigh full of Echos,<br>and St. Nicholas too —</p>
<p>And then, in an utterance,<br>I heard on the speaker,<br>The slots and intents<br>of each new feature.</p>
<p>As I drew in my ear,<br>and was turning around,<br>Down the dev portal<br>St. Nicholas came with a bound.</p>
<p>He was dressed as Alexa,<br>from his head to his foot,<br>And his woofer was covered<br>with sound files and aux input;</p>
<p>A bundle of devices<br>he had flung on his back,<br>And he looked like a developer<br>getting approval feedback.</p>
<p>His LEDs — how they twinkled!<br>his light ring, how merry!<br>His Dolby was crisp,<br>his smart home integration legendary!</p>
<p>His seven microphones<br>picked up all the audio,<br>And the wake words<br>were as clear as the snow;</p>
<p>The stump of a cord<br>he held tight in his base,<br>And the notifications,<br>it encircled his head with grace;</p>
<p>He had hand-free calling<br>and a little cylinder belly,<br>That replied when invoked,<br>like a clerk at a deli.</p>
<p>He was quick and responsive,<br>a right jolly old elf,<br>And I said “Alexa!” when I saw him,<br>in spite of myself;</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*QeJy4svSDeVxtLwZU34ydg.png" alt="Image" width="800" height="256" loading="lazy"></p>
<p>A wink of his lights<br>and a twist of his top,<br>Soon gave me to know<br>I had nothing to stop;</p>
<p>He spoke so many words,<br>putting SSML to work,<br>And filled all the rooms;<br>it gave me a smirk.</p>
<p>And connecting to the cloud<br>with his API,<br>And giving a nod,<br>Alexa said goodbye;</p>
<p>He sprang to his sleigh,<br>to evangelists gave a whistle,<br>And away they all flew<br>like a Blue Origin missile.</p>
<p>But I heard Alexa exclaim,<br>ere he drove out of sight —<br>“Happy Christmas to all,<br>and to all a good night!”</p>
<p>Merry Christmas!</p>
<p>Here’s an article I wrote about If you want to learn more about Alexa skill development — and how it’s a great gateway to cloud computing. Then be sure to enable the <a target="_blank" href="https://www.amazon.com/Drew-Firment-Santa-Claus/dp/B076Z13QSV/">Santa Claus skill</a> to see if you’ve been naughty or nice!</p>
<p><a target="_blank" href="https://medium.freecodecamp.org/why-learning-to-code-alexa-skills-is-the-gateway-to-a-cloud-computing-job-fa13c1c0c853"><strong>Why learning to code Alexa Skills is the gateway to a cloud computing job</strong></a><br><a target="_blank" href="https://medium.freecodecamp.org/why-learning-to-code-alexa-skills-is-the-gateway-to-a-cloud-computing-job-fa13c1c0c853">_There are radical economic shifts underway. Society is moving from commodity-based capital toward intellectual capital…_medium.freecodecamp.org</a><a target="_blank" href="https://devpost.com/software/naughty-or-nice"><strong>Naughty or Nice?</strong></a><br><a target="_blank" href="https://devpost.com/software/naughty-or-nice">_Naughty or Nice? — Santa Claus is making a list and checking it twice! Do you want to know if you are naughty or nice…_devpost.com</a></p>
<p><em>AWS Community Hero, Alexa Champion, and maker of dad jokes.</em><br><em>Follow me on Twitter <a target="_blank" href="https://twitter.com/drewfirment">@drewfirment</a>. <a target="_blank" href="https://info.acloud.guru/we-power-tech">#WePowerTech</a></em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to code sports games for Amazon Alexa, plus some fun games I built ]]>
                </title>
                <description>
                    <![CDATA[ By Terren Peterson I’m both a sports nut and a software engineer. I’m also recognized as an Amazon Alexa Champion. I continue to look for new ways to stretch this technology. Over the past two years, I’ve won hackathons for skills on the Alexa platfo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-code-sports-games-for-amazon-alexa-and-some-fun-games-i-built-8179d2142f02/</link>
                <guid isPermaLink="false">66c350a0465d1b2f886ba42a</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ amazon echo ]]>
                    </category>
                
                    <category>
                        <![CDATA[ sports ]]>
                    </category>
                
                    <category>
                        <![CDATA[ startup ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 30 Sep 2017 20:34:15 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*2MZNttNYjigeKtg43OiPZA.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Terren Peterson</p>
<p>I’m both a sports nut and a software engineer. I’m also recognized as an Amazon <a target="_blank" href="https://developer.amazon.com/alexa/champions/terren-peterson">Alexa Champion</a>. I continue to look for new ways to stretch this technology.</p>
<p>Over the past two years, I’ve won <a target="_blank" href="https://en.wikipedia.org/wiki/Hackathon">hackathons</a> for skills on the Alexa platform.</p>
<p>Skills are the part of the Alexa voice service that activates its capabilities. In Alexa, <em>skill</em> is a term used for capabilities that make an experience more personal. You can enable or disable them as you choose. And, with the Alexa Skills Kit, You can create and customize them.</p>
<h3 id="heading-sports-games-are-an-enormous-market">Sports games are an enormous market</h3>
<p>Video games are a huge market, with annual revenues projected at more than <a target="_blank" href="https://newzoo.com/insights/articles/the-global-games-market-will-reach-108-9-billion-in-2017-with-mobile-taking-42/">$100B worldwide</a>. Shooter and action games are the most popular, <a target="_blank" href="http://marketrealist.com/2016/06/action-and-sports-genres-dominate-the-video-gaming-space/">followed by sports games</a>.</p>
<p>Voice platforms are growing at a fantastic rate. The popular Amazon Alexa platform has grown by 4 times in the past year. There are now 20,000 custom skills on the Alexa platform. Yet no sports games are more complex than calling out trivia.</p>
<p>Here is a sample of my new football game called <em>End Zone Football</em>. This shows how an advanced game can work on the Alexa platform.</p>
<h3 id="heading-begin-game-design-with-storyboards">Begin game design with Storyboards</h3>
<p>Designing the skill requires writing <a target="_blank" href="https://en.wikipedia.org/wiki/Storyboard">storyboards</a> to script the action. Start with how the game will begin. Then write the narrative for basic <a target="_blank" href="https://en.wikipedia.org/wiki/Gameplay">gameplay</a>.</p>
<p>Consider yourself to be a playwright or a movie director. Ask yourself: What should the native Alexa voice say? What sounds can be played that are part of the game?</p>
<p>Here’s what I learned from publishing a Baseball and Football game on Alexa. These tips will improve the usability of your game:</p>
<ul>
<li>Keep the interaction simple<br>yes or no and 1/2/3/4 answers work best</li>
<li>Identify sounds that can make the gameplay more exciting<br>Crowd cheering, whistles, or the crack of a bat</li>
<li>Simplify the game<br>The Baseball game skills should include foul balls<br>The Football game skills should simulate penalties<br>These help keep the user engaged</li>
<li>Don’t rely on visuals<br>A background image for the Echo Show is nice, but the images on the companion app should be secondary</li>
<li>Bound the game to 2–5 minutes<br>Users can play again and again if they have time</li>
<li>Create a help function that explains the game in detail<br>Give examples of phrases to use to play</li>
<li>Above all else<br>Make it Fun!</li>
</ul>
<h3 id="heading-learn-ssml-to-include-sounds-with-voice">Learn SSML to include sounds with voice</h3>
<p><a target="_blank" href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference">Speech Synthesis Markup Language</a> (SSML) integrates sound with voice. It’s used to create the audio for the Alexa device.</p>
<p>This is how I set the main response attribute to call the Alexa API. After splicing the strings in JavaScript, the code looks like this:</p>
<pre><code><span class="hljs-keyword">var</span> speechOutput = “Welcome to End Zone Football. “ +   “&lt;audio src=\”” + bucketLoc + “BandMusicIntro.mp3\” /&gt;” +  “The game that lets you drive the “ +   “ball down the field using just your voice. “ +   “&lt;<span class="hljs-keyword">break</span> time=\”<span class="hljs-number">1</span>s\”/&gt;” +   “You are <span class="hljs-keyword">in</span> charge <span class="hljs-keyword">of</span> the Blackbears, and are down “ +  sessionAttributes.away + “ to “ + sessionAttributes.home + “. “ +   “&lt;<span class="hljs-keyword">break</span> time=\”<span class="hljs-number">1</span>s\”/&gt;” + “The ball is on the “ +   yardline + “ yardline. “ +   “When you are ready, just call out the play you want to run, and the game will begin. “ +   “For a list <span class="hljs-keyword">of</span> plays at anytime say, Read Playbook. “;
</code></pre><p>Here are some examples of how to use SSML in this context:</p>
<ul>
<li>To create a pause  </li>
<li>To insert a soundclip<br>&lt;audio src=”https://s3.amazonaws.../file.mp3"&gt;</li>
</ul>
<p>I recommend using an <a target="_blank" href="http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html">S3 bucket</a> to store the media files. This is a low-cost way of storing data. And they can be accessible to Alexa.</p>
<h3 id="heading-state-management-tracks-the-progress-of-play">State management tracks the progress of play</h3>
<p>Alexa has the ability to store the gameplay state. Use this feature to simplify the coding and testing of your skill.</p>
<p>In the <a target="_blank" href="https://aws.amazon.com/sdk-for-node-js/">Node.js SDK</a>, a session attribute is passed with the request and response attributes. You can use the session attribute for the gameplay state. Store critical game information in this field. You can include anything, like the play number or recorded number of outs.</p>
<p>Here is an example used in the Football game</p>
<pre><code><span class="hljs-comment">// save the game attributes through to the next play    if (session.attributes) {          sessionAttributes = session.attributes;    }...</span>
</code></pre><pre><code><span class="hljs-comment">// gameplay rules for passingif (offensivePlaybook[i].playType === “pass” &amp;&amp;    offensivePlaybook[i].playNumber.toString() ===     intent.slots.playNumber.value) {       console.log(“Matched Play Number”);       // calculate pass distance based on play selected      passDistance = Math.round(Math.random() *         (offensivePlaybook[i].maxYardage            — offensivePlaybook[i].minYardage)            + offensivePlaybook[i].minYardage);       // make sure distance of play can’t be longer than       // the remaining field       if (passDistance &gt; sessionAttributes.yardline) {         passDistance = sessionAttributes.yardline;       }       playDesc = offensivePlaybook[i].playDesc;       speechOutput = speechOutput + playDesc + “. “;       // based on the play selected, determine relative       // completion rate       passCompletion = offensivePlaybook[i].completionRate;)...// pass back the response to Alexa, and save the gamestatecallback(sessionAttributes,                 buildSpeechletResponse(cardTitle, speechOutput,       cardOutput, repromptText, device, shouldEndSession));</span>
</code></pre><p>Storing this data in a table for analytics is helpful, but is not needed in an initial version. Let the Alexa platform do this work for you.</p>
<h3 id="heading-advertise-your-skill-on-social-media">Advertise your skill on social media</h3>
<p>People don’t yet realize all the things that an Alexa can do. When doing demos of these skills, I consistently get feedback that “I didn’t think Alexa could do that.”</p>
<p>All skills must be certified before publication on the Amazon Store. When your skill passes the certification process, take the time to record a video of it in action. It is the best way to prove what the platform is capable of.</p>
<p>Thank you for reading, and please enjoy these games — they’re free!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How I programmed my first Amazon Alexa Skill and won a free Echo Dot ]]>
                </title>
                <description>
                    <![CDATA[ By Lorrie Pearson It’s been a year since I began learning to code. I became interested in coding because of my desire to work with others in the beauty, fashion and luxury lifestyle world. I wanted to create amazing websites with animated elements an... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-your-tech-skill-to-create-alexa-skills-a3e9f210a952/</link>
                <guid isPermaLink="false">66c355f8fd47bc6e657cb872</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ startup ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 10 Aug 2017 23:23:56 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*a0cGkm-EHwR3jcHd7rpkQg.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Lorrie Pearson</p>
<p>It’s been a year since I began learning to code. I became interested in coding because of my desire to work with others in the beauty, fashion and luxury lifestyle world. I wanted to create amazing websites with animated elements and other digital media.</p>
<p>I started with an online course and a month later, I discovered freeCodeCamp. That’s when learning to code became more exciting and insightful.</p>
<p>There is real-time communication with fellow coders ready to help you work through interactive challenges. They provide feedback and references for further learning. This helped my confidence grow and coding skills improve.</p>
<p>In early June, a friend told me about an online webinar titled “Build Voice Enabled Experiences with Amazon Alexa.” The idea of the webinar increased my curiosity because at the time, I had only seen commercials, but had not used an Alexa enabled product. I signed up and was fascinated.</p>
<p>At the end of the webinar attendees received information about a promotion. If within 30 days you created a Skill and got it published, you were eligible to win a free Echo Dot. I didn’t know if I had enough knowledge to succeed, but I decided to give it a try to learn.</p>
<p>The thought of creating my first app was exciting. At that moment, my Alexa learning experience began.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/GS1YCp8IJi2QrNIMKA71Y2Zj2k-GplgIVH0Y" alt="Image" width="800" height="450" loading="lazy">
<em>Amazon Alexa Enabled Devices</em></p>
<h3 id="heading-what-is-alexa-and-how-does-it-work"><strong>What is Alexa and how does it work?</strong></h3>
<p>Alexa is a cloud-based voice service that powers millions of voice experiences in the home. Devices Alexa powers includes Amazon Echo, Echo Dot, Amazon Tap and Amazon Fire TV.</p>
<p>A Skill is a voice-driven application for Alexa.</p>
<p>Alexa provides “Skills”, which allows users to interact with the devices. Skills can be created to do many things. They can answer questions, play trivia games, play music, set an alarms, tell jokes and more.</p>
<p>The Alexa Skills Kit (ASK) is a collection of tools, API’s, documentation, code samples and templates with links to GitHub. The ASK helps developers create Skills for Alexa enabled devices.</p>
<p>An Alexa Skill has two main components: a Skill Service and a Skill Interface.</p>
<p>Your code is written in Node.js for the Skill Service which lives in the Cloud (<a target="_blank" href="https://aws.amazon.com/">Amazon AWS, Lambda</a>, an HTTPS service). It receives instructions to determine the actions to take in response to the user requests from the Alexa enabled device.</p>
<p>The Skill Service implements event handlers that define how the Skill will behave. The event is triggered when the user speaks into an Alexa enabled device.</p>
<p>Then you configure the Skill Interface with the Skill Developer Portal. The interface processes the users’ words to trigger the events that the Skill Service handles. In this area you determine what to call your Skill so the user can invoke it by name. This also is where you define the Skill interaction model. This is so it knows how to listen to users’ spoken words and respond with the information intended.</p>
<p>It’s the interaction of the two components that make the Skill work.</p>
<p>The Amazon Team provided links to three Skill Templates. These templates are great to help you get started and to learn how Alexa interacts and responds.</p>
<ul>
<li><strong>Fact Skill template</strong><br>to create something like a “fact” or “joke” of the day.</li>
<li><strong>Decision Tree template</strong><br>to create simple adventure games and quizzes</li>
<li><strong>How To template</strong><br>to create skills like recipes content with similar step by step processes.</li>
</ul>
<p>Plus many more intermediate and advanced templates <a target="_blank" href="https://developer.amazon.com/alexa-skills-kit/tutorials">available</a> .</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/lEVAry9so7W9iTBCUgV0-DXV8jTfqNSqPc7i" alt="Image" width="512" height="512" loading="lazy">
<em>My first published Alexa Skill, Makeup Facts</em></p>
<p>I now have three published skills, <a target="_blank" href="https://www.amazon.com/Lorriep-design-studio-makeup-facts/dp/B071XC158S/ref=sr_1_1?s=digital-skills&amp;ie=UTF8&amp;qid=1501898705&amp;sr=1-1&amp;keywords=makeup+facts">Makeup Facts</a>, <a target="_blank" href="https://www.amazon.com/Lorriep-design-studio-fashion-facts/dp/B073JY3H83/ref=sr_1_1?s=digital-skills&amp;ie=UTF8&amp;qid=1501898748&amp;sr=1-1&amp;keywords=fashion+facts">Fashion Facts</a> and <a target="_blank" href="https://www.amazon.com/Lorriep-design-studio-Girls-Code/dp/B07487QL3J/ref=sr_1_14?s=digital-skills&amp;ie=UTF8&amp;qid=1501898636&amp;sr=1-14&amp;keywords=lifestyle">Girls Can Code</a> . I work as a freelance makeup artist and fashion stylist and decided to start with what I know best.</p>
<p>To create these “Fact Skills” I reviewed the topic and information on creating a Skill. Then I created my list of facts that would be integrated into the Fact Skill Template. All Skills were accepted and published within a couple of days.</p>
<h3 id="heading-how-i-created-my-first-skill"><strong>How I created my first Skill</strong></h3>
<p>Go to <a target="_blank" href="https://developer.amazon.com/">Amazon Developer Portal</a> sign in, click Alexa at top of the screen.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/TT4LjkFjJet75UKwzdQ1hQr2cp1vBP4WzOtu" alt="Image" width="800" height="85" loading="lazy">
<em>Amazon Developer Console</em></p>
<p>On the Alexa page, choose the “Get Started” for the Alexa Skills Kit.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ohZJBwb18S7r8sWbEWBbgZH91cgV3JfvvJzN" alt="Image" width="218" height="217" loading="lazy">
<em>Alexa Skills Kit get started button</em></p>
<p>On the next page..select “Add New Skill.”</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3DFuU4utTQ71Xj11vR7Rt0e834fdmWDyaRO9" alt="Image" width="138" height="39" loading="lazy">
<em>from Amazon Alexa Skill Kit Tutorial</em></p>
<p>Then fill out the <strong>Information</strong> page.</p>
<p>Skill Type: <strong>Custom</strong></p>
<p>Language: <strong>English</strong></p>
<p>Name: <strong>Makeup Facts</strong></p>
<p>Invocation Name: (what your user will need to say to start the Skill) <strong>Makeup Facts</strong></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/wQGWluVqdyMHNE8XWfhOJHgeukyv8opdfnAE" alt="Image" width="800" height="409" loading="lazy">
<em>my Skill information page</em></p>
<p>Click next to go to <strong>Interaction Model</strong> page. This is where you create <strong>intents</strong> or what users will ask Alexa to do. Then create <strong>utterances</strong> or possible ways the user will ask Alexa about the Skill you’ve created. I found this <a target="_blank" href="https://github.com/Lorrie01/alexacourse/tree/master/1_spaceGeek/speechAssets">GitHub repository</a> to be helpful. The Samples include: give me a fact, tell me a fact.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/YUBk843RK0lgoRBCAm782NwTo0WVkj5OarEW" alt="Image" width="800" height="407" loading="lazy">
<em>from Alexacourse GitHub</em></p>
<p>My <strong>Intents</strong> in the <strong>Interactive Model</strong> for <strong>Makeup Facts</strong></p>
<pre><code>{ “intents”: [ { “intent”: “GetNewFactIntent” }, { “intent”: “AMAZON.HelpIntent” }, { “intent”: “AMAZON.StopIntent” }, { “intent”: “AMAZON.CancelIntent” } ] }
</code></pre><p>My <strong>Utterances</strong> in the <strong>Interactive Model</strong> for <strong>Makeup Facts.</strong></p>
<pre><code>GetNewFactIntent a factGetNewFactIntent tell me a factGetNewFactIntent tell me a makeup factGetNewFactIntent give me a factGetNewFactIntent give me a makeup factGetNewFactIntent tell me triviaGetNewFactIntent give me triviaGetNewFactIntent give me some informationGetNewFactIntent tell me somethingGetNewFactIntent give me something
</code></pre><p>Now it’s time to set up Lambda. Go to <a target="_blank" href="https://aws.amazon.com/">https://aws.amazon.com/</a> and sign into the console. Then go to <strong>services-Lambda</strong>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/crBOkgDgYQiljGUSDxaNIHzVUF2FzRmCoDaY" alt="Image" width="800" height="515" loading="lazy">
<em>from Amazon Alexa Skill Kit Tutorial</em></p>
<p>On the top right of your page, make sure your <strong>AWS Region</strong> is <strong>N. Virginia</strong>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/H5yeHkDP00jQLrJBD0VvE7R8kCHkuAcJsNQW" alt="Image" width="205" height="33" loading="lazy">
<em>from Amazon Alexa Skill Kit Tutorial</em></p>
<p>Then click the blue button to create a Lamda function.</p>
<p>Choose the blueprint that looks like this:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/mddxNVvNk2T2m8M26n1VKTimgXoUKKwENBXF" alt="Image" width="289" height="152" loading="lazy">
<em>from Amazon Alexa Skill Kit Tutorial</em></p>
<p>Configure your trigger. Make sure you choose <strong>Alexa Skills Kit</strong> in the drop down menu.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ro9RU5ptijwhlJOraZgjYab3ggfdHcqnEViv" alt="Image" width="800" height="384" loading="lazy">
<em>from Amazon Alexa Skill Kit Tutorial</em></p>
<p>Configure your function. Make sure your function name is written in camelBack. You can leave the description blank, but you are building this in Node.js.</p>
<p>Add your updated code.</p>
<p>There is an <a target="_blank" href="https://github.com/Lorrie01/alexacourse/tree/master/1_spaceGeek/src">AlexaSkill.js</a> file written with specific event handlers. It specifies output, prompt and speech. There is also an Index.js file that you customize to meet the needs of your Skill.</p>
<pre><code>Girls Can Code (index.js)
</code></pre><pre><code>‘use strict’;<span class="hljs-keyword">var</span> Alexa = <span class="hljs-built_in">require</span>(‘alexa-sdk’);
</code></pre><pre><code><span class="hljs-keyword">var</span> APP_ID = “amzn1.ask.skill<span class="hljs-number">.1</span>f2c85a9-b1b6–<span class="hljs-number">49</span>a8-b94d<span class="hljs-number">-8</span>a795d545d98”;
</code></pre><pre><code><span class="hljs-keyword">var</span> SKILL_NAME = “Girls Can Code”;<span class="hljs-keyword">var</span> GET_FACT_MESSAGE = “Here’s your fact: “;<span class="hljs-keyword">var</span> HELP_MESSAGE = “You can say tell me a code fact, or, you can say exit… What can I help you <span class="hljs-keyword">with</span>?”;<span class="hljs-keyword">var</span> HELP_REPROMPT = “What can I help you <span class="hljs-keyword">with</span>?”;<span class="hljs-keyword">var</span> STOP_MESSAGE = “Goodbye!”;
</code></pre><pre><code><span class="hljs-keyword">var</span> data = [ “Coding is awesome.”, “You can create tools that will change the world.”, “Coding is creative.”, “Coding is like solving a puzzle.”, “Coding work can be done remotely”, “Learning code is empowering.”, “Technology and coding help create the future.”, “Girls who can code have the edge”, “Anyone can code. You’ll discover something <span class="hljs-keyword">new</span>.”, “Coding promotes critical thinking”, “Women make great coders”, “Girls who code are role models <span class="hljs-keyword">for</span> all women.”, “Girls who code know that technology is not just <span class="hljs-keyword">for</span> boys.”, “Jobs <span class="hljs-keyword">in</span> tech are <span class="hljs-keyword">in</span> demand.”, “Coding is the language <span class="hljs-keyword">of</span> the <span class="hljs-number">21</span>st century”, “Girls who code help close the gender gap.”, “Coding can be done anywhere, anytime”, “Working <span class="hljs-keyword">in</span> tech can be a very lucrative career choice”, “Coding is not just about building robots and website, you learn to create things that don’t exist”, “A girl who codes could create the next <span class="hljs-keyword">new</span> social media app”, “A girl <span class="hljs-keyword">with</span> tech skills can change the ways businesses communicate”, “Girls who code love to learn.”];
</code></pre><pre><code><span class="hljs-built_in">exports</span>.handler = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event, context, callback</span>) </span>{ <span class="hljs-keyword">var</span> alexa = Alexa.handler(event, context); alexa.APP_ID = APP_ID; alexa.registerHandlers(handlers); alexa.execute();};
</code></pre><pre><code><span class="hljs-keyword">var</span> handlers = { ‘LaunchRequest’: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ <span class="hljs-built_in">this</span>.emit(‘GetNewFactIntent’); }, ‘GetNewFactIntent’: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ <span class="hljs-keyword">var</span> factArr = data; <span class="hljs-keyword">var</span> factIndex = <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.random() * factArr.length); <span class="hljs-keyword">var</span> randomFact = factArr[factIndex]; <span class="hljs-keyword">var</span> speechOutput = GET_FACT_MESSAGE + randomFact; <span class="hljs-built_in">this</span>.emit(‘:tellWithCard’, speechOutput, SKILL_NAME, randomFact) }, ‘AMAZON.HelpIntent’: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ <span class="hljs-keyword">var</span> speechOutput = HELP_MESSAGE; <span class="hljs-keyword">var</span> reprompt = HELP_REPROMPT; <span class="hljs-built_in">this</span>.emit(‘:ask’, speechOutput, reprompt); }, ‘AMAZON.CancelIntent’: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ <span class="hljs-built_in">this</span>.emit(‘:tell’, STOP_MESSAGE); }, ‘AMAZON.StopIntent’: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{ <span class="hljs-built_in">this</span>.emit(‘:tell’, STOP_MESSAGE); }};
</code></pre><p>Create a compressed file with the above two files and upload the zipfile into Lambda.</p>
<p>Skip the Advanced settings.</p>
<p>Copy the ARN # in the top right hand corner of your screen.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/kcR-r2rJSGnwpihGWoZOMJS4ygixgZ285t5x" alt="Image" width="447" height="98" loading="lazy">
<em>from Amazon Alexa Skill Kit Tutorial</em></p>
<p>Go back to the <strong>Amazon Developer</strong> page. Select your skill and click on the <strong>Configuration</strong> tab located in the left sidebar menu.</p>
<p>Select the <strong>AWS Lambda</strong> option. Check the <strong>North America</strong> box. Paste the <strong>arn#</strong> that you copied from your Lambda dashboard.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1E2xx0KBWCGXaRMvLaOYhKqdWncQfYAkGU6u" alt="Image" width="800" height="374" loading="lazy">
<em>my configuration page</em></p>
<p><strong>Test your Skill. If necessary, update it so that it works properly.</strong> This <a target="_blank" href="https://github.com/Lorrie01/alexacourse/tree/master/1_spaceGeek/src">GitHub Repository</a> gives you the sample code for creating a Fact Skill. Check it, clone it and update it to write your own.</p>
<p>You can test your code in the Developer Console, in the Lambda functions, on your Echo and at <a target="_blank" href="https://echosim.io/welcome">Echoism.io</a>.</p>
<p>Enter your Publishing and Privacy information.</p>
<p>Congrats..you’re ready to submit for certification.</p>
<p>It takes a few days to hear back from the Amazon Developer Team. If your Skill is approved, then everything works and all of the information is compliant. Your Skill will be certified and published and available for others to use.</p>
<p>If not, you will receive feedback and suggestions on what you need to to to resolve any issues so you can re-submit.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0-f8xzlFh9-a56n5XRPSfu6jFzvBCznqYYEU" alt="Image" width="512" height="512" loading="lazy">
<em>My 2nd published Alexa Skill, Fashion Facts</em></p>
<h3 id="heading-what-i-learned"><strong>What I learned</strong></h3>
<ul>
<li>It’s helpful to have some familiarity with JavaScript and Node.js.</li>
<li>You will need an AWS (Amazon Web Services) account and an Amazon Developer Account to complete and submit Skills.</li>
<li>Review the words you cannot use that will conflict with how Alexa responds.</li>
<li>Listen to the preview of your Skill. It’s extremely helpful to know your information flows.</li>
<li>It’s very different creating something that is voice activated by an end user as compared to reading on a screen.</li>
<li>Pretend you are the end user when writing your Skill. It helped me understand how the user would ask Alexa for information.</li>
<li>If your Skill is not accepted review the feedback from the Alexa Skills Team. They provide great information that will help you get your skill certification ready.</li>
<li>If you provide improvements to one of your existing Skills, the improved Skill has to go through the same process.</li>
<li>You need an icon or image for your Skill to upload with submission.</li>
<li>Once your skill is accepted and certified, it is live on Amazon.</li>
</ul>
<p>I am currently working on two Skills. One uses the “Decision Tree template” and the other uses the “How To template”. These are a little more complex to build, but I’m confident will have them published soon.</p>
<p>I also have my free Echo Dot. Interacting with this device has given me ideas for developing more Skills.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ECUurYe7GuES-qtlriyhtOYaHxZ3so4Lp093" alt="Image" width="512" height="512" loading="lazy">
<em>My 3rd published Alexa Skill, Girls Can Code</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to claw your way out of AWS Lambda function hell using the power of Docker ]]>
                </title>
                <description>
                    <![CDATA[ By Liz Rice When you’re building Lambda functions, it’s easy to get trapped in an “Invalid ELF header” nightmare. The problem is that your binaries are built for the wrong platform. Here’s what’s going on, and how you can fix it easily using Docker. ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/escaping-lambda-function-hell-using-docker-40b187ec1e48/</link>
                <guid isPermaLink="false">66c349d89972b7c5c7624e36</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Docker ]]>
                    </category>
                
                    <category>
                        <![CDATA[ lambda ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 17 Feb 2017 21:58:27 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*HlfWIN7pNtK3ffZ-ll1cZQ.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Liz Rice</p>
<p>When you’re building Lambda functions, it’s easy to get trapped in an “Invalid ELF header” nightmare. The problem is that your binaries are built for the wrong platform. Here’s what’s going on, and how you can fix it easily using Docker.</p>
<p>When most people get started with Lambda functions, they’ll use the online editor in the console to input their code. This is fine for your first example or two, but pretty soon you’ll want to do something wild and crazy like, y’know, import a library.</p>
<p>Over the past few weekends I’ve been working on <a target="_blank" href="https://hackernoon.com/my-first-alexa-custom-skill-6a198d385c84#.qfxjk23ov">my first Alexa skill for an Amazon Echo</a> and I’ve reached that point where I want to use some third party code to add some additional functionality.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/vktAeFvMs7ITPSm0PgNVUG6EWPSvDRoG7Xfu" alt="Image" width="800" height="356" loading="lazy">
<em>Your options for supplying the code for your Lambda function, as seen in the AWS Console</em></p>
<p>The online editor simply lets you edit a single file. If you want to refer to other files — including imported libraries — you can upload them in a ZIP file (Amazon call this a <a target="_blank" href="http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html">deployment package</a>). But if you‘re working on a Mac or a Windows computer, there’s a catch.</p>
<p>When you use pip to install Python libraries on your laptop, it gives you binaries (.so files) that are built to run on your machine. But when the Lambda function runs in the AWS cloud it is going to be running on Linux — and binaries built for Mac (these are often called ‘darwin’ builds) or Windows won’t run on Linux (and vice versa).</p>
<p>If you upload the Mac version, you’ll see “invalid ELF header” logs when you try to test your Lambda function.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/q0v1xD6yQw0OfdQsiZVo3Fgzlm1jTvAzNUqA" alt="Image" width="800" height="241" loading="lazy">
<em>Invalid ELF header indicates it’s the wrong binary format for the platform</em></p>
<p>So you’re going to need Linux versions of those library files. But what if you don’t have a Linux box to hand?</p>
<p>You could grab yourself an EC2 instance from Amazon (or a droplet on Digital Ocean, or any Linux VM of your preference) but to my mind that’s quite a performance, and could even cost you a little bit of money (especially if you forget to take the EC2 box down again when you don’t need it).</p>
<p>I think the easiest solution is to use Docker.</p>
<h3 id="heading-the-docker-approach">The Docker approach</h3>
<p>With <a target="_blank" href="http://docker.com">Docker</a> you can very easily can run a Linux container locally on your Mac, install the Python libraries within the container so they are automatically in the right Linux format, and zip up the files ready to upload to AWS. You’ll need <a target="_blank" href="https://www.docker.com/products/docker">Docker for Mac (or Windows)</a> installed first.</p>
<p>Spin up an Ubuntu container that can see the Lambda code you want to upload.</p>
<pre><code>docker run -v &lt;directory <span class="hljs-keyword">with</span> your code&gt;:/working -it --rm ubuntu
</code></pre><ul>
<li>The <code>-v</code>flag makes your code directory available inside the container in a directory called “working”.</li>
<li>The <code>-it</code>flag means you get to interact with this container.</li>
<li>The <code>--rm</code> flag means Docker will remove the container when you’re finished.</li>
<li><code>ubuntu</code> is the name of an official container image containing, you guessed it, Ubuntu. If this container image isn’t already on your machine, Docker will download it for you.</li>
</ul>
<p>You should now be inside the container at a shell prompt looking something like this:</p>
<pre><code>root@c1996f32a397:/#
</code></pre><p>Install pip and zip:</p>
<pre><code>$ apt-get update$ apt-get install python-pip$ apt-get install zip
</code></pre><p>Move into the working directory (you should be able to see your Lambda function code here):</p>
<pre><code>$ cd working
</code></pre><p>Use pip to get the library/ies you’re interested in. You can use the -t flag to tell pip to put the libraries here in the current directory, which will be more convenient later as it’s where the AWS deployment package wants them to be:</p>
<pre><code>$ pip install -t . &lt;library&gt;
</code></pre><p>If you’re very curious, you can take a look to see what this installs. In my own case I installed the <code>editdistance</code> library, which gave me the following additional directories and files.</p>
<pre><code>editdistance:__init__.py __init__.pyc _editdistance.h bycython.so def.h
</code></pre><pre><code>editdistance<span class="hljs-number">-0.3</span><span class="hljs-number">.1</span>.dist-info:DESCRIPTION.rst INSTALLER METADATA RECORD WHEEL metadata.json top_level.txt
</code></pre><p>You can see that bycython.so file? This is the correct, Linux version of the binary that AWS was objecting to when I hit the Invalid ELF header (shown in the error log screenshot above).</p>
<p>Create the ZIP file with your Lambda code (in my case, a single file called lambda_function.py) and the libraries (for me, the two editdistance directories and their contents.</p>
<pre><code>$ zip linux-lambda.zip lambda_function.py
</code></pre><pre><code>$ zip -r linux-lambda.zip edit*
</code></pre><p>The <code>-r</code> flag on zip tells it to recursively add the contents of directories.</p>
<p>Now you have an archive file called linux-lambda.zip which is ready to upload to AWS. And because the directory is mounted from the host (your Mac) into the container, you can simply upload the file into the console.</p>
<p>Back in the terminal type <code>exit</code> to quit the container, and it will be as if it never existed, except for the existence of the linux-lambda.zip file, which is still available on the host.</p>
<p>Upload the ZIP file in the console, save it and try running a test. Invalid ELF header error no more!</p>
<p>If this article helps you out, please hit the ? button to make it easier for other people to find it. If you really like it, why not go bananas and share it too?</p>
<p>I’ve written a few other posts about what I’m learning as I write my first Alexa skill, like this one where I <a target="_blank" href="https://hackernoon.com/my-alexa-skill-with-storage-5adb1d097b88#.d0a1a7xha">add database storage capabilities to my Lambda function</a>. If you find them useful, you might be interested in a book I’m writing called <a target="_blank" href="http://leanpub.com/adventureswithalexa">Adventures with Alexa</a>. Pick your own price!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Building Alexa Skills in Swift ]]>
                </title>
                <description>
                    <![CDATA[ By Claus Höfele How to use Swift to develop custom skills for the Amazon Echo The Alexa Voice Service is Amazon’s cloud service that understands natural language and allows users to interact with devices by using their voice. You usually associate Al... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/building-alexa-skills-in-swift-3d596aa0ee95/</link>
                <guid isPermaLink="false">66c346c1c577a44239cd7b3c</guid>
                
                    <category>
                        <![CDATA[ Alexa ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ aws lambda ]]>
                    </category>
                
                    <category>
                        <![CDATA[ skills development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Swift ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 04 Dec 2016 17:00:19 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*1uxPyAsM7gCUf0YsWGYYgw.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Claus Höfele</p>
<h4 id="heading-how-to-use-swift-to-develop-custom-skills-for-the-amazon-echo">How to use Swift to develop custom skills for the Amazon Echo</h4>
<p>The Alexa Voice Service is Amazon’s cloud service that understands natural language and allows users to interact with devices by using their voice. You usually associate Alexa with Amazon’s voice-enabled speakers, such as the <a target="_blank" href="https://www.amazon.com/Amazon-Echo-Bluetooth-Speaker-with-WiFi-Alexa/dp/B00X4WHP5E">Echo</a>, but Alexa can potentially run on any connected device with a microphone and a speaker.</p>
<p>Unlike Apple’s Siri, whose extensions are <a target="_blank" href="https://developer.apple.com/library/prerelease/content/documentation/Intents/Conceptual/SiriIntegrationGuide/">limited to specific domains</a>, Alexa’s API enables developers to implement a broad range of custom voice services called “skills.” Using Swift allows iOS developers (like me) to expand their existing skill set to include server-side programming and take part in the trend towards voice user interfaces.</p>
<h3 id="heading-ingredients">Ingredients</h3>
<p>Simply put, Alexa sends your skill a JSON message with the user’s intent and your code answers with a JSON message that determines what Alexa will answer to the user.</p>
<p>Since I prefer to implement this functionality in Swift, I use <a target="_blank" href="https://github.com/choefele/AlexaSkillsKit">AlexaSkillsKit</a>, a Swift library that I wrote. It takes care of parsing JSON requests from Amazon, generating the proper responses and providing convenience methods to handle Alexa features.</p>
<p>The code for your custom skill can run as either a stand-alone web service or an AWS Lambda function. Using Lambda, Amazon’s serverless computing platform, Amazon will take care of scaling and running your Swift code — this is the reason I’ll use this deployment type for the finished skill. As you’ll see, however, the web service option is really useful while developing your skill.</p>
<p>Note that out of the box, Lambda only supports code written in JavaScript (Node.js), Python, and Java. But it’s easy to extend this to executables written in any programming language you want. My article <a target="_blank" href="https://medium.com/@claushoefele/serverless-swift-2e8dce589b68#.ts7aama46">Serverless Swift</a> provides a step-by-step guide on how to do this.</p>
<p>To summarize, you’ll need the following for your Alexa skill:</p>
<ul>
<li>An implementation of your skill’s functionality in Swift using <a target="_blank" href="https://github.com/choefele/AlexaSkillsKit">AlexaSkillsKit</a></li>
<li>A Lambda function set up with your Swift code using the <a target="_blank" href="https://aws.amazon.com/console/">AWS Console</a></li>
<li>An Alexa Skill configured in the <a target="_blank" href="https://developer.amazon.com/edw/home.html">Alexa Console</a> that triggers your Lambda function</li>
</ul>
<p>Note that the Alexa Console and the AWS Console are two separate services that you need to sign up for.</p>
<h3 id="heading-the-sample-project">The Sample Project</h3>
<p>To simplify your first steps, I created a repo with a sample app. <a target="_blank" href="https://github.com/choefele/swift-lambda-app">swift-lambda-app</a> contains code and scripts to quickly get you started with writing a custom Alexa skill in Swift and deploying it to AWS Lambda.</p>
<p>The sample app uses a standard Swift Package Manager directory layout and <a target="_blank" href="https://github.com/choefele/swift-lambda-app/blob/master/Package.swift">package file</a> thus <em>swift build</em>, <em>swift test</em> and <em>swift package generate-xcodeproj</em> work as expected. Check out the <a target="_blank" href="https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md">SPM documentation</a> for more info.</p>
<p>There are three targets:</p>
<ul>
<li><strong>AlexaSkill</strong>: this is a library with the code that implements the custom Alexa skill. It’s a separate library so it can be used by the other two targets. Also, libraries have <code>ENABLE_TESTABILITY</code> enabled by default which allows you to access internal methods and properties in your unit tests.</li>
<li><strong>Lambda</strong>: The command line executable for deployment to Lambda. This program uses <em>stdin</em> and <em>stdout</em> for processing data.</li>
<li><strong>Server</strong> (macOS only): To simplify implementing a custom Alexa Skill, the server provides an HTTP interface to the AlexaSkill target. This HTTP server can be exposed publicly via <a target="_blank" href="https://ngrok.com/">ngrok</a> and configured in the Alexa console, which enables you to develop and debug an Alexa skill with code running on your development computer. This target is macOS only because it wasn’t possible to cleanly separate target dependencies and I didn’t want to link libraries intended for server development to the Lambda executable used for deployment.</li>
</ul>
<p>For development, I recommend a <a target="_blank" href="https://en.wikipedia.org/wiki/Test-driven_development">Test-driven Development</a> approach against the library target, because this results in the quickest turnaround for code changes. Uploading to Lambda to quickly verify changes isn’t really an option because of slow uploading times. Exposing your functionality via HTTPS as described below, however, enables you to test and debug your functionality in a slightly different way.</p>
<h3 id="heading-implementing-a-custom-alexa-skill">Implementing a Custom Alexa Skill</h3>
<p>Start with implementing the <em>RequestHandler</em> protocol. AlexaSkillsKit parses requests from Alexa and passes the data on to methods required by this protocol.</p>
<pre><code>public protocol RequestHandler {        func handleLaunch(request: LaunchRequest, <span class="hljs-attr">session</span>: Session, <span class="hljs-attr">next</span>: @escaping (StandardResult) -&gt; ())
</code></pre><pre><code>    func handleIntent(request: IntentRequest, <span class="hljs-attr">session</span>: Session, <span class="hljs-attr">next</span>: @escaping (StandardResult) -&gt; ())
</code></pre><pre><code>    func handleSessionEnded(request: SessionEndedRequest, <span class="hljs-attr">session</span>: Session, <span class="hljs-attr">next</span>: @escaping (VoidResult) -&gt; ())}
</code></pre><p>For example, a <a target="_blank" href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/custom-standard-request-types-reference#launchrequest">launch request</a> would result in AlexaSkillsKit calling the <em>handleLaunch()</em> method.</p>
<pre><code><span class="hljs-keyword">import</span> Foundationimport AlexaSkillsKit
</code></pre><pre><code>public <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">AlexaSkillHandler</span> : <span class="hljs-title">RequestHandler</span> </span>{    public init() {}    public func handleLaunch(request: LaunchRequest, <span class="hljs-attr">session</span>: Session, <span class="hljs-attr">next</span>: @escaping (StandardResult) -&gt; ()) {        <span class="hljs-keyword">let</span> standardResponse = generateResponse(message: <span class="hljs-string">"Hello Swift"</span>)        next(.success(standardResponse: standardResponse, <span class="hljs-attr">sessionAttributes</span>: session.attributes))    }}
</code></pre><p>In the request handler, your custom skill can implement any logic your skill requires. To enable asynchronous code (for example calling another HTTP service), the result is passed on via the <em>next</em> callback. <em>next</em> takes a enum that’s either <em>.success</em> and contains an Alexa response or <em>.failure</em> in case a problem occurred.</p>
<p>To keep things simple, we’ll pass back a message that Alexa will speak out loud to the user:</p>
<pre><code>func generateResponse(message: <span class="hljs-built_in">String</span>) -&gt; StandardResponse {    <span class="hljs-keyword">let</span> outputSpeech = OutputSpeech.plain(text: message)    <span class="hljs-keyword">return</span> StandardResponse(outputSpeech: outputSpeech)}
</code></pre><h3 id="heading-debugging-your-code-with-local-http-server">Debugging Your Code with Local HTTP Server</h3>
<p>Invocation of a <em>RequestHandler</em> as part of a Swift server is done via Amazon’s HTTPS API where the Alexa service calls your server with a POST request. In the following code, <a target="_blank" href="https://github.com/IBM-Swift/Kitura">Kitura</a> is used as a web framework, but any other web framework would work equally well:</p>
<pre><code><span class="hljs-keyword">import</span> Foundationimport AlexaSkillsKitimport AlexaSkillimport Kiturarouter.all(<span class="hljs-string">"/"</span>) { request, response, next <span class="hljs-keyword">in</span>    <span class="hljs-keyword">var</span> data = Data()    <span class="hljs-keyword">let</span> _ = <span class="hljs-keyword">try</span>? request.read(into: &amp;data)    <span class="hljs-keyword">let</span> requestDispatcher = RequestDispatcher(requestHandler: AlexaSkillHandler())    requestDispatcher.dispatch(data: data) { result <span class="hljs-keyword">in</span>        <span class="hljs-keyword">switch</span> result {        <span class="hljs-keyword">case</span> .success(<span class="hljs-keyword">let</span> data):            response.send(data: data).status(.OK)        <span class="hljs-keyword">case</span> .failure(<span class="hljs-keyword">let</span> error):            response.send(error.message).status(.badRequest)        }        next()    }}Kitura.addHTTPServer(onPort: <span class="hljs-number">8090</span>, <span class="hljs-attr">with</span>: router)Kitura.run()
</code></pre><p>To run a local HTTPS server:</p>
<ul>
<li>Make sure the sample builds by running <em>swift build</em></li>
<li>Generate an Xcode project with <em>swift package generate-xcodeproj</em></li>
<li>Open the generated Xcode project, select the Server scheme and run the product (CMD-R). This will start a server at port 8090</li>
<li>Install ngrok via <em>brew cask install ngrok</em>. This tool allows you to expose a local HTTP server to the internet</li>
<li>Run <em>ngrok http 8090</em> and copy the HTTPS URL generated by ngrok (it looks similar to https://c4ba192c.ngrok.io)</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/oTg3tdnBl-Ko4ksBBstFqLLFq29Ek2GcB-6g" alt="Image" width="800" height="412" loading="lazy"></p>
<p>ngrok exposes your local server to the public internet thus allowing the Alexa Voice Service to call into your custom skill running in Xcode.</p>
<h3 id="heading-configuring-the-alexa-skill">Configuring the Alexa Skill</h3>
<p>To hook up your custom skill to Alexa:</p>
<ul>
<li>Go to the <a target="_blank" href="https://developer.amazon.com/edw/home.html#/skills/list">Alexa console</a> and create a new skill</li>
<li>Skill type: Custom Interaction Model</li>
<li>Intent: <code>{"intents": [{"intent": "TestIntent"}]}</code></li>
<li>Sample utterances: “TestIntent test swift”</li>
<li>SSL Certificate: Select “My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority”</li>
<li>Service endpoint type: <em>HTTPS (use the URL from ngrok)</em></li>
</ul>
<p>Now you can test the skill in the Alexa Console’s Service Simulator using the utterance “test swift”. This will call your local server allowing you to modify and debug your code while interacting with the Alexa service.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/eQLxWIDrhg7aBhMOERXzLRPohltuzaqNim54" alt="Image" width="800" height="497" loading="lazy"></p>
<h3 id="heading-running-tests-for-your-code">Running Tests for Your Code</h3>
<p>Before uploading to Lambda, it’s worthwhile to run your unit tests in a Linux environment and run integration tests that simulate the execution environment. The sample provides <a target="_blank" href="https://github.com/choefele/swift-lambda-app/blob/master/run-unit-tests.sh"><em>run-unit-tests.sh</em></a> to do the former and <a target="_blank" href="https://github.com/choefele/swift-lambda-app/blob/master/run-integration-tests.sh"><em>run-integration-tests.sh</em></a> to do the latter.</p>
<p><em>run-unit-tests.sh</em> builds and tests the Lambda target inside a Swift Docker container based on Ubuntu because there's currently no Swift compiler for Amazon Linux (based on RHEL). Executables built on different Linux distributions are compatible with each other if you provide all dependencies necessary to run the program. For this reason, the script captures all shared libraries required to run the executable using <em>ldd</em>.</p>
<p>To prove that the resulting package works, <em>run-integration-tests.sh</em> runs a release build of the Swift code inside a Docker container that comes close to Lambda’s execution environment (unfortunately, <a target="_blank" href="https://hub.docker.com/_/amazonlinux/">Amazon only provides a few Docker images</a> that don't necessarily match what <a target="_blank" href="http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html">Lambda is using</a>).</p>
<p>The integration with Lambda is done via a small <a target="_blank" href="https://github.com/choefele/swift-lambda-app/blob/master/Shim/index.js">Node.js script</a> that uses the _child<em>process</em> module to run the Swift executable. The script follows Amazon's recommendations to <a target="_blank" href="https://aws.amazon.com/blogs/compute/running-executables-in-aws-lambda/">run arbitrary executables in AWS Lambda</a>.</p>
<p>After <a target="_blank" href="https://github.com/choefele/swift-lambda-app/blob/master/.travis.yml">configuring Travis</a>, you can run the same integration script also for every commit.</p>
<h3 id="heading-deploying-your-code-to-lambda">Deploying Your Code to Lambda</h3>
<p>For Lambda, you need to create an executable that takes input from <em>stdin</em> and writes output to <em>stdout</em>. This can be done with the following code:</p>
<pre><code><span class="hljs-keyword">import</span> Foundationimport AlexaSkillsKitimport AlexaSkilldo {    <span class="hljs-keyword">let</span> data = FileHandle.standardInput.readDataToEndOfFile()    <span class="hljs-keyword">let</span> requestDispatcher = RequestDispatcher(requestHandler: AlexaSkillHandler())    <span class="hljs-keyword">let</span> responseData = <span class="hljs-keyword">try</span> requestDispatcher.dispatch(data: data)    FileHandle.standardOutput.write(responseData)} <span class="hljs-keyword">catch</span> <span class="hljs-keyword">let</span> error <span class="hljs-keyword">as</span> MessageError {    <span class="hljs-keyword">let</span> data = error.message.data(using: .utf8) ?? Data()    FileHandle.standardOutput.write(data)}
</code></pre><p>Note that this code uses the same <em>RequestHandler</em> that was used for the HTTP server thus minimizing the differences to the development environment.</p>
<p>To deploy your code to Lambda:</p>
<ul>
<li>Run <em>run-integration-tests.sh</em> to produce a zip file at .build/lambda/lambda.zip with all required files to upload to Lambda</li>
<li>Create a new Lambda function in the <a target="_blank" href="https://console.aws.amazon.com/lambda/home">AWS Console</a> in the US East/N. Virginia region (for Europe use EU/Ireland)</li>
<li>Use an Alexa Skills Kit trigger</li>
<li>Runtime: NodeJS 4.3</li>
<li>Code entry type: ZIP file (upload the lambda.zip file from the previous step)</li>
<li>Handler: index.handler</li>
<li>Role: Create from template or use existing role</li>
</ul>
<p>Once you uploaded the Lambda function, you can use the test actions in the AWS Console, for example by using a Start Session action.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/HB448STSmeJW0tYbqsWJToGOV2gJjRQsWkcV" alt="Image" width="800" height="554" loading="lazy"></p>
<h3 id="heading-configuring-the-alexa-skill-for-lambda">Configuring the Alexa Skill for Lambda</h3>
<p>After creating the Lambda function, you can now create an Alexa skill. If you have previously created an Alexa skill for the local HTTP server — the only difference is the service endpoint:</p>
<ul>
<li>Go to the <a target="_blank" href="https://developer.amazon.com/edw/home.html#/skills/list">Alexa console</a> and create a new skill</li>
<li>Skill type: Custom Interaction Model</li>
<li>Intent: <code>{"intents": [{"intent": "TestIntent"}]}</code></li>
<li>Sample utterances: “TestIntent test swift”</li>
<li>Service endpoint type: <em>AWS Lambda ARN</em> (use the ARN for the Lambda function from the AWS Console)</li>
</ul>
<p>Now you can test the skill in the Alexa Console using the utterance “test swift”. More details on configuring Alexa skills can be found on <a target="_blank" href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/overviews/steps-to-build-a-custom-skill">Amazon’s developer portal</a>.</p>
<h3 id="heading-wrapping-up">Wrapping Up</h3>
<p>Check out the <a target="_blank" href="https://github.com/choefele/swift-lambda-app">swift-lambda-app</a> repo on GitHub for the code and scripts to develop and deploy a simple Alex skill in Swift. In future articles, I’ll provide more details on how to write useful skills. Meanwhile, you can browse <a target="_blank" href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference">Amazon’s documentation</a> or contact me on <a target="_blank" href="https://twitter.com/claushoefele">Twitter</a> if you have any question.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
