<?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" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Carl Cheel on Medium]]></title>
        <description><![CDATA[Stories by Carl Cheel on Medium]]></description>
        <link>https://medium.com/@carlcheel?source=rss-7b97c934702e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*19YZMfVTctmDy9t7tE-yZA.jpeg</url>
            <title>Stories by Carl Cheel on Medium</title>
            <link>https://medium.com/@carlcheel?source=rss-7b97c934702e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 14:48:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carlcheel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating an Alexa skill with Node, AWS Lambda, Babel, Webpack, Serverless and the ASK CLI.]]></title>
            <link>https://medium.com/@carlcheel/creating-an-alexa-skill-with-node-aws-lambda-babel-webpack-serverless-and-the-ask-cli-dcc99cc582bd?source=rss-7b97c934702e------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcc99cc582bd</guid>
            <category><![CDATA[alexa-skills]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Carl Cheel]]></dc:creator>
            <pubDate>Thu, 01 Mar 2018 10:56:45 GMT</pubDate>
            <atom:updated>2018-06-04T09:56:14.825Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IFxNmpVYcg4Tt9Kv." /><figcaption>Photo by <a href="https://unsplash.com/@hckmstrrahul?utm_source=medium&amp;utm_medium=referral">Rahul Chakraborty</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>I’ve just finished creating my first production Alexa skill and I thought I’d share a quick guide on what I learnt along the way. It includes information on how to get started with a lot of the best practices baked in.</p><p>If you get a minute, check out my skill. <a href="https://www.amazon.co.uk/gp/product/B079T274ZM?ie=UTF8&amp;ref-suffix=ss_rw">I’m Home</a> 🏡</p><h3>Prerequisites 📦</h3><p>There are a few things you’ll have to install first, I’d recommend doing them in the order below to avoid any issues. Skip anything you’ve already got installed.</p><ul><li><strong>Node ≥ v6.5.0 </strong>-<strong> </strong>To install or update your version of Node, visit the <a href="https://nodejs.org/en/download/">Node.js downloads page</a>.</li><li><strong>An AWS account </strong>- Used to deploy your code to Lambda.</li><li><strong>An Amazon developer account</strong> - Required to set up your Alexa skill. Visit the <a href="https://developer.amazon.com/home.html">Amazon Developer Portal</a> to set this up.</li><li><strong>The AWS CLI</strong> - Install the <a href="https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html">AWS CLI</a>. After installation run aws configure and enter your <strong>AWS Access Key ID</strong> and <strong>Secret</strong>, which can be obtained from the <a href="https://console.aws.amazon.com/iam/home?region=eu-west-1#/home">IAM console</a>. Remember to use the <a href="https://en.wikipedia.org/wiki/Principle_of_least_privilege">Principle of least privilege</a> for your IAM users. You might hit a few issues if you don’t have access but it’s really simple grant extra access.</li><li><strong>Alexa Skills Kit CLI</strong> — Install the <a href="https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html#step-1-prerequisites-for-using-ask-cli">Alexa Skills Kit CLI</a> using npm. Simply open a terminal and run npm install -g ask-cli &gt; ask init</li></ul><h3>Start the project 🗂</h3><p>In this section we’ll set up our folder structure, configure serverless, babel and webpack.</p><h4>Create the folder structure</h4><p>Open a terminal in a directory you want to store your project (the root folder will be created for you) and run ask new. Follow the steps to link your account. After completion you’ll see a tree structure that looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*HKcjP4LbnQcvAtt82pJdwA.png" /><figcaption>Initial folder structure.</figcaption></figure><h4>Set up Serverless</h4><ol><li>Install <a href="https://serverless.com/framework/docs/getting-started/">Serverless</a>.</li><li>cd into &lt;project dir&gt;/lambda/custom and create a new file named <strong>serverless.yml </strong>with the following content:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1dea039125124a245336f516af86dd20/href">https://medium.com/media/1dea039125124a245336f516af86dd20/href</a></iframe><p>3. Open &lt;project dir&gt;/lambda/custom/<strong>package.json </strong>and setup a dev and production deployment script (we’ll be running these later).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kCjqJH52ToueW7MHVxYxuw.png" /><figcaption>Development and Production deployment scripts</figcaption></figure><h4>Set up Webpack</h4><ol><li>Open a terminal window at &lt;project dir&gt;/lambda/custom</li><li>npm install webpack webpack-node-externals serverless-webpack --save-dev</li></ol><blockquote>- webpack — The core webpack package.</blockquote><blockquote>- webpack-node-externals — Tells webpack not to bundle node_modules.</blockquote><blockquote>- serverless-webpack — Provides the entry points for your serverless functions to webpack.</blockquote><p>3. Create a new file named <strong>webpack.config.js </strong>and include the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97a45e156f965d25bf270dbb4d2ba377/href">https://medium.com/media/97a45e156f965d25bf270dbb4d2ba377/href</a></iframe><h4>Set up Babel (optional but recommended)</h4><p>If you decide not to set up babel, remove the module section from the <strong>webpack.config.js</strong></p><ol><li>Open a terminal window at &lt;project dir&gt;/lambda/custom</li><li>npm install babel babel-cli babel-loader babel-preset-env --save-dev</li></ol><blockquote>- babel — The core babel package.</blockquote><blockquote>- babel-cli — Needed to use babel-node, which we use to run the code locally.</blockquote><blockquote>- babel-loader — Transpile via babel during webpack bundling.</blockquote><blockquote>- babel-preset-env — Automatically determines the Babel plugins and polyfills you need based on your targeted runtime.</blockquote><p>3. Create a <strong>.babelrc</strong> file with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/291f8a15760ab5ac24f3d49ff8e5afbd/href">https://medium.com/media/291f8a15760ab5ac24f3d49ff8e5afbd/href</a></iframe><p>That’s the project all set up, all that’s left is to deploy and test our code.</p><h3>Deployments 🚀</h3><h4>Deploy the lambda</h4><p>Serverless makes this one super easy, run npm run sls-deploy</p><p>To double check everything has worked smoothly, log in to your <a href="https://eu-west-1.console.aws.amazon.com/lambda/home">AWS Lambda console</a> and ensure you can see your newly created function. If you can’t, check you’ve selected the right region, for example, eu-west-1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fnkLoO4ZqaH0XNZtkATpTA.png" /><figcaption>Lambda console example</figcaption></figure><p>Click on the Lambda function and copy the Lambda ARN and paste it in the endpoint URI section of your .ask/config file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XkwhWrJhkyFjemTZhI3u7w.png" /></figure><p>Whenever you update your code, just run npm run sls-deploy when you’re ready to push it to Lambda.</p><h4>Deploy the Alexa skill</h4><p>Because serverless is handling our lambda deployments, we’re going to remove a section in our<strong> skill.json </strong>file. This means ask deploy will just handle the deployment to the Alexa skill console and interaction models not our lambda function.</p><p>Open <strong>skill.json</strong> and remove the APIs section. You’ll be left with something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*AFNPHWVftP5UUASFs49s0g.png" /><figcaption>After removing the APIs section.</figcaption></figure><p>In a Terminal window cd into your project directory (along side the <strong>skill.json</strong> file) and runask deploy</p><p><strong>Note: </strong>If running ask deploy without flags is causing issues, try ask deploy -t model which just deploys the model.</p><p>To check everything has deployed successfully, open the <a href="https://developer.amazon.com/edw/home.html#/skills">Developer Portal</a> and you should your skill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lf7oJtLEigZMSAYoQT5F0A.png" /><figcaption>Example Alexa skill in the Amazon Developer Console</figcaption></figure><h3>Testing locally 👩🏻‍💻</h3><p>I find the quickest and easiest way to test your Alexa skill locally is through <a href="https://expressjs.com/"><strong>express</strong></a> and <a href="https://ngrok.com/"><strong>ngrok</strong></a>.</p><h4>Set up express</h4><ol><li>Open a terminal window at &lt;project dir&gt;/lambda/custom</li><li>Install express npm install express --save-dev</li><li>Create a file named <strong>dev.init.js </strong>and add the following code</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2199ab5244423c01f7a27a14057bab2/href">https://medium.com/media/c2199ab5244423c01f7a27a14057bab2/href</a></iframe><p>4. Add a start and debug npm script to your <strong>package.json</strong>. One for debug and one for without.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zf4Ec-TEFbQNCSIiKE_-_Q.png" /><figcaption>Run scripts in package.json</figcaption></figure><p>If you’ve decided not to use babel, change <strong>babel-node</strong> for <strong>node</strong>.</p><h4>Set up ngrok</h4><p><a href="https://ngrok.com/download">Download ngrok</a> and unzip the contents to a folder on your machine. To test it’s all working, run path/to/ngrok http 3000</p><p>If everything is set up correctly you’ll see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kb6B5NLIOWErkxiHDJ6XKw.png" /></figure><h4>Try it</h4><ol><li>Open a terminal window at &lt;project dir&gt;/lambda/custom &gt; run npm run start . This will start express and listen for requests on port 3000.</li><li>Open another terminal window and run path/to/ngrok http 3000 . This will open a tunnel from your localhost:3000 to a randomly generated ngrok URL.</li><li>Copy the <strong>Forwarding</strong> https URL (<a href="https://9d2ce67c.ngrok.io)]">https://9d2ce67c.ngrok.io</a> in the screenshot above)</li><li>Open the <a href="https://developer.amazon.com/edw/home.html#/skillshttps://developer.amazon.com/edw/home.html#/skills">Alexa skills developer console</a> &gt; click on the skill &gt; configuration &gt; Select HTTPS &gt; paste the ngrok https URL in the box &gt; Save.</li><li>Click Test &gt; Go to Test Simulator</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*oWM3lM601zhdqH4jHtS2Hg.png" /><figcaption>Go to Test Simulator button in the Alexa skills console</figcaption></figure><p>Type “<strong>ask hello world” </strong>in the test box and you should get a response from your local machine. You can now use npm run debug and add breakpoints in your favourite editor! 🤓</p><h3>Editing your code and interaction model ✏️</h3><h4>Interaction model</h4><p>It’s worth spending time getting your interaction model right first before writing any code. First visit the <a href="https://developer.amazon.com/edw/home.html#/skills">Developer Portal</a> &gt; select your skill &gt; interaction model &gt; Launch Skill Builder<strong>.</strong></p><p>Add any intents you’re going to need for your skill. Details on exactly how to do this are outside the scope of this article, but <a href="https://developer.amazon.com/docs/custom-skills/use-the-skill-builder-beta-to-define-intents-slots-and-dialogs.html">check this article out for more details</a>. Let me know if there’s a good article / video for this, let me know in the comments.</p><p>Once you’ve generated your interaction model, click <strong>Code Editor </strong>and copy the contents.</p><p>To ensure your model is version controlled, paste this over the <strong>languageModel section</strong> in your models/<strong>&lt;locale&gt;.json </strong>file. Ensure you don’t paste over the whole thing or you’ll encounter problems when deploying.</p><p>To deploy this model, simply run ask deploy</p><p><strong>Note: </strong>If running ask deploy without flags is causing issues, try ask deploy -t model which just deploys the model.</p><h4>Generate sample code</h4><p><a href="https://skillinator.io/">Skillinator.io</a> is an awesome tool to generate sample code from your interaction model. Paste your interaction model into the box and hit generate.</p><p>Copy the lambda template section and paste it in <strong>&lt;project dir&gt;/lambda/custom/index.js</strong>.<strong> </strong>Make the changes you need and redeploy using thenpm run sls-deploy scripts.</p><h3>Wrap up</h3><p>I hope you enjoyed this article, please leave any feedback in the comments section or get in touch on <a href="https://twitter.com/@carlcheel13">Twitter — @carlcheel13</a>.</p><p>Remember to check out my skill if you have time — <a href="https://www.amazon.co.uk/gp/product/B079T274ZM?ie=UTF8&amp;ref-suffix=ss_rw">I’m Home</a>. 🏡</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcc99cc582bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>