<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sam Williams</title>
    <description>The latest articles on DEV Community by Sam Williams (@samwsoftware).</description>
    <link>https://dev.to/samwsoftware</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F45009%2F0da7ae20-6561-4b7d-9bf2-ad1e5ace0847.jpg</url>
      <title>DEV Community: Sam Williams</title>
      <link>https://dev.to/samwsoftware</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samwsoftware"/>
    <language>en</language>
    <item>
      <title>The Ultimate Guide to Migrating to the Cloud with Serverless</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Wed, 07 Aug 2019 07:00:31 +0000</pubDate>
      <link>https://dev.to/samwsoftware/the-ultimate-guide-to-migrating-to-the-cloud-with-serverless-2e60</link>
      <guid>https://dev.to/samwsoftware/the-ultimate-guide-to-migrating-to-the-cloud-with-serverless-2e60</guid>
      <description>&lt;h4&gt;
  
  
  A step by step guide to migrating an existing software product to run serverlessly in the cloud
&lt;/h4&gt;

&lt;p&gt;You’ve got an app that you run and you’ve heard loads about serverless and the benefits. You may have even tried deploying some things with serverless but you want to move you whole app to serverless.&lt;/p&gt;

&lt;p&gt;How do you do that? What bits do you do first? Do you have to do it all at the same time?&lt;/p&gt;

&lt;p&gt;This article will guide you through the steps you can take to migrate your app or service to the cloud with Serverless.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Simple APIs
&lt;/h3&gt;

&lt;p&gt;When you start the process of migrating your service to, it’s best to start with the low hanging fruit. This will get you some experience working with serverless and AWS but still provide value to the application.&lt;/p&gt;

&lt;p&gt;Simple APIs are endpoints that don’t need to access your databases to perform their actions. This could be an API for sending emails, hitting external APIs and combining the data or for running some logic on the input.&lt;/p&gt;

&lt;p&gt;A secondary advantage to creating these APIs is that it reduces the load on the existing servers. We, at MissionLabs, have found that this removal of functionality and complexity has allowed us to reduce the code on our servers by over 50%. This has resulted in much more readable code and quicker bug fixes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to migrate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--droUM8QW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/535/0%2AgO1wm8d-FYq6EWIk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--droUM8QW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/535/0%2AgO1wm8d-FYq6EWIk.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Luckily, migrating simple APIs to the cloud using serverless is really easy with AWS Lambda and API Gateway.&lt;/p&gt;

&lt;p&gt;AWS Lambda is a cloud function service where you can run code functions and only pay for when the function is running. You can write your code in Ruby, Python, Node, Java, Go or .Net and through the AWS SDK you can easily access other AWS services (such as email, sms, kinesis, databases).&lt;/p&gt;

&lt;p&gt;To create an API using AWS Lambda and API Gateway you need to write a function that executes the logic. Then you need to export the function as exports.handler .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.handler = async (event, context) =&amp;gt; { 
    // your function code goes here 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To deploy your code with an API using serverless, we need to add this new function to our serverless.yml file under function declaration. You need to define the location of the code as well as the methods and path for the API endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;functions:    
myFirstApi:
    handler: src/myFirstApi/index.handler        
        events:            
        - http:
              path: getFromMyAPI                  
              method: GET
              cors: true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This will deploy your function code to ${random-api-subdomain}.execute-api.${region}.amazonaws.com/${stage}/getFromMyApi. Here is an example of an endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ic5hwq6j0a.execute-api.eu-west-1.amazonaws.com/live/item"&gt;https://ic5hwq6j0a.execute-api.eu-west-1.amazonaws.com/live/item&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to create a more readable API address then you can use Route 53 to forward traffic so that your endpoint could be something like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://api.completecoding.io/v1/item"&gt;https://api.completecoding.io/v1/item&lt;/a&gt; (not active)&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Databases and Connected APIs
&lt;/h3&gt;

&lt;p&gt;Now that you’ve migrated some of your APIs, you’re familiar with writing Lambda functions and deploying them with Serverless.&lt;/p&gt;

&lt;p&gt;The next step is to migrate your databases over to serverless and create the rest of your APIs.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.1 Databases
&lt;/h4&gt;

&lt;p&gt;Databases are obviously a massive part of any software product, but creating, managing and scaling them can be a pain. Provisioning shards and syncing instances can be difficult at the best of times.&lt;/p&gt;

&lt;p&gt;With Serverless you can use DynamoDB, where scaling and performance are managed by AWS, leaving you to work on the valuable parts of the product.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G4oZ1iMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/854/0%2AtJqlob-FSsWCU7ZG.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G4oZ1iMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/854/0%2AtJqlob-FSsWCU7ZG.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to migrate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creating DynamoDB tables in serverless is relatively simple. All we need to do is create a new Resource and provide the table details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Resources:  
    OrderTable:
    Type: AWS::DynamoDB::Table
        Properties:
        TableName: order-table
            AttributeDefinitions:
            - AttributeName: userID
                  AttributeType: S
                - AttributeName: orderId
                  AttributeType: S
            KeySchema:
            - AttributeName: userId
                  KeyType: HASH
                - AttributeName: orderId
                  KeyType: HASH
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Things can get a little more complex when it comes to auto-scaling and secondary indexes.&lt;/p&gt;

&lt;p&gt;To get auto-scaling added to our table, we have two options. We can either set up PayPerReqest billing or provision auto-scaling on the table.&lt;/p&gt;

&lt;p&gt;PayPerRequest is better if you have more irregular traffic that comes in spikes and troughs. To provision is you can remove these lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ProvisionedThroughput:
    ReadCapacityUnits: 5
    WriteCapacityUnits: 5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and replace them with this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BillingMode: PAY\_PER\_REQUEST
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The other option is to add auto-scaling. This wasn’t a feature when Dynamo was first released so the configuration is more complex. To reduce the complexity we can use the serverless-dynamodb-autoscaling plugin. To install this plugin run npm install serverless-dynamodb-autoscaling and then add some custom fields to our serverless.yml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins:  
    - serverless-dynamodb-autoscaling
custom:  
    capacities:    
        - table: order-table # DynamoDB Resource      
          read:
              minimum: 5 # Minimum read capacity
              maximum: 1000 # Maximum read capacity        
              usage: 0.75 # Targeted usage percentage      
          write:        
              minimum: 40 # Minimum write capacity
              maximum: 200 # Maximum write capacity
              usage: 0.5 # Targeted usage percentage
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should use whichever of these methods is most applicable to how each of your tables is used. There is no reason you can’t have some tables on PayPerRequest and others using normal auto-scaling.&lt;/p&gt;

&lt;p&gt;There is also the issue of migrating all your data from your existing tables to your new dynamo tables. Luckily this is a &lt;a href="https://aws.amazon.com/dynamodb/migrations/"&gt;brilliant article&lt;/a&gt; about how to complete these kinds of migrations, whether from MongoDB, Cassandra, mySQL or RDBMS.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.2 Connected APIs
&lt;/h4&gt;

&lt;p&gt;Now that we have our databases created, we should be able to convert most of our remaining APIs over to serverless. These might be user lookups, logins, product lookups, order status updates or any other kind of request that read or write to one of your tables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to migrate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The process to create these functions will be exactly the same as the process that you did in step 1, but now we have databases to access.&lt;/p&gt;

&lt;p&gt;To access your data in DynamoDB, you can use the AWS SDK and the DynamoDB document client. This interface has the functionality to perform all the rest methods as well as a few extras such as &lt;em&gt;scan, query, batchGet&lt;/em&gt; and &lt;em&gt;batchWrite&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Whilst these sound perfect for baking into your Lambda code, I would suggest creating your own class that uses these methods. This is because the format of the request made to the document client is often overly complicated. Here’s my example of a simplified method for getting from Dynamo.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get(ID, table) {
    if (!table)
        throw 'table needed';
    if (typeof ID !== 'string')
        throw `ID was not string and was ${ID} on table ${table}`;
    return new Promise((resolve, reject) =&amp;gt; {
        let params = {
            TableName: table,
            Key: {
                ID: ID,
            },
        };
        documentClient.get(params, function (err, data) {
            if (err) {
                console.log(`There was an error fetching the data for ID ${ID} on table ${table}`, err);
                return reject(err);
            }
            return resolve(data.Item);
        });
    });
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you now need to do a lookup in any of your APIs you can just use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let user = await DB.get('123-f342-3ca', 'user-table')
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can do the same for write, update, delete, scan and query.&lt;/p&gt;

&lt;p&gt;With these methods, you should be able to port almost all your APIs over to serverless. This can be a large piece of work but there are a lot of benefits, including autoscaling, only pay for what you use, redundancy, separation of concerns and many more.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Storage
&lt;/h3&gt;

&lt;p&gt;Cloud storage was the first service that was ever provided by AWS — Amazon S3. This service allows you to host file in the cloud, define the access policies, and easily use those files in other AWS services.&lt;/p&gt;

&lt;p&gt;Items stored in S3 are put into buckets, which are isolated containers used to group items (similar to folders on your machine). You can store whatever files you like in S3, from product images to invoices, from data in JSON format to whole websites.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ox9XGq4h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/960/0%2Ac5UnX4FIuiYXGxt1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ox9XGq4h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/960/0%2Ac5UnX4FIuiYXGxt1.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to migrate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two stages to migrating to serverless cloud storage: creating the buckets and deploying the resources.&lt;/p&gt;

&lt;p&gt;To create a bucket in serverless, you are defining a new resource. One thing to remember is that the bucket name must be globally unique. This means you can’t have the same bucket name on two accounts, or in two regions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resources:
  Resources:
    UploadBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-bucket-name-is-unique
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When you run sls deploy now, you'll find that you've created a bucket on your account. Now you can manually upload files into this bucket using the UI, or use it as a location to put uploaded files, but we're also going to learn how to sync up local files to the bucket.&lt;/p&gt;

&lt;p&gt;To automatically upload files to our new bucket, we’re going to be using the serverless-s3-sync plugin. This plugin allows us to upload all the content of a folder on our computer to an S3 bucket as part of the deployment process.&lt;/p&gt;

&lt;p&gt;To start using the plugin, we need to install it using npm install --save serverless-s3-sync and then adding the plugin to our serverless file. With out autoscaling DynamoDB plugin we'll now have this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins:  
    - serverless-dynamodb-autoscaling
    - serverless-s3-sync
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To configure the upload we need to add another field to our custom section as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;custom:
  s3Sync:
    - bucketName: my-bucket-name-is-unique # required 
      bucketPrefix: assets/ # optional 
      localDir: dist/assets # required
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The bucketName needs to match the name of the bucket you created. The localDir is the folder that you want to upload to the bucket. You can also use bucketPrefix if you want to add a prefix onto the start of the files (put them in a folder within the bucket).&lt;/p&gt;

&lt;p&gt;With this all set up, running sls deploy will now create a new bucket and upload the files you have in dist/assets.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Website Hosting
&lt;/h3&gt;

&lt;p&gt;So far you will have had to make quite a few URL changes to your website for all the API changes that you’ve already implemented. Now wouldn’t it be cool if you could also host that website entirely serverlessly and deploy it with all of your APIs, databases and everything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to migrate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We’re going to host and deploy our website in a very similar way to the way that we are hosting our asset storage in the last section: serverless-s3-sync.&lt;/p&gt;

&lt;p&gt;There are a few extra bits that we need to take care of when we’re hosting a website. To start out though, we’re still uploading a folder (containing our static site) to an S3 bucket. We can add a new bucket (MyWebsiteBucket) and new S3Sync setup. We set a custom variable called siteName and then use that to define the bucket name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resources:
  Resources:
    UploadBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: my-bucket-name-is-unique
    MyWebsiteBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:custom.siteName}

custom:
  s3Sync:
    - bucketName: my-bucket-name-is-unique 
      bucketPrefix: assets/
      localDir: dist/assets
    - bucketName: ${self:custom.siteName}  
      localDir: myWebsiteFolder
  siteName: serverlessfullstack.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;But this time we need to add a few more things onto our S3 bucket configuration. We need to set the access control and tell S3 that this is a website we’re hosting in the bucket.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    MyWebsiteBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:custom.siteName}
        WebsiteConfiguration:
          IndexDocument: index.html
        AccessControl: PublicRead
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We also need to create a policy document for the bucket in our resources&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    WebsiteS3BucketPolicy:
      Type: AWS::S3::BucketPolicy
      Properties:
        Bucket:
          Ref: MyWebsiteBucket
        PolicyDocument:
          Statement:
            - Sid: PublicReadGetObject
              Effect: Allow
              Principal: "\*"
              Action:
              - s3:GetObject
              Resource:
              Fn::Join: ["", [
                  "arn:aws:s3:::",
                  {"Ref": "StaticSite"},
                  "/\*"
                ]]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;When we now run sls deploy we'll get our content of our website uploaded to S3 and all the correct permissions set on the bucket.&lt;/p&gt;

&lt;p&gt;You’ll now be able to view your site at &lt;a href="http://serverlessfullstack.com.s3-website-us-east-1.amazonaws.com/"&gt;http://serverlessfullstack.com.s3-website-us-east-1.amazonaws.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is nice but it would be better if we were hosting on our own url, so that’s what we’ll do now. We need to create a DNS record that points the requested domain to our s3 bucket.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1CZNKJtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2ArSb9sWpJ-AS20Mie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1CZNKJtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/0%2ArSb9sWpJ-AS20Mie.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Route 53, make sure you’ve set up your hosted zone name and then we can add the DNS record to the resources.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    DnsRecord:
        Type: 'AWS::Route53::RecordSet'
        Properties:
            AliasTarget:
                DNSName: ${self:custom.aliasDNSName}
                HostedZoneId: ${self:custom.aliasHostedZoneId}
            HostedZoneName: ${self:custom.siteName}.
            Name:
                Ref: MyWebsiteBucket
            Type: 'A'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With this we also need to set a few extra custom fields of hostedZoneName, aliasHostedZoneId and aliasDNSName.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;custom:
    s3Sync:
        - bucketName: ${self:custom.siteName}
          localDir: myWebsiteFolder
    siteName: serverlessfullstack.com
    hostedZoneName: ${self:custom.siteName}
    aliasHostedZoneId: Z3AQBSTGFYJSTF # us-east-1
    aliasDNSName: s3-website-us-east-1.amazonaws.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you’ve set this up in a region that isn’t us-east-1 then you can find your aliasHostedZoneId &lt;a href="https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With this all set up you should now be able to run sls deploy again. This will add the DNS record to your account and now you can visit serverlessfullstack.com and see the live page hosted from S3.&lt;/p&gt;

&lt;p&gt;If you’ve followed along, the only differences between our code should be: custom.siteName and your assets bucket name and you should have your own serverlessly hosted app!&lt;/p&gt;

&lt;p&gt;If you’ve found this article useful and want to start working with Serverless then check out my &lt;a href="https://courses.completecoding.io/p/build-a-serverless-api/"&gt;FREE course&lt;/a&gt; on creating and deploying a Serverless API. You’ll learn to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a user and get credentials on AWS and set up Serverless&lt;/li&gt;
&lt;li&gt;Create a Lambda and API Endpoint to handle the API requests&lt;/li&gt;
&lt;li&gt;Deploy, Test and Update your API&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://courses.completecoding.io/p/build-a-serverless-api/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--POGyoheP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/960/1%2AU5Oib-puk-qaqN5QqI_T-Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://completecoding.io/migrating-your-app-to-the-aws-cloud-with-serverless/"&gt;&lt;em&gt;https://completecoding.io&lt;/em&gt;&lt;/a&gt; &lt;em&gt;on August 7, 2019.&lt;/em&gt;&lt;/p&gt;




</description>
      <category>migration</category>
      <category>serverless</category>
      <category>aws</category>
    </item>
    <item>
      <title>What you need to become a full-stack serverless developer</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Tue, 16 Jul 2019 21:14:10 +0000</pubDate>
      <link>https://dev.to/samwsoftware/what-you-need-to-become-a-full-stack-serverless-developer-1ncp</link>
      <guid>https://dev.to/samwsoftware/what-you-need-to-become-a-full-stack-serverless-developer-1ncp</guid>
      <description>&lt;h4&gt;
  
  
  The 4 areas of development you need to know to call yourself a full-stack developer
&lt;/h4&gt;

&lt;p&gt;Becoming a full-stack developer is the goal of a lot of developers. Being able to create a complete software product, getting to understand how the whole system work and the very nice wage increase(Over £5,500**) are all reasons people want to level up their skills and become a full-stack developer.&lt;/p&gt;

&lt;p&gt;The issue is that learning all of the skills you need can take a lot of time. We’ll cover the 4 areas of development that you need to know and discuss the best way that you can learn them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Front End /Website Hosting
&lt;/h3&gt;

&lt;p&gt;Whenever you build any sort of application, it needs to have a front end. This is what your users will see and how they interact with your product.&lt;/p&gt;

&lt;p&gt;This is often the first serverless skill that developers do, often without realising it. This is often through GitHub pages or a hosting service.&lt;/p&gt;

&lt;p&gt;Whilst these services are great for quick and simple project hosting, you will need something more robust for larger and more technical serverless web hosting.&lt;/p&gt;

&lt;h4&gt;
  
  
  What you’ll need to be able to do
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;To be able to host the files required for a front end application.&lt;/li&gt;
&lt;li&gt;To be able to serve these files on a given URL at scale&lt;/li&gt;
&lt;li&gt;Point a registered domain name at these files&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How to do this with Serverless?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Host the files on Amazon S3 (file storage system)&lt;/li&gt;
&lt;li&gt;Create a CloudFront distribution to serve the files at scale&lt;/li&gt;
&lt;li&gt;Use Route 53 to register a domain name and point it at the Cloudfront Distribution&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Why Serverless is the best way to do this
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;S3, CloudFront and Route 53 all scale so you don’t have to work out (guess) how many visitors your site will get&lt;/li&gt;
&lt;li&gt;You don’t need to set up or maintain the servers&lt;/li&gt;
&lt;li&gt;You don’t need to set up DNS, nameservers or anything else to get the site up on your URL. Route 53 handles all of this.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Create an API
&lt;/h3&gt;

&lt;p&gt;Every app needs APIs so that the front end can interact with the back end (databases, storage, email, etc.) which is where most of the power of a full-stack app comes from.&lt;/p&gt;

&lt;h4&gt;
  
  
  What you’ll need to be able to do
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;To be able to create restful API endpoints&lt;/li&gt;
&lt;li&gt;To be able to access your databases&lt;/li&gt;
&lt;li&gt;To be able to access other services (Storage, SMS, email, other APIs)&lt;/li&gt;
&lt;li&gt;Protect your endpoints with API keys&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How to do this?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Use API Gateway to build the API endpoints&lt;/li&gt;
&lt;li&gt;Create Lambda functions to execute your logic and access other services (database access, SMS, email, etc.)&lt;/li&gt;
&lt;li&gt;Create API keys that provide access to your API endpoints&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Why Serverless is the best way to do this
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Each endpoint is an isolated function, so if one breaks it doesn’t crash the others&lt;/li&gt;
&lt;li&gt;You have very easy access to the rest of the serverless services through the aws-sdk, reducing code and speeding up development&lt;/li&gt;
&lt;li&gt;You can easily create, limit and remove API keys to make sure that the right people are able to invoke your API endpoints.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Databases
&lt;/h3&gt;

&lt;p&gt;All full-stack services need a way to store data about users, products, and everything else. This might be in a relational or non-relational database but you need to store the data somewhere organised.&lt;/p&gt;

&lt;h4&gt;
  
  
  What you’ll need to be able to do
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Create a scalable non-relational or relational database&lt;/li&gt;
&lt;li&gt;Access this database&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How to do this?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Create a DynamoDB (non-relational) or Aurora (relational) database&lt;/li&gt;
&lt;li&gt;Access your tables within your API Lambdas using the built-in tools within the AWS SDK&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Why Serverless is the best way to do this
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Your tables automatically scale and have built-in redundancy, removing the need to manage and sync multiple copies of databases&lt;/li&gt;
&lt;li&gt;You can easily access the databases with the AWS SDK without having to expose it to the outside world.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deployment and Maintainance
&lt;/h3&gt;

&lt;p&gt;Once you’ve designed and built all of your systems, you need to deploy them into a production environment, maintain and upgrade them.&lt;/p&gt;

&lt;h4&gt;
  
  
  What you’ll need to be able to do
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Deploy all of the resources we’ve talked about so far&lt;/li&gt;
&lt;li&gt;Provide version-controlled configuration for all of the resources&lt;/li&gt;
&lt;li&gt;Maintain and update the software and hardware that your systems are running on&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How to do this?
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Create the resources using the Serverless framework&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Why Serverless is the best way to do this
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;When you create your serverless.yml file, you define all of the resources that you need to get your application running&lt;/li&gt;
&lt;li&gt;This serverless.yml file can be version controlled to track changes over time&lt;/li&gt;
&lt;li&gt;You can deploy your whole architecture in minutes with a single command&lt;/li&gt;
&lt;li&gt;All of the underlying software and hardware is maintained, updated and upgraded by your service provider (AWS) so you don’t need to worry about it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’ve liked this article and want to start learning how you can become a full-stack developer, I have a free 3 part video course on how to build and deploy your own serverless API.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://courses.completecoding.io/p/build-a-serverless-api/" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftsq4bo7nwrih1kgkkd6x.png" width="800" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;** London Front end developer (£42,994) vs London Fullstack Developer (48,767)&lt;/p&gt;




</description>
      <category>serverless</category>
      <category>javascript</category>
      <category>aws</category>
    </item>
    <item>
      <title>Building an API with Lambdas and API Gateway</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Wed, 18 Jul 2018 20:39:01 +0000</pubDate>
      <link>https://dev.to/samwsoftware/building-an-api-with-lambdas-and-api-gateway-3kla</link>
      <guid>https://dev.to/samwsoftware/building-an-api-with-lambdas-and-api-gateway-3kla</guid>
      <description>

&lt;h4&gt;
  
  
  Want to access your database, control your system or execute some code from another website? An API can do all of this for you and they’re surprisingly easy to set up.
&lt;/h4&gt;

&lt;p&gt;An API is a url that you can perform &lt;em&gt;GET, PUT, POST&lt;/em&gt; and &lt;em&gt;DELETE&lt;/em&gt; requests on to control another service. If you make one yourself then you can build these APIs to do whatever you want behind the scenes. Common uses are providing database control, performing actions on third party APIs (API-ception) or controlling another service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use an API
&lt;/h3&gt;

&lt;p&gt;You may ask why we need an API when we can access the database directly or run the code on the website. There are a few massive advantages to APIs over running the code in your website.&lt;/p&gt;

&lt;h4&gt;
  
  
  Hide Your Access Keys and Tokens
&lt;/h4&gt;

&lt;p&gt;This is possibly the most important reason to use an API. If your are accessing a database then you’re going to need the database details as well as user and access token/key.&lt;/p&gt;

&lt;p&gt;If you access the database from the website then you’re going to have all of these details in the source code of your site. This is really bad practice as anyone can look into the source control and steal your details. This doesn’t sound too bad but what if these are your AWS or Google Cloud Compute credentials? They could then use these to run whatever they want on your account, leaving you with a huge bill.&lt;/p&gt;

&lt;p&gt;Running these processes from behind an API means no one can see any of the private details so can’t steal them to use in their own projects. If you store your website code in Github or another public source control then it also means that they aren’t visible there either.&lt;/p&gt;

&lt;h4&gt;
  
  
  Run the Code Elsewhere
&lt;/h4&gt;

&lt;p&gt;What if you aren’t using any other services and aren’t using any secret keys? If you are running a large or complex bit of code or if you don’t want anyone else reading your code and working out how it works then you can still use an API.&lt;/p&gt;

&lt;h4&gt;
  
  
  Control Who Has Access
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yT37n_6q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AmXW73ujWRmuYUACsNpzKqw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yT37n_6q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AmXW73ujWRmuYUACsNpzKqw.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Providing an API also allows you to restrict who is able to access the database or run the code. You can do this by requiring an API key. This key is used to identify the user making the request and then allowing or rejecting the request.&lt;/p&gt;

&lt;p&gt;This can be used to allow only a few people to access the service, or even to create a tier system. This is how a lot of paid APIs work, giving everyone free but limited access and then allowing you to pay for access to superior parts of the service or just higher rate of requests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building the API
&lt;/h3&gt;

&lt;p&gt;Now that we know some reasons why we might want to create an API, lets do just that. We’re going to use API Gateway and AWS Lambdas because its simpler than running a server. Make sure you have an AWS account and are logged in.&lt;/p&gt;

&lt;h4&gt;
  
  
  Setting up API Gateway
&lt;/h4&gt;

&lt;p&gt;We can start by opening the API Gateway service and clicking &lt;em&gt;Get Started*.&lt;/em&gt; On the next page we need to make sure that we’ve selected the &lt;em&gt;New API&lt;/em&gt; option and then give our API a name.&lt;/p&gt;

&lt;p&gt;When creating our first API we should select &lt;em&gt;*New API*&lt;/em&gt; and then we can give this API a name and description and click &lt;em&gt;*Create API*&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EO6OOYLH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ACjKTmP5zCWhqr_XIznAuZw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EO6OOYLH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ACjKTmP5zCWhqr_XIznAuZw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Clicking &lt;em&gt;Create API&lt;/em&gt; will get us into the configuration page for your API. The first thing we need to do is to add a resource onto the API. Using resources allows us to group similar API calls together using nested slashes. We are going to create an API that we can use to recommendations on what to watch. Therefore we can have /&lt;em&gt;tv-shows&lt;/em&gt; and &lt;em&gt;/movies&lt;/em&gt; as two base methods.&lt;/p&gt;

&lt;p&gt;Click the &lt;em&gt;Actions&lt;/em&gt; dropdown and select &lt;em&gt;Create Resource.&lt;/em&gt; Name your resources, making sure that they are both in the “/” path.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QIyRmTEY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/900/1%2Agj847pJH6XRgL4K-Iy2c9Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QIyRmTEY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/900/1%2Agj847pJH6XRgL4K-Iy2c9Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ushqegwR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A3u-krWS1HQx25aDYtyS6iA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ushqegwR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A3u-krWS1HQx25aDYtyS6iA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We want users to be able to go to &lt;em&gt;/movies/horror&lt;/em&gt; or &lt;em&gt;/tv-shows/comedy&lt;/em&gt; and we can do this by adding path parameters. These are variables that we can access inside the API. To create one of theses we need to set the resource to &lt;em&gt;{resourceName}&lt;/em&gt; as shown below. This can be done for &lt;em&gt;tv-shows&lt;/em&gt; and &lt;em&gt;movies.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b92nCtFn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AHVNkD3aWgl5FPHw8E1U-9Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b92nCtFn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AHVNkD3aWgl5FPHw8E1U-9Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we can length and genre we can create methods for getting and adding data to a table. Select one of the &lt;em&gt;{genre}&lt;/em&gt; resources and click &lt;em&gt;Actions&lt;/em&gt; then &lt;em&gt;Create Method.&lt;/em&gt; This will create a small grey box below the resource which we can click. We are going to start with a &lt;em&gt;GET&lt;/em&gt; request so select that and click the tick button.&lt;/p&gt;

&lt;p&gt;This is where we get to decide how to handle the request. We are going to use AWS Lambdas but we need to create them before we can finish setting up the methods.&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating the Lambdas
&lt;/h4&gt;

&lt;p&gt;We are able to respond to these API requests using Lambdas which is great as they only run when we need them to. They are also really easy to create so that’s what we’ll do now.&lt;/p&gt;

&lt;p&gt;In the Lambda console click &lt;em&gt;Create function&lt;/em&gt; and then we can name our first API function &lt;em&gt;movieAPI,&lt;/em&gt; set it to run Node 8.10 and &lt;em&gt;Create new role from template(s).&lt;/em&gt; Name our new role &lt;em&gt;tableAPI&lt;/em&gt; and add &lt;em&gt;Simple Microservice permissions&lt;/em&gt; as the only template.&lt;/p&gt;

&lt;p&gt;All code can be found at &lt;a href="https://github.com/SamWSoftware/Projects/tree/master/movieAPI"&gt;https://github.com/SamWSoftware/Projects/tree/master/movieAPI&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;em&gt;Create function&lt;/em&gt; and we are sent into the Lambda window. Scroll down to the &lt;em&gt;Function code&lt;/em&gt; section and we’ll change the code. The first thing we’re going to do is to check what request method was used.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.handler = async (event) =&amp;gt; {
    console.log(event);
    if (event.httpMethod === 'PUT'){
        let response = putMovie(event)
        return done(response);
    } else if (event.httpMethod === 'GET'){
        let response = getMovie(event);
        return done(response);
    }
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We’re going to start by writing the &lt;em&gt;getMovie&lt;/em&gt; function. This function will start by getting the &lt;em&gt;genre&lt;/em&gt; from the path parameters. This is where using path parameters can make this process easy.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getMovie = event =&amp;gt; {
    let genre = event.pathParameters.genre;
    return;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With the genre that the user requested we are going to get a recommended movie for them. I copied these from &lt;a href="https://www.imdb.com/list/ls000441429/"&gt;25 Top Films From Each Genre&lt;/a&gt; and added them to an object with the genre as the key. We can then get the film by getting the value of the genre requested.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const movies = {
    action: 'Desperado (1995)',
    fantasy: 'Inception (2010)',
    ...
    horror: 'Black Swan (2010)'
}

const getMovie = event =&amp;gt; {
    let genre = event.pathParameters.genre;
    return movies[genre];
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This means that the title of the movie is being passed into the &lt;em&gt;done&lt;/em&gt; function. This function is used as API Gateway expects the data to come back in a very specific format. This function turns a string into that required format.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const done = response =&amp;gt; {
    return {
        statusCode: '200',
        body: JSON.stringify(response),
        headers: {
            'Content-Type': 'application/json',
            'Access-Control-Allow-Methods': '\*',
            'Access-Control-Allow-Origin': '\*'
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We can do a very similar thing for a &lt;em&gt;tv-showsAPI&lt;/em&gt; function, reusing most of the code, just changing the function names and the movie suggestions to tv show.&lt;/p&gt;

&lt;h4&gt;
  
  
  Connecting the Lambdas to API Gateway
&lt;/h4&gt;

&lt;p&gt;Back in API Gateway we can add our new Lambdas to the methods we created earlier. We need to make sure that &lt;em&gt;Use Lambda Proxy integration&lt;/em&gt; is selected and we are pointing at the correct Lambda. Clicking &lt;em&gt;Save&lt;/em&gt; will ask you for permissions to access this Lambda which we can give the &lt;em&gt;OK.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ljpy2w4I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ap_tMRh17u0KxXOMyA6OFvQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ljpy2w4I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ap_tMRh17u0KxXOMyA6OFvQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do this for the &lt;em&gt;GET&lt;/em&gt; methods on both resources and we can start to test. Selecting the methods should now show a method execution diagram. This sounds complicated but the only bit we need is the _TEST _section.&lt;/p&gt;

&lt;p&gt;Clicking TEST will open a new section where we can try out the API. There are lots of things you can set here but the only one we care about is the &lt;em&gt;Path {genre}.&lt;/em&gt; We need to set this to the genre we’re requesting. Entering &lt;em&gt;western&lt;/em&gt; as the genre and hitting the &lt;em&gt;Test&lt;/em&gt; button gets a response like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R-ZvGKlo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AbHaxGw8vv1XmQUK2TJBkAQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R-ZvGKlo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AbHaxGw8vv1XmQUK2TJBkAQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We got our API working! Now we need to make sure that other people can access it. There are two steps to this.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We enable CORS — Select the &lt;em&gt;{genre}&lt;/em&gt; resource and then click &lt;em&gt;Actions&lt;/em&gt; and &lt;em&gt;Enable CORS.&lt;/em&gt; Leave everything as defaults and when asked click &lt;em&gt;Yes, replace existing values.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Deploy our API — Click on &lt;em&gt;Actions&lt;/em&gt; and &lt;em&gt;Deploy API&lt;/em&gt;. Set the deployment stage to &lt;em&gt;[New Stage]&lt;/em&gt; and then give your stage a name like &lt;em&gt;production&lt;/em&gt; or_ public._&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once your API has deployed you should get a URL like this. This is the base of your API. You can add /movies/western to access your API.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://{uniqueCode}.execute-api.eu-west-1.amazonaws.com/production
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That’s all for this article but in the next one we’ll connect this API to Dynamo tables and let users vote on their favourite movies in each genre.&lt;/p&gt;

&lt;p&gt;If you’ve liked this article, make sure to hit that like button and follow me for the next API article.&lt;/p&gt;





</description>
      <category>apiintegration</category>
      <category>movies</category>
      <category>awslambda</category>
      <category>apigateway</category>
    </item>
    <item>
      <title>Become a Developer and Get Your First Job Fast</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Fri, 13 Jul 2018 18:48:56 +0000</pubDate>
      <link>https://dev.to/samwsoftware/become-a-developer-and-get-your-first-job-fast-pm4</link>
      <guid>https://dev.to/samwsoftware/become-a-developer-and-get-your-first-job-fast-pm4</guid>
      <description>&lt;h4&gt;
  
  
  Ever thought about becoming a software developer or looking for a change of career? This article will give you a solid plan to get you started in software development and get your first job!
&lt;/h4&gt;

&lt;h3&gt;
  
  
  But why be a developer?
&lt;/h3&gt;

&lt;p&gt;If your considering becoming a developer and but aren’t sure whether it’s a good idea, here are a few things to think about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;There is a huge demand for developers — at the time of writing, Indeed had 37,739 job adverts for ‘developer’ in the UK and 145,640 in the US. Those numbers are only going to increase as the U.S. Bureau of Labor Statistics estimates a 17% rise between 2014 and 2024.&lt;/li&gt;
&lt;li&gt;The work can be very varied and interesting — as a developer you can work on a huge range of projects from e-commerce websites to computer games, from mobile apps to artificial intelligence. Almost all of the skills are transferable between each of these areas and this means you aren’t locked into a single job.&lt;/li&gt;
&lt;li&gt;The work can be flexible — As most of your work is reading and writing code, all you need is a computer. This means it can be done from anywhere, at any time. There is an increasing number of remote developers who work from home or whilst travelling the world.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How to become a Developer
&lt;/h3&gt;

&lt;p&gt;Being a developer is a skill and there are two major factors in developing a skill: effective practice and support from senior developers. You need to maximise both of these to help you become the best developer you can. There are are three good ways to make sure that you’re on a fast track to starting your developer career:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Coding Bootcamps — These are great because they are designed to take you from little or no coding experience to job ready in 3 months. This means lots of effective practice and tones of help from the developers running the bootcamp.
The issues you might have with bootcamps are that they are usually 3 months of full time study and they can cost from £3000 ($4000) to £15,000 ($20,000). That’s a lot of money to spend especially since you’re not earning for those 3 months.&lt;/li&gt;
&lt;li&gt;Get a Mentor — This is the perfect situation, you start coding and have a developer act as your mentor and tutor. They could be a friend, family member or just a developer that wants to help you out. You won’t get as much help as with a bootcamp but having someone to turn to when you hit a roadblock is really useful. Also having someone checking in on you and making sure that you’re putting the time in can help keep you on track.
This sounds great but getting a mentor can be hard. Not everyone knows someone who works as a developer and it’s a lot of extra work for the mentor. If you know a developer, they may say no to being your mentor and you need to respect that.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AbyGmIJHlY6R00U3e8rX3Fg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AbyGmIJHlY6R00U3e8rX3Fg.jpeg"&gt;&lt;/a&gt;Having a mentor can be brilliant&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get a Job as a Developer — This may seem like a cheat as you need to be able to code before you can get a job but I’ll explain later how to get to this point without a mentor or bootcamp. When you do get your first job you’ll suddenly have a huge advantage — you’ll be getting paid to practice coding whilst working with senior developers. What more could you want?
Working as a developer will also expose you to the side of development that you’ll not see whilst you study — the business side. This is a massive part of development as there’s no point in making a product that no-one wants and dealing with customers is a skill that takes time to learn.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Starting a Plan
&lt;/h3&gt;

&lt;p&gt;As not everyone can afford to go to a bootcamp or knows someone who’ll mentor them, I’ll give you a plan for how to get your first developer job. This is almost exactly how &lt;a href="https://medium.freecodecamp.org/https-medium-com-samwcoding-how-to-get-your-first-developer-job-in-4-months-ec86da6e5d9a" rel="noopener noreferrer"&gt;I went from an engineer to a developer in just 4 months&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Finding Your Job
&lt;/h4&gt;

&lt;p&gt;To create a great plan you need to have a target that you are going to hit. Our target is to get a developer job as quickly as possible. The sooner you get your first job, the sooner you get the boost of practising code every day, having the support of senior developers and the bonus of getting paid.&lt;/p&gt;

&lt;p&gt;There are a lot of ways to get into development, from data science to AI to game development but the sector that is the easiest to get into is web development. If you’ve got your heart set on something else remember that starting in web development doesn’t mean you’re locked into it. You’ll learn a huge amount that you’ll be able to use to transfer across into your preferred field.&lt;/p&gt;

&lt;p&gt;When I searched for &lt;strong&gt;Junior Web Developer&lt;/strong&gt; the first job listing I saw was for a &lt;strong&gt;Junior Front End Web Developer&lt;/strong&gt;. The requirements are:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AvWoyfKE_8lkNXVcMlJAq9Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AvWoyfKE_8lkNXVcMlJAq9Q.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can look through a few similar job adverts and find the requirements that appear often. These will likely be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Front end knowledge: HTML, CSS and JavaScript&lt;/li&gt;
&lt;li&gt;Ability to create responsive websites&lt;/li&gt;
&lt;li&gt;A portfolio demonstrating your experience and skills&lt;/li&gt;
&lt;li&gt;Understanding of version control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other &lt;em&gt;bonus&lt;/em&gt; skills might be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Javascript libraries: jQuery, AJAX, Bootstrap&lt;/li&gt;
&lt;li&gt;Debugging knowledge&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Creating the Plan
&lt;/h3&gt;

&lt;p&gt;Now that we know what we need to learn to meet the requirements we can create a plan for how to learn what we need to meet the requirements. You should try to follow this plan step by step as its going to be easier to learn the later sections if you know the earlier ones.&lt;/p&gt;

&lt;h4&gt;
  
  
  HTML and CSS
&lt;/h4&gt;

&lt;p&gt;These are the building blocks of most websites today. You need to develop a strong understanding of these if you want a chance at getting a job. Luckily there are hundreds of free and paid resources out there which can help you learn and master these skills.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.freecodecamp.org/" rel="noopener noreferrer"&gt;Free Code Camp&lt;/a&gt; is a website that teaches you everything to do with website development and it’s incredible. It takes you step by step through mini-lessons and its where I learnt HTML, CSS and JavaScript!&lt;/p&gt;

&lt;p&gt;We’ll be starting with the &lt;a href="https://learn.freecodecamp.org/" rel="noopener noreferrer"&gt;Responsive Web Design Certification&lt;/a&gt; and the &lt;em&gt;Basic HTML and HTML5&lt;/em&gt; and &lt;em&gt;Basic CSS&lt;/em&gt; sections. These sections introduce you to HTML and CSS and by the end, you’ll be creating forms and styling HTML with cascading variables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F810%2F1%2AhXmg4Z2-YgV8PaSlr079CA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F810%2F1%2AhXmg4Z2-YgV8PaSlr079CA.png"&gt;&lt;/a&gt;An image that you’ll create in &lt;em&gt;Basic CSS: Cascading CSS variables&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To improve our CSS we’ll complete the &lt;em&gt;Applied Visual Design&lt;/em&gt; section up to &lt;em&gt;Create a More Complex Shape Using CSS and HTML&lt;/em&gt;, and then do all of &lt;em&gt;Responsive Web Design&lt;/em&gt; and &lt;em&gt;CSS Flexbox.&lt;/em&gt; We’re skipping some of the challenges and sections for now as our aim is to learn what we need and those other sections are great but not needed for now.&lt;/p&gt;

&lt;p&gt;Now that we’ve learnt to use HTML and CSS to build and style a web page, we’re going to get some effective practice by completing the &lt;em&gt;Responsive Web Design Projects.&lt;/em&gt; These projects will use everything that you’ve learnt so far to build 5 websites.&lt;/p&gt;

&lt;h4&gt;
  
  
  Version Control
&lt;/h4&gt;

&lt;p&gt;Version control is a system where you save files and you can look back over time and see what you changed at what point. It’ll probably be used as every software company you ever work at and knowing the basics is really important.&lt;/p&gt;

&lt;p&gt;To learn how to install Git, create a GitHub account and work with Git there is a great tutorial post &lt;a href="https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners" rel="noopener noreferrer"&gt;&lt;em&gt;An Intro to Git and GitHub&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt; You could learn this before the HTML and CSS design projects and start using version control for these projects.&lt;/p&gt;

&lt;p&gt;Now that you know how to use version control, try to do all of your projects in a local editor (like &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;VS Code&lt;/a&gt;) and upload it to codepen when you’re finished. Working in a local editor is how you’ll be doing it at a job so it helps build your experience.&lt;/p&gt;

&lt;p&gt;There are a lot of ways to use Git but you want to be able to create a GitHub repository, link that to a local folder, commit work that you’ve done and push that up to GitHub. Once you can do this you’ll be able to work effectively as part of a development team.&lt;/p&gt;

&lt;h4&gt;
  
  
  JavaScript
&lt;/h4&gt;

&lt;p&gt;JavaScript is the language that powers &lt;strong&gt;94.8%&lt;/strong&gt; of websites on the internet. That's a lot of sites! JavaScript allows you to covert a static website into a fully interactive one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AXZj7qjKxz7l8xGEf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2AXZj7qjKxz7l8xGEf.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To learn JavaScript we can do the &lt;em&gt;Javascript Algorithms And Data Structures Certification&lt;/em&gt; on &lt;a href="https://learn.freecodecamp.org/" rel="noopener noreferrer"&gt;&lt;em&gt;FreeCodeCamp&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt; Because JavaScript is such a big part of modern websites, we’re going to complete the whole of this certification. This may seem like a lot of work but when you work as a web developer you’ll probably spend most of your time writing JavaScript so it's important to be good at it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Building Your Portfolio
&lt;/h4&gt;

&lt;p&gt;To show off what you can do you need to have a portfolio to show to possible employers. Luckily you will already have 10 projects — 5 HTML and CSS and 5 JavaScript. Make sure that you’ve got these all in version control and uploaded to GitHub so that other people (future employers) can have a look and see how well you work.&lt;/p&gt;

&lt;p&gt;You can now go back to the portfolio site that you built and update it with all of your new projects. You can then use your new JavaScript skills to add interaction to the page. This could be a popup description when a user hovers over one of your projects, a slideshow of images or even a mini-game.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Job Search
&lt;/h3&gt;

&lt;p&gt;If you’ve done everything in the plan so far then you should meet the requirements of a lot of the junior web developer jobs. Now it’s time to apply for some jobs.&lt;/p&gt;

&lt;p&gt;To apply for most jobs you need a cv so we can make a web developer cv. This should highlight your strengths without bringing added attention to how long you’ve been coding or the fact that you haven’t got any commercial experience.&lt;/p&gt;

&lt;p&gt;Here’s the CV that I used to get my second job.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F794%2F1%2AygWRFpOBDGIKdC_SA_xGAw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F794%2F1%2AygWRFpOBDGIKdC_SA_xGAw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which jobs to apply for is also important. This may seem wrong but you should apply to jobs where you can meet 80% of the requirements. You can always point out that as a self-taught developer you will likely pick up the other requirements faster than most other people.&lt;/p&gt;

&lt;p&gt;Of course, this doesn’t mean you sound apply to &lt;em&gt;every&lt;/em&gt; job where you meet the requirements. Only apply to jobs where you think the job is interesting and you would take if you got the offer.&lt;/p&gt;

&lt;h4&gt;
  
  
  Using Recruiters
&lt;/h4&gt;

&lt;p&gt;Recruiters can be a powerful tool for getting your first job. They know what the company wants, often have jobs that aren’t on job boards and they want you to get the job… that’s how they get paid.&lt;/p&gt;

&lt;p&gt;To make sure that your cv gets into the hands of as many recruiters as possible we need to apply to jobs on a range of sites. Start with the large sites like indeed and total jobs but also try to find the smaller job sites too.&lt;/p&gt;

&lt;p&gt;A lot of developers talk about how awful recruiters are but we need to make sure to utilise them. Whenever you speak to a recruiter make sure to be respectful and polite. If they ask you about jobs that are way above or below your desired job, thank them and decline but remind them of the type of job you are looking for.&lt;/p&gt;

&lt;p&gt;My first two jobs came from recruiters asking about a job that wasn’t suited to me, but they had another job that was perfect. Don’t give them such a hard time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Continued Improvement
&lt;/h3&gt;

&lt;p&gt;You probably won’t get an interview and job offer in the first week of applying for jobs. You might not get an interview in the first month but this gives us time to improve.&lt;/p&gt;

&lt;p&gt;Now that we’ve met the basic requirements we can start adding more &lt;em&gt;nice to haves&lt;/em&gt; into our toolkit. Now is the time to add a new tool to your tool chest. Adding more skills to your belt will make employers more likely to want you and increase your chances to get an interview. Here are some skills to learn:&lt;/p&gt;

&lt;h4&gt;
  
  
  Learn a library
&lt;/h4&gt;

&lt;p&gt;There are JavaScript libraries out there which can make your life much easier. The most famous library is jQuery which helps you with DOM manipulation, object and array functions and much more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F0%2A80BbrrMMtWYYPobP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F600%2F0%2A80BbrrMMtWYYPobP.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I would recommend learning to use jQuery because it’s a great introduction to using libraries in JavaScript. There are loads of courses and tutorials for learning jQuery but I still love the FreeCodeCamp lesson.&lt;/p&gt;

&lt;h4&gt;
  
  
  Completing the HTML and CSS Lessons
&lt;/h4&gt;

&lt;p&gt;Go back to the HTML and CSS lessons from FreeCodeCamp and complete the rest of the lessons in &lt;em&gt;Applied Visual Design&lt;/em&gt;, &lt;em&gt;Applied Accessibility&lt;/em&gt; and &lt;em&gt;CSS Grid&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Advance Your CSS (optional)
&lt;/h4&gt;

&lt;p&gt;If you like the design and style side of front end development then there’s a cool &lt;a href="http://dailycssimages.com/" rel="noopener noreferrer"&gt;Daily CSS course&lt;/a&gt; that gets you to make images with just CSS and HTML. These images could be a great thing to talk about in an interview.&lt;/p&gt;

&lt;h4&gt;
  
  
  Learn how JavaScript Works
&lt;/h4&gt;

&lt;p&gt;Being able to use JavaScript is great but understanding how it works can help you become a much better developer. It allows you to write the best possible code as you know why and how that code fixes the problem.&lt;/p&gt;

&lt;p&gt;To get this deeper understanding of JavaScript I highly recommend the &lt;a href="https://github.com/getify/You-Dont-Know-JS" rel="noopener noreferrer"&gt;You Don’t Know JS&lt;/a&gt; book series. The first two books are great for understanding the fundamentals of JavaScript. Understanding this gives you a great foundation on which you can become an even better developer. They can be accessed for &lt;a href="https://github.com/getify/You-Dont-Know-JS" rel="noopener noreferrer"&gt;FREE online&lt;/a&gt; or bought in &lt;a href="https://www.amazon.co.uk/s/ref=dp_byline_sr_book_1?ie=UTF8&amp;amp;text=Kyle+Simpson&amp;amp;search-alias=books-uk&amp;amp;field-author=Kyle+Simpson&amp;amp;sort=relevancerank" rel="noopener noreferrer"&gt;hard copy&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Build Projects
&lt;/h4&gt;

&lt;p&gt;Another way to improve your skills is to build projects. These can be anything but your aim is to get practice using the tools that you are less experienced with. Not great with arrays, create a shopping list app. A bit iffy on styling, try to make an exact copy of a real website.&lt;/p&gt;

&lt;p&gt;These projects should be improving your skills so if it's too easy or too difficult, stop and start a project that is at a better level.&lt;/p&gt;

&lt;p&gt;Sometimes when you build a project you might need to learn a completely new skill and learning as you go can be a great way for some people to learn.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interviews
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2APApMjuBjzI_cTNQ1JYknqw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2APApMjuBjzI_cTNQ1JYknqw.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After having applied for a bunch of jobs and continued to improve your skills you will hopefully be asked in an interview. This is your time to shine. There are loads of articles about how to approach the interview process so I won’t go into too much detail but will highlight what &lt;a href="https://medium.com/@samwsoftware/how-to-secure-the-job-of-your-dreams-by-smashing-your-interview-61f38b7cdd0e" rel="noopener noreferrer"&gt;this article says&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Know your CV&lt;/li&gt;
&lt;li&gt;Know about the company&lt;/li&gt;
&lt;li&gt;Practice your skills&lt;/li&gt;
&lt;li&gt;Be early, polite and confident&lt;/li&gt;
&lt;li&gt;Ask Questions&lt;/li&gt;
&lt;li&gt;Follow up after the interview&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you follow all of this advice then you’ll have a good chance of getting an offer. Amazing! If you don’t get an offer then make sure to ask for feedback and use that to be better in your next interview.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;If you want to become a developer you should be aiming to get a junior web developer job ASAP so that you get the experience and support from senior developers. To get this kind of job you need to: learn HTML, CSS and JavaScript and build a portfolio of small projects. Once you’ve done this you can start applying to jobs.&lt;/p&gt;

&lt;p&gt;Prepare well for your interviews and continue to build new skill whilst you wait for that offer.&lt;/p&gt;

&lt;p&gt;Thanks for following my guide to becoming a developer and getting your first job. If you enjoyed it then give it a like and follow me for more developer tips and tricks!&lt;/p&gt;




</description>
      <category>softwaredevelopment</category>
      <category>jobs</category>
      <category>webdev</category>
      <category>careers</category>
    </item>
    <item>
      <title>Amazon Lex — Hacking a Postcode Slot Type</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Sun, 03 Jun 2018 08:07:26 +0000</pubDate>
      <link>https://dev.to/samwsoftware/amazon-lex--hacking-a-postcode-slot-type-13gh</link>
      <guid>https://dev.to/samwsoftware/amazon-lex--hacking-a-postcode-slot-type-13gh</guid>
      <description>

&lt;p&gt;When you create an Amazon Lex chatbot you use slots to gather bits of information from the user. To ensure that the slots are capturing the right types of information, you have to give a &lt;em&gt;Slot type&lt;/em&gt; to each of the slots.&lt;/p&gt;

&lt;p&gt;Amazon provides a list of pre-made slot types that cover a lot of things such as numbers, names, cities and lots of other categories. This is great and I’ve found that about half of my slots can be set to an Amazon slot type.&lt;/p&gt;

&lt;p&gt;If the slot type you need isn’t a default Amazon type then they let you build your own slot type. This is great as it &lt;em&gt;theoretically&lt;/em&gt; allows for infinitely unique slot types that will match your user’s inputs perfectly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a custom slot type
&lt;/h3&gt;

&lt;p&gt;There are 2 types of custom slot type you can create: &lt;em&gt;Expanded Values&lt;/em&gt; and &lt;em&gt;Slot values and Synonyms&lt;/em&gt;. Expanded values is where you provide some sample values and Amazon these as training data to learn to identify if the value is the correct slot type. Slot values and synonyms allows you to hard code slot values and then provide a list of synonyms that a use might say.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dealing with UK Postcodes
&lt;/h3&gt;

&lt;p&gt;Recently we created a bot that needed to ask for a user’s postcode. Amazon doesn’t have a &lt;em&gt;Postcode&lt;/em&gt; slot type so we needed to create a custom one. For this we would have to use &lt;em&gt;Expanded values&lt;/em&gt; as we couldn’t just list every UK postcode.&lt;/p&gt;

&lt;h4&gt;
  
  
  First Try
&lt;/h4&gt;

&lt;p&gt;The first attempt at a postcode type involved populating the list of example values with about 8 postcodes. I would have expected Lex to have learnt from those example postcodes but this results in some strange things happening. Sometimes it rejects about 1/3 of genuine postcodes, other times it lets almost anything through.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pn9d8Rz7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/786/1%2Au88kERHMowHi8owdVFwTPg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pn9d8Rz7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/786/1%2Au88kERHMowHi8owdVFwTPg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BoQyBB6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/768/1%2A2AV1J6U4qptif4nmegZfLA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BoQyBB6h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/768/1%2A2AV1J6U4qptif4nmegZfLA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZjBsYCcD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/764/1%2ABzDwL17xaOkKdO6H-7w5rA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZjBsYCcD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/764/1%2ABzDwL17xaOkKdO6H-7w5rA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The whole point in slot types is to make sure that if the user types a valid value it will go though and incorrect values will be blocked. This method wasn’t good enough.&lt;/p&gt;

&lt;h4&gt;
  
  
  Try 2
&lt;/h4&gt;

&lt;p&gt;When creating the &lt;em&gt;Expanded values&lt;/em&gt; slot type it lets you know that it uses the example values as training data. To improve the accuracy of the validator we should try adding more training data. This way it has more values to train and test against.&lt;/p&gt;

&lt;p&gt;I downloaded a list of 999 real uk postcodes and wrote a script to build the slot type json file. I uploaded this to Lex and tested it out.&lt;/p&gt;

&lt;p&gt;The fact that with 999 new postcodes it only took a few seconds to build implies that it isn’t running a machine learning training cycle. It must be using another method of matching the values.&lt;/p&gt;

&lt;p&gt;When testing this out, it had some of the same problems as the first version. Whilst it did accept more real postcodes and reject the more insane values, it did still reject some real postcodes and accept some random values.&lt;/p&gt;

&lt;h4&gt;
  
  
  Try 3 — the hacking begins
&lt;/h4&gt;

&lt;p&gt;So having tried to get it working properly using Amazon’s methods we resorted to working around the system. We knew that there are some great rejex functions for postcode validation so we decided to give this a go.&lt;/p&gt;

&lt;p&gt;We needed to design a new slot type that allowed everything through so we could pass it through to our own validation Lambda to perform the rejex. We copied our first slot type and then started adding random values that were between 3 and 8 characters long and included numbers, upper and lowe case letters, and spaces.&lt;/p&gt;

&lt;p&gt;We added a initialisation and validation Lambda that took the value of the postcode slot and ran it through the rejex. If it succeeded then we let Lex carry on, else we re-elicited the postcode slot.&lt;/p&gt;

&lt;p&gt;This worked much better than either of the previous methods, filtering out all of the nonsense values but still sometimes blocking valid postcodes before they even got through to the rejex validation.&lt;/p&gt;

&lt;h4&gt;
  
  
  4th times the charm???
&lt;/h4&gt;

&lt;p&gt;I moved onto another part of the project whilst one of my colleagues started researching how other people dealt with similar issues. We couldn’t be the only ones hitting this problem.&lt;/p&gt;

&lt;p&gt;Luckily we weren’t. Although a lot of the questions were about US postcode, there were some useful bits of information. The most important one was to try out the &lt;em&gt;Music&lt;/em&gt; and &lt;em&gt;Musician&lt;/em&gt; slot types. People suggested that they let any value through.&lt;/p&gt;

&lt;p&gt;With this nugget of knowledge we created a new test for music and musician to see if the rumours were true.&lt;/p&gt;

&lt;p&gt;Music was pretty good, letting through all postcodes with XXX XXX format but blocking all XXXX XXX postcodes. Musician is where we struck gold. This slot type appears to let absolutely anything through. When I say anything I mean anything, whether it was &lt;em&gt;cat, dog&lt;/em&gt; or the lyrics to fresh prince.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GdU4kgsW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/424/1%2ApzgwvBUUsWh5iMet5uv4yg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GdU4kgsW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/424/1%2ApzgwvBUUsWh5iMet5uv4yg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D-P1aPIM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/420/1%2Am3q8ZdQk2Q8KeJyeNBd1Ew.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D-P1aPIM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/420/1%2Am3q8ZdQk2Q8KeJyeNBd1Ew.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This slot type has allowed our rejex to deal with whatever values users give it. You can use a validation Lambda to catch it when they say it or just run some validation checks at the start of your fulfilment Lambda.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Using a few values to create a slot type wasn’t very good&lt;/li&gt;
&lt;li&gt;Using hundreds was better but not great&lt;/li&gt;
&lt;li&gt;Creating a slot type to capture anything was ok&lt;/li&gt;
&lt;li&gt;Using the &lt;em&gt;Musician&lt;/em&gt; slot type lets anything through&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using this knowledge we can now create rejex slots validation, or any type of validation you want.&lt;/p&gt;

&lt;p&gt;If you think you’ll use this in one of your chatbots or simply enjoyed seeing people hacking their way around Amazon then give this a like and follow me for more chatbot tips and tricks.&lt;/p&gt;





</description>
      <category>programming</category>
      <category>amazonlex</category>
      <category>aws</category>
    </item>
    <item>
      <title>AWS Lambda — The Top 3 Ways to Work</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Sun, 15 Apr 2018 09:04:40 +0000</pubDate>
      <link>https://dev.to/samwsoftware/aws-lambda--the-top-3-ways-to-work-gh0</link>
      <guid>https://dev.to/samwsoftware/aws-lambda--the-top-3-ways-to-work-gh0</guid>
      <description>&lt;p&gt;AWS Lambdas are incredible! They’re functions that are hosted on Amazon Web Services that can be triggered in a load of ways.&lt;/p&gt;

&lt;p&gt;One of the bests part is that you only pay for the time the lambda is running. Got something that only runs once an hour and only takes 2 seconds? You’ll only be charged for 48 seconds a day! That’s insane compared to running a 24/7 ec2 or your own private server.&lt;/p&gt;

&lt;p&gt;Today we’ll create a lambda and then look at the three best ways to work with the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Lambda
&lt;/h3&gt;

&lt;p&gt;Once you’ve got your AWS account set up there are a few ways to create a new lambda. For the first Lambda we’re going to be using the AWS Console.&lt;/p&gt;

&lt;h4&gt;
  
  
  AWS Console
&lt;/h4&gt;

&lt;p&gt;The easiest way to create your first lambda is to create it in the AWS Console. You can find &lt;em&gt;Lambda&lt;/em&gt; under &lt;em&gt;Services&lt;/em&gt; which takes you to the Lambda console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A23UBDu9eiNn9CasvX9dUqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A23UBDu9eiNn9CasvX9dUqg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is what you’ll see if this is your first Lambda. Click that &lt;em&gt;Create a function&lt;/em&gt; button to start setting up your first function.&lt;/p&gt;

&lt;p&gt;You’ll end up on the setup page where you configure some of the function. You can create a Lambda from Blueprints or Serverless Application Repos but for this we’ll Author from scratch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AjmKCKMsIPuMLhgsMxNMBog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AjmKCKMsIPuMLhgsMxNMBog.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the name for your function (this must be unique to your user or sub-account), choose your Runtime (We’ll use Node.js 8.10), and select a role.&lt;/p&gt;

&lt;p&gt;You’ll have to create a new role if you don’t already have one. Create one from template and you can leave &lt;em&gt;Policy templates&lt;/em&gt; blank.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing Your Lambda Code
&lt;/h3&gt;

&lt;p&gt;One of the big advantages with Lambdas is that you can choose how you write and edit them. There are three main ways to do so: in Lambda Console, in Cloud9, and on your local machine. I’m going to cover all three and discuss advantages and disadvantages to them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lambda Console
&lt;/h3&gt;

&lt;p&gt;This is the screen you got sent to when you created the function. You’ll see that there is a lot of stuff going on. The bit that we care about fro now is the &lt;em&gt;Function code&lt;/em&gt; section, about half way down&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AVxeSaa8uQgP92Wl4zCPMUg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AVxeSaa8uQgP92Wl4zCPMUg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In here we have a basic editor. I believe it’s based on the Cloud 9 IDE and works pretty damn well for simple Lambdas. You can see below that the handler is an async function because I chose to use Node 8.10. If you prefer callbacks then Node 6.10 is the runtime for you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F693%2F1%2AUkr1dY8xL4mT2IIEw0DVZg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F693%2F1%2AUkr1dY8xL4mT2IIEw0DVZg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The advantages&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It’s a decent editor.&lt;/li&gt;
&lt;li&gt;You can access it from any computer through your AWS console.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Disadvantages&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It doesn’t seem to be 100% stable. Sometimes it doesn’t let you save so you have to copy all of your work to local file, reload the page and copy your work back. I hope that this gets fixed soon!&lt;/li&gt;
&lt;li&gt;It doesn’t have a terminal. This means that you can install packages using NPM using this method alone.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cloud 9 Editor
&lt;/h3&gt;

&lt;p&gt;Amazon recently bought out Cloud 9, an online development platform. It seems to run a very basic version of Ubuntu that is integrated with the rest of the AWS platform.&lt;/p&gt;

&lt;p&gt;Search for &lt;em&gt;Cloud 9&lt;/em&gt; in the console, go to the page and select &lt;em&gt;Create environment.&lt;/em&gt; From here you give your environment a name and go to the next step.&lt;/p&gt;

&lt;p&gt;Here you get to choose what you want to run this environment on. The great thing is that t2.micro is Free-tier eligible so you can use this method without getting charged anything if you’re on the free tier. I’ve never needed anything more powerful than a t2.micro.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F919%2F1%2AmIMSy6hKCQuer20ZOTjVSQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F919%2F1%2AmIMSy6hKCQuer20ZOTjVSQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Continue on from here and you’ll end up in your new cloud 9 environment!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AuaTpBEey0EHYd-_aWa165g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AuaTpBEey0EHYd-_aWa165g.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The cool thing about this is that you have access to all of your Lambdas from inside your environment. Click &lt;em&gt;AWS Resources&lt;/em&gt; then under &lt;em&gt;Remote Functions&lt;/em&gt; you’ll find all of your functions. Click on the Lambda you want to edit and then hit the download button above to import it into your environment.&lt;/p&gt;

&lt;p&gt;Once that’s done, it’ll be just like you’re working on it locally.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F733%2F1%2AP2Y6g3Juw5T7lltbooxhbg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F733%2F1%2AP2Y6g3Juw5T7lltbooxhbg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you’re finished, just select the function you’ve been working on from the local list and hit the upload button. Within a few seconds it’ll be live with all your changes.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Advantages&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Again, this is all remote so you don’t need to worry about forgetting to commit your work or save it to a memory stick if you work on multiple machines.&lt;/li&gt;
&lt;li&gt;Getting your functions and uploading them is super easy. This is by far the best bit about this method.&lt;/li&gt;
&lt;li&gt;You now have an integrated terminal, allowing you to install npm packages and do everything else you want to do using the terminal.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Disadvantages&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It still has the same stability issues that the Lambda editor has. I’ve had multiple occasions where I’ve tried to save couldn’t, having to copy to local, refresh and recopy to Cloud 9. After a few times, I gave up and moved to local editing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Local Editing
&lt;/h3&gt;

&lt;p&gt;I’m going to do this one a bit differently, I’ll list the advantages and disadvantages then show you how to make it so much better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AXMS7swq0ptF24er7L0fgmg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AXMS7swq0ptF24er7L0fgmg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Advantages&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Local editing is how most developers will work, we can use our favourite IDE, extensions and colour schemes.&lt;/li&gt;
&lt;li&gt;It’s stable (as long as your computer is).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Disadvantages&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;There’s no fancy button to get and upload your work to AWS.&lt;/li&gt;
&lt;li&gt;Your work is local, so multiple users or just working on multiple devices is more complex.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Local Editing Tricks
&lt;/h4&gt;

&lt;p&gt;Because the advantages for this method are so appealing (or the other methods’ disadvantages are so appalling) we’re going to utilise some basic workarounds. It should take about 15 minutes to set up everything we need!&lt;/p&gt;

&lt;h4&gt;
  
  
  AWS CLI
&lt;/h4&gt;

&lt;p&gt;To upload our work to AWS we can use the AWS CLI. This allows us to upload a zip file to our AWS account that populates a given Lambda.&lt;/p&gt;

&lt;p&gt;To do this we first need to setup AWS CLI. You can install it using&lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/installing.html" rel="noopener noreferrer"&gt;this tutorial&lt;/a&gt;or by typing npm install -g aws-cli into your terminal. Now we need to set up a user for our CLI to log in as.&lt;/p&gt;

&lt;p&gt;In IAM Management, click &lt;em&gt;Add User,&lt;/em&gt; give the user a name and select &lt;em&gt;Programmatic Access.&lt;/em&gt; This will allow us to act as the user remotely.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2ALkB76XZZwPt6soPHPtWlCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2ALkB76XZZwPt6soPHPtWlCQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the permissions screen, choose to &lt;em&gt;Attach existing policies directly&lt;/em&gt; and select &lt;em&gt;AdministatorAccess.&lt;/em&gt; This will let you do whatever you want through your CLI. You can set stricter policies on this user if you want, or this is for another person to access.&lt;/p&gt;

&lt;p&gt;There’s another screen before you end up being show your access key. Copy your access key and open a terminal. Run the command aws configure which will ask you for 4 things.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS Access Key ID [None]: "Your Access Key ID" AWS Secret Access Key [None]: "Your Secret Access Key" Default region name [eu-west-1]: Default output format [json]:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The first two are found on the last page of the user creation and the next two can be left as default or changed to whatever you want.&lt;/p&gt;
&lt;h4&gt;
  
  
  Using the AWS CLI
&lt;/h4&gt;

&lt;p&gt;Now that we’ve got the CLI set up, we can use it to make our lives so much easier. If you have a folder with a lambda function in then we can run a few simple commands to upload it.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd MyLambdaFunction rm index.zip zip –X –r ./index.zip \* aws lambda update-function-code --function-name MyLambdaFunction --zip-file fileb://index.zip cd ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  AWS CLI Build Script
&lt;/h4&gt;

&lt;p&gt;This is great but typing this all out every time you want to upload a new lambda version would become tiresome. So we’re going to use a build script.&lt;/p&gt;

&lt;p&gt;For this exact script to work, you need to have a folder structure like this. Each lambda has a folder with the relevant files and a region.txt file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F270%2F1%2AXEed7aP1zbg6CyB3B8maWA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F270%2F1%2AXEed7aP1zbg6CyB3B8maWA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This script not only runs the basic AWS CLI commands, but it also does extra checks, runs npm install and echos out details about the progress.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;This may look like a complex script but it can be easy broken down. The first 32 lines are moving into the lambda folder, running npm install, and checking that AWS CLI is installed. Line 38 is zipping the folder, except from certain files, and line 42 is uploading the zip file.&lt;/p&gt;

&lt;p&gt;Now all you need to do is to navigate to the main lambdas folder and run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./build.sh example-lambda
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This script could be modified and expanded to include region specific uploading, batch uploading multiple lambdas or Git integration.&lt;/p&gt;

&lt;h4&gt;
  
  
  Git
&lt;/h4&gt;

&lt;p&gt;Most people reading this will use git on a daily basis. There’s a reason for that — it makes life simpler.&lt;/p&gt;

&lt;p&gt;Having a git repository for all of your lambdas is a great way to work with teams of developers or by yourself on multiple machines.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;There are three common ways to edit Lambdas: in the Lambda console, in Cloud 9, and locally.&lt;/p&gt;

&lt;p&gt;There are advantages and disadvantages to all three methods, but I think the best choice is to write function locally and deploy them using a deployment script.&lt;/p&gt;

&lt;p&gt;If you found this useful then give it some claps and follow me for more AWS tutorials and developer articles!&lt;/p&gt;

&lt;p&gt;NEXT → &lt;a href="https://dev.to/samwsoftware/say-hello-to-your-own-amazon-lex-chatbot-mol-temp-slug-2595234"&gt;Say Hello to Your Own Amazon Lex Chat Bot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A-leQk1ik68WjLB__Vc9IXw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A-leQk1ik68WjLB__Vc9IXw.gif"&gt;&lt;/a&gt;&lt;/p&gt;




</description>
      <category>cloud9</category>
      <category>aws</category>
      <category>awslambda</category>
      <category>automation</category>
    </item>
    <item>
      <title>I Burnt Out — Forcing Myself to Work at 100% All the Time</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Sat, 07 Apr 2018 10:24:58 +0000</pubDate>
      <link>https://dev.to/samwsoftware/i-burnt-out--forcing-myself-to-work-at-100-all-the-time-led</link>
      <guid>https://dev.to/samwsoftware/i-burnt-out--forcing-myself-to-work-at-100-all-the-time-led</guid>
      <description>&lt;h4&gt;
  
  
  I’ve written about how I utilise my mornings to do things like Doubling my salary in 5 months, and I wanted to carry on that level of progress. After a month of trying to force it, I was frustrated, exhausted and bored.
&lt;/h4&gt;

&lt;h3&gt;
  
  
  What I was doing
&lt;/h3&gt;

&lt;p&gt;I was getting up every morning at 6am with the aim to do 1.5 hours of work before starting my daily job. I would sit down and try to do anything that I classed as making progress.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why This Failed
&lt;/h3&gt;

&lt;p&gt;There are load of reasons that this failed but here are the main three:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. I changed my routine
&lt;/h4&gt;

&lt;p&gt;With starting a new job, my routine changed slightly but the biggest change came when I broke my phone. This meant that I no longer had access to Blinkist to listen to a book whilst I had breakfast. To fill the time I turned to Youtube.&lt;/p&gt;

&lt;p&gt;Youtube has a lot of amazing content, but it also has an insane amount of crap. Unfortunately that crap often has a great title and a eye catching thumbnail. I ended up getting distracted, watching useless video after useless video and wasting a lot of my mornings.&lt;/p&gt;

&lt;p&gt;Because I changed my routine, I often forgot to do my daily bullet journal and weekly reviews. This meant I had no real plan for how to use my 1.5 hours and wasn’t catching my wasted time in my weekly reviews.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. I had no direction
&lt;/h4&gt;

&lt;p&gt;When I was trying to get y first developer job, I had a very clear goal with defined milestones.&lt;/p&gt;

&lt;p&gt;When I was trying to double my salary, I had a very clear goal with defined milestones.&lt;/p&gt;

&lt;p&gt;Currently I had no goal and no milestones. With no goal to achieve, I wasn’t delaying any work by watching another Youtube video.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. I was forcing it
&lt;/h4&gt;

&lt;p&gt;The days that I managed to actually get some work done, I was trying really hard to do really well. I had willpowered my way off Youtube and needed to make up for the days I’d wasted.&lt;/p&gt;

&lt;p&gt;I was doing things just so I could feel like I was accomplishing something, not because I wanted to or because it was beneficial.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;After a month of this, I was tired and frustrated. Tired from using my willpower to get some work done and frustrated that the work was crap and that I’d made almost no progress.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I Did to Turn Things Around
&lt;/h3&gt;

&lt;h4&gt;
  
  
  I Chilled out
&lt;/h4&gt;

&lt;p&gt;I decided that forcing progress wasn’t working and I deserved some time off. I still woke up at 6am but I did what I wanted. Watch a few episodes of Brooklyn Nine Nine? Why not! Have a session on Rocket League, Skyrim, or any other game that took my fancy? Sounds Fun! Snooze the alarm until 8am? Sometimes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lkZcMVTb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ARoC_-1xB03_kQR66OMBPVQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lkZcMVTb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ARoC_-1xB03_kQR66OMBPVQ.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Set New Goals
&lt;/h4&gt;

&lt;p&gt;After about 2 weeks of more relaxed mornings, I felt ready to start some work again. This time I knew I had to have a goal, so I sat down and came up with a new main goal.&lt;/p&gt;

&lt;p&gt;For me this is to &lt;strong&gt;complete the Fast AI Deep Learning course.&lt;/strong&gt; AI and deep learning is something that has always interested me, it’s a great skill for a developer to have, and there is a possible project at my job where I could use it.&lt;/p&gt;

&lt;p&gt;As well as my main goal, I decided that I want to become more consistent with my articles, so I’ve decided to write one article a week. This is deliberately low so it’s easier for me to achieve, keeping motivation levels high. If I write more, even better!&lt;/p&gt;

&lt;p&gt;Having a goal means that I know what I’m going to be doing when I get up in the morning, and more importantly, I want to be doing that. This should help me close the Youtube tab and start making progress again.&lt;/p&gt;

&lt;h4&gt;
  
  
  Restart Journal-ling
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wMisqRPN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AgW9vN2wLyXoWMfqQhKLrlA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wMisqRPN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AgW9vN2wLyXoWMfqQhKLrlA.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This goes along well with setting a new goal. My journal used to be amazing to making sure I knew what I was working on that week and that day. It helped me track progress and see how I was using my time.&lt;/p&gt;

&lt;p&gt;It often catches weeks where you spend too much time on one thing as well as keeping you more organised in general.&lt;/p&gt;

&lt;h4&gt;
  
  
  I got a new phone
&lt;/h4&gt;

&lt;p&gt;This may seem silly but it means that I can listen to Blinkist again, stripping Youtube from my mornings, removing a massive distraction opportunity.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Aim
&lt;/h3&gt;

&lt;p&gt;These changes will hopefully reignite my passion for progress and reduce the willpower I was using to force myself into work.&lt;/p&gt;

&lt;p&gt;I’ll have better organisation of my life and hope to grow personally and professionally.&lt;/p&gt;

&lt;p&gt;If you liked this article, please mash that clap button and follow me for more articles on tech and productivity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6aRVXTdp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AhNyHl_6GQIr7cmcSYSwF3w.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6aRVXTdp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AhNyHl_6GQIr7cmcSYSwF3w.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>burnout</category>
      <category>goals</category>
    </item>
    <item>
      <title>AI is Taking Peoples’ Jobs — Are Developers Next?</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Tue, 27 Mar 2018 13:10:40 +0000</pubDate>
      <link>https://dev.to/samwsoftware/ai-is-taking-peoples-jobs--are-developers-next-hi4</link>
      <guid>https://dev.to/samwsoftware/ai-is-taking-peoples-jobs--are-developers-next-hi4</guid>
      <description>&lt;h4&gt;
  
  
  I was recently asked to comment on whether there was any point becoming a developer because AI might be doing it very soon.
&lt;/h4&gt;

&lt;p&gt;Here is the quote I was asked to comment on:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Developing websites especially ones with static content or just plain content management will no longer be a relevant skill in next few years.&lt;/p&gt;

&lt;p&gt;Developing website will boil down to choosing a color palette, deciding your content and then just letting a website creating tool to do the rest for you. Most of it has been automated already. Even things like deploying scalable web services and APIs have become easier owing to cloud computing platforms provided by Amazon, Google, Microsoft and others.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I’ve also been reading more articles on AI and a few have rekindled my interest in the conversation. One of the best articles I’ve read asks &lt;a href="https://medium.freecodecamp.org/the-ai-solution-youre-building-might-cost-people-their-jobs-here-s-why-you-should-care-eec7e66ed4e3" rel="noopener noreferrer"&gt;should developers should care that their AI products could take away peoples’ jobs&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI Taking Jobs
&lt;/h3&gt;

&lt;p&gt;There is no doubt that AI is now doing things that used to be done by people. The most obvious is chatbots taking away customer service jobs, but there are loads of other examples: facial recognition passport gates, automatic logistics planning, even art.&lt;/p&gt;

&lt;h4&gt;
  
  
  Tech taking jobs is normal
&lt;/h4&gt;

&lt;p&gt;Throughout history technology has been taking peoples’ jobs. The horse drawn plough took away the jobs of field diggers, these horse farriers lost their jobs because of tractors and recently production line workers have been loosing their jobs to robotic workers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AOOLTdbFcU8KDYsFiFy2LCw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AOOLTdbFcU8KDYsFiFy2LCw.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI taking peoples’ jobs is just the next step in the continual process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Will AI Take Developer Jobs
&lt;/h3&gt;

&lt;p&gt;Yes, and it’s already started.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F558%2F1%2A0gB8mU6oZKVD4fOnOZN7xA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F558%2F1%2A0gB8mU6oZKVD4fOnOZN7xA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The quote talks about jobs writing HTML and CSS and I thing that a lot of them are already disappearing. Services like SquareSpace allow you to design and build a website without any coding. You can have it exactly as you like without ever having to employ a developer. This isn’t even AI, this is just well designed software.&lt;/p&gt;

&lt;p&gt;AI has also been used in this field. There have&lt;a href="https://blog.floydhub.com/turning-design-mockups-into-code-with-deep-learning/" rel="noopener noreferrer"&gt;been projects&lt;/a&gt;to get AI to build a website from a PhotoShop design. It used image analysis and feature detection to build up a full website from mockups.&lt;/p&gt;

&lt;h4&gt;
  
  
  What about more technical jobs?
&lt;/h4&gt;

&lt;p&gt;Technical jobs, like dynamic websites, creating software or data science, seem safe for now but they will definitely start seeing AI in the workplace more and more.&lt;/p&gt;

&lt;p&gt;I don’t believe that AI will be taking jobs away, but giving developers an incredibly powerful tool to create better products. There are loads of places that I’d love to use AI in my work life, automating the boring processes.&lt;/p&gt;

&lt;p&gt;I don’t think it’ll be long before we have template compilers that take simple commands and compile them into whatever language you want. This will be such a powerful tool as it could eliminate the need for generic boilerplate code, cut down the repetitive typing tasks and give the developers time to do what we do best — solve problems.&lt;/p&gt;

&lt;p&gt;I expect there are loads of use cases in development that would make life so much better. If you can think of any great examples let me know in the comments.&lt;/p&gt;

&lt;p&gt;One thing that AI is a very long from being competent at is the soft skills. Creating a relationship with your customers, effectively motivating and working with a team, and understanding human wants and needs are all skills that turn a good developer into a great one.&lt;/p&gt;

&lt;h3&gt;
  
  
  What about in 100 years?
&lt;/h3&gt;

&lt;p&gt;In 100 years, I have no doubt that a lot of current developer jobs will become obsolete. AI will probably be able to create incredibly complex software from a description of it’s features. There may also be sentient AI which can figure out whatever it is you want and do it, no more need for unique software packages.&lt;/p&gt;

&lt;p&gt;There will also be loads of new jobs to replace our current ones. No one 100 years ago would have thought that web designer, JavaScript developer or machine learning developer would have been jobs. In 100 years there are going to be new jobs we can’t even imagine.&lt;/p&gt;

&lt;p&gt;You could be an alien designer — designing synthetic lifeforms to make distant planets habitable for humans, or a warpdrive operator.&lt;/p&gt;

&lt;h3&gt;
  
  
  So is it worth becoming a developer now?
&lt;/h3&gt;

&lt;p&gt;Yes, if you want to become a developer I think it is a great career choice.&lt;/p&gt;

&lt;p&gt;You may start learning to do things that can already be done by AI but soon you’ll be working on projects that AI is not yet able to do. Demand for developers is set to massively increase over the next decade and the number of areas you can work in is massive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AyUn6TSBwXyFo84rI5GJt8g.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AyUn6TSBwXyFo84rI5GJt8g.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll also be in an industry where progression is always happening. You can continually grow your skills, adopt AI to make your life easier and more productive, and learn about the bleeding edge of technology.&lt;/p&gt;

&lt;p&gt;Thanks for reading this article! If you liked it, give it a clap. If you loved it, follow me to get more tech content every week.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>jobs</category>
      <category>career</category>
      <category>development</category>
    </item>
    <item>
      <title>How I Doubled my Salary in 5 Months and Got an Amazing Job</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Sun, 11 Mar 2018 19:46:52 +0000</pubDate>
      <link>https://dev.to/samwsoftware/how-i-doubled-my-salary-in-5-months-and-got-an-amazing-job--12b1</link>
      <guid>https://dev.to/samwsoftware/how-i-doubled-my-salary-in-5-months-and-got-an-amazing-job--12b1</guid>
      <description>

&lt;h4&gt;
  
  
  It certainly wasn’t easy but I managed to go from a low paid junior dev to a well paid developer in 5 months and even had fun on the way. This is how I did it.
&lt;/h4&gt;

&lt;p&gt;6 months ago I quit my job as a junior JavaScript developer and travelled around south east Asia for 5 months. Within a week of getting back to the UK, I had 3 job offers and had accepted an offer of almost double my previous salary.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Aim
&lt;/h4&gt;

&lt;p&gt;I was planning to travel around south east Asia for 3–6 months and I knew that I wanted get a better job when I returned. My junior JavaScript job had shown me three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I loved to code, not only as a hobby but as a job.&lt;/li&gt;
&lt;li&gt;I enjoyed back end development work as it was removed from the css and visual design of front end development work.&lt;/li&gt;
&lt;li&gt;I didn’t like Angular that much.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this knowledge, I set about creating a target for where I wanted to be by the time I finished travelling and what I needed to learn to get to that point.&lt;/p&gt;

&lt;p&gt;My target was to be a &lt;strong&gt;Mid level Full stack developer&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Recon
&lt;/h4&gt;

&lt;p&gt;To become the mid level full stack developer I wanted to be. To find out where I needed to improve, I looked for jobs that I would want to apply for and saw what they were requiring in a candidate and what they said was desirable.&lt;/p&gt;

&lt;p&gt;Through this I found a list of things that most of the jobs required:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Strong understanding of JavaScript&lt;/li&gt;
&lt;li&gt;At least one framework (usually React or Angular)&lt;/li&gt;
&lt;li&gt;Ability to create a REST API (usually express)&lt;/li&gt;
&lt;li&gt;Knowledge of one or more database (usually MongoDB or SQL)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Formulating the Plan
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B-iQxaFc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AsnaikpRqrNElf5gocsSTEQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B-iQxaFc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AsnaikpRqrNElf5gocsSTEQ.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this information, I knew that I needed to up my game in a few key areas:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I needed to finish reading You Don’t Know JS. This book series helped me really understand the basics of JavaScript, so I reasoned that it would be great for learning the more advanced stuff.&lt;/li&gt;
&lt;li&gt;I needed to become very good at one front end framework. I looked into Angular, Vue and React and decided on React. I’d done a bit of React before and liked it, I wasn’t a fan of Angular, and Vue wasn’t requested in many job adverts.&lt;/li&gt;
&lt;li&gt;Although I could just about create an express API from scratch, I wasn’t very confident and could only do the basics. I needed to up my game across the board with this, especially if I was wanting to have a job that prioritised back end work.&lt;/li&gt;
&lt;li&gt;I could either stick with relational databases (postgreSQL) or learn a new DB. I decided that I would go for learning MongoDB as it was massively popular and added NoSQL databases to my CV.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I wasn’t sure how long I’d be travelling for so decided to plan my learning out like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Learn React (and Redux) whilst reading You Don’t Know JavaScript.&lt;/li&gt;
&lt;li&gt;Get much better at express and learn MongoDB.&lt;/li&gt;
&lt;li&gt;Make something with the skills I’d learnt.&lt;/li&gt;
&lt;li&gt;Learn other things.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I did this for a very good reason. If I ended my travels after 3 months and had completed 1 but was still part way through 2, then I would still be able to apply for mid level developer jobs, they’d just be limited to mainly front end jobs.&lt;/p&gt;

&lt;p&gt;If I did back end learning first, after 3 months I still wouldn’t be very confident with any front end framework and that would probably be a sticking point for every mid level job. I could try to apply for a back end only developer role but they all seemed to want much more experience than I had.&lt;/p&gt;

&lt;h3&gt;
  
  
  Learn React and Redux, and read You Don’t Know JS
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yBTvCu_h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Agu-JMdJu3R7w6_qsOSO3KA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yBTvCu_h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Agu-JMdJu3R7w6_qsOSO3KA.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’d done a little bit of React before, using Youtube videos and normal web tutorials but this time I wanted to make sure that I was learning it properly. This led me to getting the &lt;a href="https://www.udemy.com/react-js-and-redux-mastering-web-apps"&gt;&lt;em&gt;React JS and Redux: Mastering Web App&lt;/em&gt;&lt;/a&gt; course from Udemy.&lt;/p&gt;

&lt;p&gt;This course was brilliant, the little bit of experience I had with React helped a lot but I had no experience with Redux. By the end of this course, I felt like I could have built a pretty complex website and was confident with both the syntax and formats of React and the data control of Redux.&lt;/p&gt;

&lt;p&gt;This course took my about 2 weeks to complete, but I was working on it for an hour or 2 once or twice a week. I was on holiday in Asia so this wasn’t my main priority.&lt;/p&gt;

&lt;p&gt;As well as working on the course when I had my laptop, I read my way through the last few books in the You Don’t Know JS series. I stored the online github version on my phone and read it whilst I was resting between climbs.&lt;/p&gt;

&lt;p&gt;Having got some real world experience, I understood a lot more than the last time I tried to read these books. Things like Promises are really hard to understand if you’ve never used them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get much better at express and learn MongoDB
&lt;/h3&gt;

&lt;p&gt;Now I felt comfortable creating front ends it was time to work on my back end skills.&lt;/p&gt;

&lt;p&gt;Again I decided to do a Udemy course. I found that because they’re complete packages, it progresses nicely and tends to cover the whole process. Of course you can learn all of the same stuff for free on Youtube or other online tutorials but they never seem to cover a whole topic quite as well.&lt;/p&gt;

&lt;p&gt;The next question was which course to do. There are free ones and paid ones, short ones and long ones.&lt;/p&gt;

&lt;p&gt;I decided to invest in myself and buy a course ($10 is a tiny investment for such a lot of information) and I managed to narrow it down to about 3 courses. They varied in length between 7 hours and 25.5 hours.&lt;/p&gt;

&lt;p&gt;I was tempted by the 7 hour course, I could get it done in a week or two whilst still enjoying my holiday. The 25 hour course would obviously take much longer but seemed to cover more topics. By this point in the trip, I’d decided that I was going to be travelling for as long as by bank balance allowed so I went with the 25 hour course.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;a href="https://www.udemy.com/node-with-react-fullstack-web-development"&gt;Node with React: Fullstack Web Development&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h7HE51fv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/480/1%2AU5qMs9sbR2Ra01dOdb9DJw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h7HE51fv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/480/1%2AU5qMs9sbR2Ra01dOdb9DJw.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’ve actually done a full review of this &lt;a href="https://medium.com/@samwsoftware/node-and-react-fullstack-course-review-d8672c8518eb"&gt;course here&lt;/a&gt; and it’s a great course.&lt;/p&gt;

&lt;p&gt;Having done the React and Redux course before, the React stuff was being repeated. So you don’t waste time, you can just skip videos you already know or put the video on 2x speed and “skim watch” for a refresher or to check for any bits of useful advice.&lt;/p&gt;

&lt;p&gt;The back end stuff is where this course excels. It covers a huge range of topics including: oAuth, email handling, payments, API key handling, MongoDB, mongoose and advanced deployment.&lt;/p&gt;

&lt;p&gt;The reason that this course is so long is that it covers &lt;strong&gt;so many topics&lt;/strong&gt; in &lt;strong&gt;such great detail.&lt;/strong&gt; This is good and bad, but I ended up watching most of the videos at 1.5x speed and pausing it when I needed to.&lt;/p&gt;

&lt;p&gt;This course obviously took longer than the first, and I managed to finish it in about 1.5 months.&lt;/p&gt;

&lt;h3&gt;
  
  
  I started Writing
&lt;/h3&gt;

&lt;p&gt;At some point, whilst staying in China, I decided to write an article about how awful trying to do &lt;a href="https://medium.freecodecamp.org/developer-vs-the-great-firewall-of-china-aaa8605902ba"&gt;development was in China&lt;/a&gt;. It got accepted into the Free Code Camp publication, and now has 1.6K reads and 791 claps. I was amazed that people read what I wrote and liked it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jk15lVUA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ar2Kcaw_jS1o8BiojZINpoA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jk15lVUA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Ar2Kcaw_jS1o8BiojZINpoA.png" alt=""&gt;&lt;/a&gt;The Stats for the first 30 days of my article. Can you work out when it got put on Free Code Camp?&lt;/p&gt;

&lt;p&gt;I decided that I was going to try to write more articles about what I was doing and cool things I find. This also ended up giving me a great talking point when it came to interviews.&lt;/p&gt;

&lt;p&gt;Writing a blog is also a great way to log your progress and allows you to see how you’ve progressed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make something with the skills I’d learnt
&lt;/h3&gt;

&lt;p&gt;Now I had all the tools I needed, I wanted to create something with them. I was 3.5 months into my travels and expected that I would be able to travel for another 1–3 months. This meant that I might need to start thinking about jobs soon if I wanted to start ASAP when I got back.&lt;/p&gt;

&lt;p&gt;To apply for jobs I needed to update my CV and portfolio. This gave me a great chance to use what I’d learnt to build a new portfolio using Node and React.&lt;/p&gt;

&lt;p&gt;This is exactly what I did. This is the result. As I said before, I’m not a designer, but it works well. I even used a wordpress API to host blog posts on the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fPR_leDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AXNYBkBaKERnw5-F17bSjKQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fPR_leDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AXNYBkBaKERnw5-F17bSjKQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I knew that the design was awful so I posted it in a web design review subredit. I got lots of good advice, most of which revolved around spending the next few months researching and learning the basics of web design.&lt;/p&gt;

&lt;p&gt;One bit of advice I did take was to utilise the bootstraps that existed. This resulted in a &lt;a href="https://samwsoftware.github.io/"&gt;completely new website&lt;/a&gt;, using none of the skills I’d used before, but it does look less garish.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applying for Jobs
&lt;/h3&gt;

&lt;p&gt;The next place I visited was a remote climbing area in Laos. This meant that there was minimal access to power and no wifi. This lead me to leave my laptop in Bangkok for the 2 weeks I was in Laos.&lt;/p&gt;

&lt;p&gt;When I got to the campsite in Laos, I found out that they have 4G! I bought a local sim card (£2 for 1.5GB and then 89p for each extra GB) and had decent internet access. By this point I knew that I had 2 weeks in Laos, then about 4 weeks in China again before heading home. Time to get applying for job.&lt;/p&gt;

&lt;h4&gt;
  
  
  Progress
&lt;/h4&gt;

&lt;p&gt;Over the course of the next 1.5 months I applied to well over 50 jobs, had email and LinkedIn conversations with about 25 people and managed to secure 5 job interviews for the week after I got back. Most of my interactions were by email but if someone wanted to call directly then I tried my best to accommodate that (I was 8 hours ahead).&lt;/p&gt;

&lt;p&gt;I think that having an actual conversation is a great way to improve the relationship between you and the other person, increasing the chances that they’ll invite you to interview or recommend you for a job.&lt;/p&gt;

&lt;p&gt;If you don’t feel comfortable having a call or Skype with people then you can stick to emails, but I think you’re missing out on improving your chances.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build More Things
&lt;/h3&gt;

&lt;p&gt;One of the interviews asked me to prototype what I would do for a company with an awful website and minimal customer service. This was cool as it pushed me into learning about prototyping. I wrote a series of articles on how I prototyped and fleshed out the website. You can see the website &lt;a href="https://golden-shoes.herokuapp.com/"&gt;here&lt;/a&gt; read my &lt;a href="https://hackernoon.com/creating-a-shopping-app-from-scratch-part-1-352ebbd78655"&gt;articles here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hackernoon.com/creating-a-shopping-app-from-scratch-part-1-352ebbd78655"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rIih5Aen--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AQncJAWUwko0qEE3FO5KqrA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last thing I did on this was to create a chat bot for returning orders. I had to learn about the workings of chat bots and it took me about a week to get a decent working version. This was a massive factor in me getting the job.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interviews
&lt;/h3&gt;

&lt;p&gt;Now that I had these 5 interviews lined up, I had to convert them to job offers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Preparation
&lt;/h4&gt;

&lt;p&gt;I’ve written articles about &lt;a href="https://medium.freecodecamp.org/5-top-sites-for-javascript-interview-preparation-71b48e9a6c8a"&gt;preparing for a JavaScript interview&lt;/a&gt; and &lt;a href="https://medium.com/@samwsoftware/how-to-secure-the-job-of-your-dreams-by-smashing-your-interview-61f38b7cdd0e"&gt;mastering the interview process&lt;/a&gt;. I made sure I ticked every box.&lt;/p&gt;

&lt;p&gt;I knew all the points I was wanting to emphasise, how to answer the questions about my weaknesses and what each company did.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Interviews
&lt;/h4&gt;

&lt;p&gt;I’ve always been good at interviews, being naturally introverted I’ve had to teach myself to act more extrovert and engage with the people interviewing me. If you find yourself acting shy and reserved in interviews, I recommend find a book on emotional intelligence and ways to act more confident.&lt;/p&gt;

&lt;p&gt;I had tech tests at 3/4 of the interviews (having done the other two online) and my preparation paid off. There were small slip ups but I talked through my thinking and finished all of the tasks well.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Offers and Negotiating
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P2mizius--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AmjRgciwVUqZKPL7GT6Uegw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P2mizius--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AmjRgciwVUqZKPL7GT6Uegw.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From my first 3 interviews, I had 2 offers. After the fourth interview I knew that they weren’t the company for me so let them know I wouldn’t be considering an offer from them. If you are ever in a similar situation, try not to lead them on if you know you’re not going to accept an offer from them.&lt;/p&gt;

&lt;p&gt;Now I had offers from two companies who were very keen to hire me. It was time to negotiate. I’ve never been great at negotiating or asking for more but I read a few articles and went for it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You might think to yourself: “&lt;em&gt;well, I don’t want to set high expectations, and the offer is already generous, so I ought to just take it.&lt;/em&gt;”&lt;br&gt;&lt;br&gt;
&lt;strong&gt;No. Negotiate.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Or maybe: “&lt;em&gt;I don’t want to start off on the wrong foot and look greedy with my future employer.&lt;/em&gt;”&lt;br&gt;&lt;br&gt;
&lt;strong&gt;No. Negotiate.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“But this company is small and — “&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;No. Shut up. Negotiate.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From &lt;a href="https://medium.freecodecamp.org/ten-rules-for-negotiating-a-job-offer-ee17cccbdab6"&gt;Ten Rules of Negotiating a Job Offer&lt;/a&gt;. I recommend reading it if you’re applying for jobs.&lt;/p&gt;

&lt;p&gt;I definitely didn’t do this perfectly (or even that well) but I did do a few things that strengthened my hand. I had two equal offers but I had a preference for one company. I wrote myself a little script and (after some breathing exercises to calm myself) I called the director of my favoured company.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hi Dave. I’m calling to give you an update on where I’m at. Thank you for giving me an offer, I’m glad you thought that I would be a a great fit in the company too.&lt;br&gt;&lt;br&gt;
I’ve had another really strong offer and I’ll be making my decision this weekend, letting you know by Monday at 12pm.&lt;br&gt;&lt;br&gt;
There is one thing that could really strengthen the offer. I’m going to be relocating to wherever I take a job and some assistance with the relocation costs would be amazing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It didn’t quite end up going exactly like that but it helped a lot. It thanked them for the offer, told them a deadline for making the decision and asked for an improvement in the offer without just asking for a higher wage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;I found out what I needed to get the jobs I wanted. I used this to create a plan and then used paid online courses to speed up the learning process.&lt;/p&gt;

&lt;p&gt;I applied to loads of jobs and got 5 interviews. I negotiated the offers from the two companies I liked the best.&lt;/p&gt;

&lt;p&gt;I’ve been working at &lt;a href="https://www.missionlabs.co.uk/"&gt;MissionLabs&lt;/a&gt; for 2 weeks now and I’m loving it!&lt;/p&gt;


</description>
      <category>jobs</category>
      <category>career</category>
      <category>javascript</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Say Hello to Your Own Amazon Lex Chat Bot</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Fri, 02 Mar 2018 08:07:57 +0000</pubDate>
      <link>https://dev.to/samwsoftware/say-hello-to-your-own-amazon-lex-chat-bot-1n63</link>
      <guid>https://dev.to/samwsoftware/say-hello-to-your-own-amazon-lex-chat-bot-1n63</guid>
      <description>&lt;h4&gt;
  
  
  Build your own chat bot using Amazon Lex and teach it to say whatever you want.
&lt;/h4&gt;

&lt;p&gt;This tutorial will guide you through the whole process of making a chat bot. We will start by setting up some simple responses and then use AWS Lambda for more complex responses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Set Up
&lt;/h3&gt;

&lt;p&gt;As all of this is built on Amazon Web Services you need to have an account. If you don’t have one, you can set one up &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt; and clicking &lt;strong&gt;Create an AWS Account&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once you have your account set up, we can set up the bot. Search for &lt;em&gt;Lex&lt;/em&gt; or find it in the services drop down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AGrZ1JfkXxInFf10AKXkSvA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AGrZ1JfkXxInFf10AKXkSvA.png"&gt;&lt;/a&gt;The AWS Services List&lt;/p&gt;

&lt;p&gt;Once on the Lex page, click &lt;strong&gt;&lt;em&gt;Get Started&lt;/em&gt;&lt;/strong&gt; to get onto the bot setup page. Here is the option to use one of three sample bots or create a &lt;em&gt;Custom Bot.&lt;/em&gt; We’ll be creating a completely custom bot so select that option.&lt;/p&gt;

&lt;p&gt;You now get to name your bot and select an output voice. The voice will be used if you ever want to make a voice chat version of your bot. We will also set the session timeout to 5 min as default and select &lt;strong&gt;no&lt;/strong&gt; for the COPPA (unless you intend to include non PG replies!).&lt;/p&gt;

&lt;p&gt;With that all set up, you can click &lt;strong&gt;Create&lt;/strong&gt;. You’ll be taken to a new dashboard like this and I’ll explain what everything means as we go along.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F915%2F1%2AbytzXWvlXP6iZPzryN82Lg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F915%2F1%2AbytzXWvlXP6iZPzryN82Lg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Intents
&lt;/h3&gt;

&lt;p&gt;A chat bot is a set of responses that it gives to a certain message. These are stored in &lt;em&gt;Intents&lt;/em&gt; which are like talking points.&lt;/p&gt;

&lt;h4&gt;
  
  
  Naming your Bot
&lt;/h4&gt;

&lt;p&gt;We’ll keep our first intent simple, if someone asks what our bot is called we will reply with a name.&lt;/p&gt;

&lt;p&gt;Create a new intent by clicking &lt;strong&gt;&lt;em&gt;Create Intent&lt;/em&gt;&lt;/strong&gt; or clicking the &lt;strong&gt;+&lt;/strong&gt; next to Intents on the left. A menu will pop up and we want to choose &lt;strong&gt;&lt;em&gt;Create intent&lt;/em&gt;&lt;/strong&gt; again. We have to name the intent so call it something like &lt;strong&gt;&lt;em&gt;WhatAreYouCalled.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This puts us through to the Intent screen. For now the important sections are &lt;em&gt;Sample utterances&lt;/em&gt; and &lt;em&gt;Response.&lt;/em&gt; The rest of the settings we will cover later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F903%2F1%2AWZ1wjkHeDo-5ne6p8U5jXA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F903%2F1%2AWZ1wjkHeDo-5ne6p8U5jXA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Sample Utterances
&lt;/h4&gt;

&lt;p&gt;Utterances are the phrases that you want this intent to reply to. For us those are phrases like “What is your name” and “What are you called”. Add each of the phrases to the sample utterances; I also added “what do you like to be called” and “what should I call you”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F469%2F1%2AWg-tdra9fS_Xu1OZ6Rr4rA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F469%2F1%2AWg-tdra9fS_Xu1OZ6Rr4rA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The smart bit of Amazon Lex is that it uses Natural Language Understanding (NLU) to work out what the user is trying to say. If they say “What’s your name” instead of “What is your name”, Lex will still match the phrases. Pretty smart!&lt;/p&gt;

&lt;h4&gt;
  
  
  Response
&lt;/h4&gt;

&lt;p&gt;No we need to reply to this message. Click the &lt;strong&gt;&lt;em&gt;Add Message&lt;/em&gt;&lt;/strong&gt; button in the response box. This creates a new message box for us to fill in.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F635%2F1%2AC6BMDFckK9qbV3E5Yb-lLA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F635%2F1%2AC6BMDFckK9qbV3E5Yb-lLA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In here you can type whatever you want to respond. You can enter multiple answers so the user can get a varied and more natural responses.&lt;/p&gt;

&lt;p&gt;Now click &lt;strong&gt;&lt;em&gt;Save Intent&lt;/em&gt;&lt;/strong&gt; at the bottom of the page and you’ve created your first intent.&lt;/p&gt;

&lt;h3&gt;
  
  
  Building and Testing the Bot
&lt;/h3&gt;

&lt;p&gt;To get your new chat bot working we first need to build it. This allows Lex to take your sample utterances and put it all together. Click the &lt;em&gt;Build&lt;/em&gt; button in the top right of the page, it can take a minute or so to finish building so be patient.&lt;/p&gt;

&lt;p&gt;When it’s finished you get a new area on the right called &lt;em&gt;Test Bot (latest)&lt;/em&gt;. This is where you can try chatting to you bot and testing it out. Try asking your new bot it’s name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F398%2F1%2Ahyhj5biPiXiBBXuKqrhwiQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F398%2F1%2Ahyhj5biPiXiBBXuKqrhwiQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding More Intents
&lt;/h3&gt;

&lt;p&gt;Being able to tell you its name is cool, but we want it to do more than that. You can add intents for load of things, just repeat the process you’ve done with different utterances and responses.&lt;/p&gt;

&lt;p&gt;What does your bot say if the user says Hi or Hello. We’re going to expand on this later so make sure you get it working!&lt;/p&gt;

&lt;p&gt;You can also have a go at making your bot answer these questions:&lt;br&gt;&lt;br&gt;
Who made you?&lt;br&gt;&lt;br&gt;
What is your favourite colour?&lt;br&gt;&lt;br&gt;
What’s it like being a robot?&lt;/p&gt;

&lt;p&gt;What other questions can you think to get your bot to answer?&lt;/p&gt;

&lt;h4&gt;
  
  
  Quick Tip
&lt;/h4&gt;

&lt;p&gt;When you are creating your utterances, type them in all lower case with no punctuation. The NLU program gets rid of the punctuation and capitals so using them can break the system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Improving the Hello Intent
&lt;/h3&gt;

&lt;p&gt;Having your bot just reply with &lt;em&gt;Hi&lt;/em&gt; or &lt;em&gt;Hello&lt;/em&gt; is pretty cool but it isn’t much of a conversation. We’re going to change that.&lt;/p&gt;

&lt;h4&gt;
  
  
  New Hello Intent
&lt;/h4&gt;

&lt;p&gt;This is the design for the new intent&lt;/p&gt;

&lt;p&gt;Customer — Hi&lt;br&gt;&lt;br&gt;
Bot — Hi there, what’s your name?&lt;br&gt;&lt;br&gt;
Customer — my name is Dave&lt;br&gt;&lt;br&gt;
Bot — Hi Dave, it’s nice to meet you. Is there anything I can help you with today?&lt;/p&gt;

&lt;h4&gt;
  
  
  Slots
&lt;/h4&gt;

&lt;p&gt;In Lex, variables are stored in &lt;em&gt;Slots.&lt;/em&gt; These contain a property name, slot type and a prompt.&lt;/p&gt;

&lt;p&gt;There are a few different ways to create new slots and I’ll talk through them.&lt;/p&gt;

&lt;p&gt;The first method is the most expected way. In the &lt;em&gt;Slots&lt;/em&gt; section, type the a name for your variable, choose a slot type and write a prompt. In this example I’m calling my variable &lt;em&gt;Name&lt;/em&gt; choosing &lt;em&gt;AMAZON.GB_FIRST_NAME&lt;/em&gt; and saying &lt;em&gt;Hi there, what’s your name?&lt;/em&gt; as the prompt.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A3K9mmmFMGNqkqc4kqRS26g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A3K9mmmFMGNqkqc4kqRS26g.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The prompt is sent if the &lt;em&gt;Required&lt;/em&gt; box is ticked and the intent doesn’t know the value for the variable. Clicking the settings cog opens up a new menu where you can set multiple prompt messages and list some replies.&lt;/p&gt;

&lt;p&gt;The user can reply with just the answer to the question but what if they say something like &lt;em&gt;My name is David&lt;/em&gt;? Lex needs to know which bit of the reply is the the variable and what is just filler words. You define the variable with curly brackets around the variable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F587%2F1%2Aj9Ig6l7QiE9aDfParU0hkg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F587%2F1%2Aj9Ig6l7QiE9aDfParU0hkg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last bit is to change the final response. You can include any of the variables in the final message using the same {variableName} syntax as in the prompt utterances.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F564%2F1%2ALO3KHaJqaaVOyHWwMbN1kQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F564%2F1%2ALO3KHaJqaaVOyHWwMbN1kQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With all of this updated it’s time to build again and try it out!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F496%2F1%2A6YXcz3DooqcYzTXeosnsNg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F496%2F1%2A6YXcz3DooqcYzTXeosnsNg.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Other way to populate the Slots
&lt;/h3&gt;

&lt;p&gt;So far, the user says a phrase which gets the bot to reply with a prompt for the slot value. This is great but there’s another way. What if a user say “&lt;em&gt;Hi there, it’s Claire”&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F487%2F1%2AbMDo2ioK0MuGMqycsM6WQw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F487%2F1%2AbMDo2ioK0MuGMqycsM6WQw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is just wrong. They’ve told you their name and then you ask them for their name. Luckily we can sort this out.&lt;/p&gt;

&lt;p&gt;We can add a new utterance that includes the slot name. This is the same as writing a prompt utterance, including {SlotName} in the utterance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F650%2F1%2AGcooD5h4Qv-N5Yo3lUgktA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F650%2F1%2AGcooD5h4Qv-N5Yo3lUgktA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This now fills the slot with their name from the first message. The slot is filled so the prompt never has to fire and the final message is sent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F597%2F1%2AG4FXISqnYwEpSentmhc-dg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F597%2F1%2AG4FXISqnYwEpSentmhc-dg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing Your Own Intents
&lt;/h3&gt;

&lt;p&gt;With what you’ve learnt so far you can create intents that create a very unique conversation with your users. You can have intents with multiple slots that create very custom messages.&lt;/p&gt;

&lt;p&gt;Try creating an intent that works like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F398%2F1%2Aj2Lb-EfPzLDC2waiHtDFbg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F398%2F1%2Aj2Lb-EfPzLDC2waiHtDFbg.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks for following this tutorial, I hope you enjoyed it. If you did then please react and follow me for more bot tutorials and JavaScript content.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can also check out some of my most popular articles &lt;a href="https://medium.com/free-code-camp/@samwsoftware" rel="noopener noreferrer"&gt;here&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;




</description>
      <category>chatbots</category>
      <category>javascript</category>
      <category>amazonlex</category>
      <category>ai</category>
    </item>
    <item>
      <title>Shopping App from Scratch — Part 3</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Tue, 27 Feb 2018 19:22:47 +0000</pubDate>
      <link>https://dev.to/samwsoftware/shopping-app-from-scratch--part-3-4b0p</link>
      <guid>https://dev.to/samwsoftware/shopping-app-from-scratch--part-3-4b0p</guid>
      <description>&lt;p&gt;&lt;em&gt;I’d been asked to prototype a shopping site for a job interview. This is part 3 of the process. Read&lt;/em&gt; &lt;a href="https://medium.com/@samwsoftware/creating-a-shopping-app-from-scratch-part-1-352ebbd78655"&gt;&lt;em&gt;Part 1&lt;/em&gt;&lt;/a&gt; &lt;em&gt;and&lt;/em&gt; &lt;a href="https://medium.com/@samwsoftware/creating-a-shopping-app-from-scratch-part-2-5e5ec24b2e0b"&gt;&lt;em&gt;Part 2&lt;/em&gt;&lt;/a&gt; &lt;em&gt;if you haven’t already&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Having got a decent chunk of the website working and with 8 days until my interview, I decided to start working on the chat bot. I’d never done any work with bots so I was really excited.&lt;/p&gt;

&lt;p&gt;It started with a lot of Googling and I found countless ways to create a chat bot. One of the tutorials was on &lt;a href="https://chatbotslife.com/"&gt;Chatbot’s Life&lt;/a&gt; on Medium. This tutorial created a bot using claudia-bot-builder and deployed it on AWS.&lt;/p&gt;

&lt;p&gt;I worked my way through the tutorial but when I got to deploying it to AWS using Claudia, I hit a problem. It didn’t recognise my AWS credentials. I search stackoverflow, AWS and countless forums but couldn’t sort it. I spent almost the whole morning trying to get it to work. If you’ve got experience with AWS or Claudia comment and let me know what I should have done!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xNl6itMA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/479/1%2AU0ScankV5e__HqUEDn5-Hw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xNl6itMA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/479/1%2AU0ScankV5e__HqUEDn5-Hw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://girliemac.com/blog/2017/01/06/facebook-apiai-bot-nodejs/"&gt;next tutorial I found&lt;/a&gt; didn’t use Claudia or AWS so I gave that a go and it worked. I had to start by using ngrok to tunnel the webhook requests through to a local port.&lt;/p&gt;

&lt;p&gt;With this set up I needed to create the webhook routes in my bot API. This meant creating a get route for Facebook verification and a push route for receiving any messages.&lt;/p&gt;

&lt;p&gt;Now I had to go through the process of setting up Facebook so that it worked with my new bot API. this involved creating a Facebook page for my group, adding an app to that page, adding messaging to that app and then adding my ngrok route to verified messaging routes.&lt;/p&gt;

&lt;p&gt;I verified the route and saw the request go through. I also decided to get my app approved for bot messaging by submitting a request. This allows the bot to reply to other users, not just me.&lt;/p&gt;

&lt;p&gt;The next step was to create a simple function that sends the same message back to the user. This was great as it allowed me to see how the process works and find any errors. Luckily there weren’t and it worked great.&lt;/p&gt;

&lt;p&gt;Having a chat bot that imitates whatever you say is quite cool but completely useless. To give this bot a purpose you can connect it to API.ai. There are probably loads of different natural language processing (NLP) libraries and resources but this one is the one the tutorial suggests.&lt;/p&gt;

&lt;p&gt;Once I’d signed up, I created an agent. An agent is like the logic of a bot, it contains all of the ‘request → response’ paths. To start I added a ‘small talk’ add on which meant the bot could have small talk with the user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lgrQ-fhW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/404/1%2A8bLaIWbuAHFkki6OlqRjCw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lgrQ-fhW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/404/1%2A8bLaIWbuAHFkki6OlqRjCw.gif" alt=""&gt;&lt;/a&gt;Small Talk&lt;/p&gt;

&lt;p&gt;You can customise any of the responses and it had a list of inputs which will result in this response. The clever part comes with the fact that the phrase doesn’t have to match exactly. If a user types ‘what is your name’ instead of ‘what’s your name’, it’ll still match. This is the real strength of using a NLP service rather than hard coding all the responses yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating something more customised
&lt;/h3&gt;

&lt;p&gt;The available add-ons are great and it looks like you can do a lot with them but sometimes you just need to do something that they don’t offer. This is where custom intents come in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Intents
&lt;/h3&gt;

&lt;p&gt;These are the building blocks of any successful chat bot. They have a defined set of training phrases and then a given response phrase.&lt;/p&gt;

&lt;h4&gt;
  
  
  Simple text response
&lt;/h4&gt;

&lt;p&gt;This could be as simple as “we will, we will” getting the response of “Rock you!”. This is most commonly used for simple support questions like “What is your customer support number?” or “What is the website address?”. Any question that can have an answer that doesn’t change.&lt;/p&gt;

&lt;h4&gt;
  
  
  Complex Requests
&lt;/h4&gt;

&lt;p&gt;The simple text response intents are fun but they aren’t able to deal with the more complex and relevant questions such as “Where is my order” or “Can I return my order”. For these we need to use webhooks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z5RmvtJD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/431/1%2ApzrzPwqUipw8u8NAkocQMw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z5RmvtJD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/431/1%2ApzrzPwqUipw8u8NAkocQMw.png" alt=""&gt;&lt;/a&gt;Fulfilment Options&lt;/p&gt;

&lt;p&gt;When you enable a webhook call for an intent, the data is sent to the webhook URL that you created. This webhook gets all of the information contained within the intent and you can use this however you want, then return a custom message.&lt;/p&gt;

&lt;h4&gt;
  
  
  Chaining Intents
&lt;/h4&gt;

&lt;p&gt;Asking a question and then giving an answer isn’t how a normal conversation goes, it’s a back and forth of a series of questions and answers.&lt;/p&gt;

&lt;p&gt;DialogFlow allows you to add follow-up intents to any intents you’ve already made. Here is my follow up intents for my &lt;em&gt;returnOrder&lt;/em&gt; intent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oCBhbrDB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/474/1%2AQ7RfxxZkpe6pFSNjDIoq-A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oCBhbrDB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/474/1%2AQ7RfxxZkpe6pFSNjDIoq-A.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Customer — Can I return my order&lt;br&gt;&lt;br&gt;
Bot — Of course, can I take your order number please (simple text response)&lt;br&gt;&lt;br&gt;
Customer — It’s 12345678&lt;br&gt;&lt;br&gt;
Bot — Thank you, I’ll just check that order (simple text response)&lt;br&gt;&lt;br&gt;
Bot — 2 pairs of Fred Perry B72 lace ups for Lucy Jones (webhook that hit the API to search the database for the order)&lt;br&gt;&lt;br&gt;
Bot — Is this the order you want to return?&lt;br&gt;&lt;br&gt;
Customer — Yes&lt;br&gt;&lt;br&gt;
Bot — OK, you will receive an email with a free post label (simple text response but also hits the webhook to send the email)&lt;/p&gt;

&lt;p&gt;This is much more like what you expect from customer service, and it’s all completely automated in this bot.&lt;/p&gt;

&lt;p&gt;Creating this really wasn’t very hard, I managed to do this having never worked with chat bots before. It takes a little while to get your head around how everything works (especially with the webhooks) but if you follow a tutorial and can use stackoverflow then you should be fine.&lt;/p&gt;

&lt;p&gt;The webhook API was very simple: receive a request, if it has an action of &lt;em&gt;return order&lt;/em&gt; then do a get request to main API and format the order in a readable way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oF-2nZR8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/406/1%2AsaBmKdLmw00pTGPTTgvmAA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oF-2nZR8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/406/1%2AsaBmKdLmw00pTGPTTgvmAA.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;




</description>
      <category>bots</category>
      <category>ai</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Creating a Shopping App from Scratch (Part 2)</title>
      <dc:creator>Sam Williams</dc:creator>
      <pubDate>Wed, 07 Feb 2018 01:13:29 +0000</pubDate>
      <link>https://dev.to/samwsoftware/creating-a-shopping-app-from-scratch-part-2-12pn</link>
      <guid>https://dev.to/samwsoftware/creating-a-shopping-app-from-scratch-part-2-12pn</guid>
      <description>&lt;p&gt;This is part 2 of a series on creating a shopping website from scratch for an upcoming interview. &lt;a href="https://medium.com/@samwsoftware/creating-a-shopping-app-from-scratch-part-1-352ebbd78655" rel="noopener noreferrer"&gt;Click here&lt;/a&gt; to read part 1 to find out  more!&lt;/p&gt;

&lt;h3&gt;
  
  
  Product Lists
&lt;/h3&gt;

&lt;p&gt;I knew that this bit would end up taking a while. I had to create and populate a products model, create a get route for the API with searching capabilities, then create product list, product preview, product and filter criteria components.&lt;/p&gt;

&lt;p&gt;The basic back end came together quickly and the front end list and preview components were done reasonable quickly too. I’d set it up so the URL was /products/:gender/:category which ended up regretting later on but it  worked.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AJoRrqATWLevBCcsYykwI9Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AJoRrqATWLevBCcsYykwI9Q.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Filtering
&lt;/h3&gt;

&lt;p&gt;This is where things started to slowly unwind. I created a filter component using multi-select drop downs, populated from the same store as the sub-header. The multi-selects worked well and I managed to get the values from them (with Google, console.log and trial-and-improvement).&lt;/p&gt;

&lt;p&gt;I now had to work out how to turn that search query into a URL. This is where I realised that having a category as a parameter in the URL had a major problem — what if they were searching for more than one category? I had been trying to go with a /products/:gender/:category/:brand type of URL but that was not going to work  now.&lt;/p&gt;

&lt;p&gt;After some trial and error followed by a while of contemplative frustration, I decided to go with /products/:gender?filter-criteria. I could get the filter criteria and gender and pass them straight into the getProducts action… or  not.&lt;/p&gt;

&lt;h4&gt;
  
  
  Converting Filtering into  Queries
&lt;/h4&gt;

&lt;p&gt;For some reason I had left the API functionality at getting all of the available products. Now I needed to take the filter from the front end and convert it into a query for  MongoDB.&lt;/p&gt;

&lt;p&gt;The problem with this is that the query comes in as a string and it needs to be compiled with $and and $or controls for multiple fields and multiple values for those fields respectively.&lt;/p&gt;

&lt;p&gt;For example, requesting all women’s shoes in size 5 or 6 and in blue or white come as a string like  this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;?gender=womens&amp;amp;stock=5&amp;amp;stock=6&amp;amp;colors=blue&amp;amp;colors=white
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the query to the mongo database needs to be in this  format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;$and&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;gender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;womens&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;  
      &lt;span class="na"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; 
        &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
          &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="na"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; 
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}]&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$or&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, express parses the above query into this  format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;gender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;womens&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are 3 problems with this  :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The stock parameter is actually an array of  objects.&lt;/li&gt;
&lt;li&gt;The colors parameter is an array of  strings.&lt;/li&gt;
&lt;li&gt;We need to have all three parameters in a  product.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The stock objects look like  this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means that we need to create an array of objects that have one of the sized requested and also have stock. To do this we use $elemMatch for an object with size in our size array and stock being greater than  0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;  
  &lt;span class="nl"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="c1"&gt;// create an array of elements&lt;/span&gt;
    &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// That match &lt;/span&gt;
      &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// size of 5 or 6&lt;/span&gt;
      &lt;span class="na"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;// and stock greater than 0&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To handle this, I created a handleStock function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleStock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="na"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$elemMatch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$gt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; 
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The colors is slightly simpler. We need to find products that match blue or white. This was similarly handed by a handleColorsArray function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;$or&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleColorsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$or&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;col&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;col&lt;/span&gt; &lt;span class="p"&gt;}))&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last issue is making sure the products contain all of the properties. To do this, if a query had more than one parameter I would pass it to convertToAnd(). This maps over every parameter. “stock” parameters are passed to handleStock. “colours” parameters are passed to handleColorsArray if they are a array. Everything else is just passed through as  is.&lt;/p&gt;

&lt;p&gt;Once each of the parameters has been mapped over, the array of queries is wrapped in an $and  query.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;convertToAnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;param&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;param&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stock&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;handleStock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;param&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;colors&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;handleColorsArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;param&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;param&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;$and&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;q&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if I did a call to the API with queries, it could process them and return the array of all of the matching products. Hooray!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AwKz2bHUSl4uiSIwooCulzQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AwKz2bHUSl4uiSIwooCulzQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Filter Criteria
&lt;/h3&gt;

&lt;p&gt;Now with the API able to receive and processing the filtered queries, I had to allow the users to select and change  them.&lt;/p&gt;

&lt;p&gt;I created a FilterCriteria component that mapped over the filtering options and created a new Select dropdown for each. This Select uses MaterializeCSS multi-select dropdown boxes so that a user could select and unselect the options that they want. Because of MaterializeCSS these boxes worked well and looked  great.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AAxkGH9-Q-KvTkslT5lEYNw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AAxkGH9-Q-KvTkslT5lEYNw.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I had to get the resulting information from the form and somehow send this to the API. The solution I came up with was to make the search button a to the URL that corresponded to the  queries.&lt;/p&gt;

&lt;p&gt;I did this by mapping over the form and extracting all of the drop down values. I then mapped over these adding them to a query string. If a value had multiple selected options, I mapped each of them to another section of the query  string.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ADzGkuvaF6BvWZ58p9t1WVg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2ADzGkuvaF6BvWZ58p9t1WVg.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;FWith the completed query string, I generate the complete URL and push it into the  history.&lt;/p&gt;

&lt;h4&gt;
  
  
  A few small  hiccups
&lt;/h4&gt;

&lt;p&gt;The way that I’d set things up, it currently worked like  this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search for trainers by Fred Perry in size  5&lt;/li&gt;
&lt;li&gt;Redirected to URL /products/womens?category=TRAINERS&amp;amp;brand=FRED%20PERRY&amp;amp;size=5&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The problem with this is that &lt;em&gt;TRAINERS&lt;/em&gt; doesn’t match &lt;em&gt;trainers&lt;/em&gt; like in the database. The reason that it is TRAINERS in the URL is that I capitalised the strings as lower case looked really  bad.&lt;/p&gt;

&lt;p&gt;To try to fix this, I just converted all of the strings to lower case before processing them. This brought up two new problems.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The default values don’t equal themselves as the value from the select has been lower cased →(“category” === “Category”) is false. This means they are added to the query string as &lt;em&gt;category=Category&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;The brands no longer match the database  strings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After some over complicated attempts to capitalise certain parts I realised I could just change the original values in the database.&lt;/p&gt;

&lt;p&gt;“red” became “Red”, “trainers” became “Trainers”. I think this also looks much better than block capitals.&lt;/p&gt;

&lt;p&gt;This meant that I didn’t need to do any string manipulation and everything would work as it had done  before.&lt;/p&gt;

&lt;h3&gt;
  
  
  Product Page
&lt;/h3&gt;

&lt;p&gt;Now I had a fully filterable product list, I needed to send the customers somewhere when they clicked on a  product.&lt;/p&gt;

&lt;p&gt;This was a simple layout — image on the left — basic details on the right — full details  below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F799%2F1%2AULtTiuK7jg_XXMz4zKWFQQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F799%2F1%2AULtTiuK7jg_XXMz4zKWFQQ.jpeg"&gt;&lt;/a&gt;Basic wireframing&lt;/p&gt;

&lt;p&gt;Building this component was simple to build and most of my time was spent styling it so that it looked good and worked well on desktop and on  mobile.&lt;/p&gt;

&lt;p&gt;I’ve still got some work to do with this page. The &lt;em&gt;select&lt;/em&gt; boxes are being created before the product information has been received and aren’t updating their values with the correct information. The &lt;em&gt;Add to Basket&lt;/em&gt; button currently doesn’t do anything as I need to create the user/basket update methods  first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Account Pages
&lt;/h3&gt;

&lt;p&gt;The last UI thing I decided to tackle was building an account section. Again I &lt;em&gt;borrowed&lt;/em&gt; the design from Asos, simple tabs on the right and information on the right. When on mobile, the menu was full screen width and opened a new page that had a back  button.&lt;/p&gt;

&lt;p&gt;Each of the options (Orders, Details, Addresses) have their own UI component. These components are either rendered to the right side of the menu when on desktop, or as a separate page when viewing on  mobile.&lt;/p&gt;

&lt;p&gt;These components are very simple, taking a prop of either auth (user) and rendering out the relevant data. Again these components currently don’t support updating the user information as I’ve decided to work on other parts of the prototype first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AVMBc63-4iXD-mXg-N-7PYg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AVMBc63-4iXD-mXg-N-7PYg.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Things to  note
&lt;/h3&gt;

&lt;p&gt;It may seem like I’m building lots of components without finishing some of them, even leaving some not working properly. You’d be right. I’m doing this for 3  reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I only have 3 weeks to build it. Making 80% of it work will take 20% of the time. I’m just skipping the last 20% and saving myself a load of  time.&lt;/li&gt;
&lt;li&gt;This is a prototype. I’m not trying to make a perfect product, I want to show all of the ideas I have. As long as they work reasonably well and demonstrate the skills and ideas that I have, they’re meeting their requirements.&lt;/li&gt;
&lt;li&gt;I’m actually on holiday. I’m doing this in the last few weeks of a 6 month road trip around South East Asia. I don’t want to be spending all day every day sat inside on a laptop when I could be outside climbing and having  fum.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the next section I’ll talk about creating a chat bot to accompany the website. I’ve never worked with chat bots before so come along for the  ride!&lt;/p&gt;

&lt;p&gt;If you liked this article, make sure to react and follow me to see the &lt;a href="https://hackernoon.com/shopping-app-from-scratch-part-3-89e631a34361" rel="noopener noreferrer"&gt;part 3&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>projects</category>
      <category>node</category>
      <category>ecommerce</category>
    </item>
  </channel>
</rss>
