<?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: Godwin Alexander Ekainu</title>
    <description>The latest articles on DEV Community by Godwin Alexander Ekainu (@maxiggle).</description>
    <link>https://dev.to/maxiggle</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%2F712849%2F1fd7cc1a-ef1d-4b55-b336-b1be9f375fab.png</url>
      <title>DEV Community: Godwin Alexander Ekainu</title>
      <link>https://dev.to/maxiggle</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/maxiggle"/>
    <language>en</language>
    <item>
      <title>How To Integrate Chatbots Into Vue Apps Using AWS Amplify</title>
      <dc:creator>Godwin Alexander Ekainu</dc:creator>
      <pubDate>Mon, 10 Jan 2022 10:46:29 +0000</pubDate>
      <link>https://dev.to/maxiggle/how-to-integrate-chatbots-into-vue-apps-using-aws-amplify-pd0</link>
      <guid>https://dev.to/maxiggle/how-to-integrate-chatbots-into-vue-apps-using-aws-amplify-pd0</guid>
      <description>&lt;p&gt;Everyday, new tools are been created or designed to simplify interactions between end-users and computers. On websites like e-commerce websites there is a need to automate interactions using a chatbot as it will serve as a standby employee 24/7.&lt;/p&gt;

&lt;p&gt;Throughout this tutorial, we will be looking at how we can practically deploy chatbots to our Vue app with fewer lines of code using the Amazon Lex service through the AWS Amplify CLI (Command Line Interface).&lt;/p&gt;

&lt;h2&gt;
  
  
  What is AWS Amplify
&lt;/h2&gt;

&lt;p&gt;AWS Amplify is a set of tools that helps developers create scalable, full-stack mobile and web applications all powered by AWS. Amplify lets you configure backends, connect your apps in minutes, and deploy static web apps in a few minutes. We can also say that Amplify is a faster route to use AWS services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Chatbots
&lt;/h2&gt;

&lt;p&gt;Chatbot applications streamline interaction between people and services thereby enhancing the customer experience. Furthermore, they offer companies new opportunities to improve customer engagement processes and operational efficiency by reducing the typical cost of customer service.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will create a chatbot that we can use to place orders for items and implement them in our Vue app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chatbot Walkthrough
&lt;/h2&gt;

&lt;p&gt;Before we dive deep into our tutorial, here are some terminologies we should familiarize ourselves with as we will use them in later parts of the tutorial.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Intent: This is what the user objectives are or what the user wishes to achieve&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Slots: Slots are the data the user must provide to fulfill the intent, you can create as many slots  as possible. Slots are all features that the bot can have.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lambda Function: This is just functionality that enables the chatbot to work with external API like open weather API.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup AWS Amplify CLI
&lt;/h2&gt;

&lt;p&gt;Just before we set up the Amplify CLI, we need to create our Vue project first and we will be using Vue 2 for this tutorial. There is already a start-up project for you in my repository, so instead of going through all the stress of creating a new one, you can just clone my repository to your local machine but you can begin from scratch if you want to.&lt;br&gt;
Note: You need to install CLI in the project directory.&lt;/p&gt;

&lt;p&gt;To install AWS Amplify, first create an AWS account &lt;a href="https://portal.aws.amazon.com/billing/signup?nc2=h_ct&amp;amp;src=header_signup&amp;amp;redirect_url=https%3A%2F%2Faws.amazon.com%2Fregistration-confirmation#/start" rel="noopener noreferrer"&gt;signup&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;On your terminal, use the command &lt;code&gt;npm install -g @aws-amplify/cli&lt;/code&gt; to install AWS globally on your local machine. &lt;br&gt;
This will allow us to access and interface with their services faster, directly on our local machine.&lt;/p&gt;
&lt;h2&gt;
  
  
  Configure AWS
&lt;/h2&gt;

&lt;p&gt;Still on your terminal, use the &lt;code&gt;amplify configure&lt;/code&gt; command. The &lt;code&gt;amplify configure&lt;/code&gt; command will set up an account that will allow us to interface with AWS services and allow Amplify CLI to create bot services for us.&lt;br&gt;
The &lt;code&gt;amplify configure&lt;/code&gt; command will prompt us to sign in to your AWS account and sign in as a root. After doing so, it should open a new window on your browser called the “AWS Management Console”.&lt;/p&gt;

&lt;p&gt;Once you are signed in, go back to your terminal and hit enter to continue, select a region, we will be using us-east-1, specify a username or you can use the default name by just hitting enter. After that, a new window will open on our browser to continue creating the user, make sure to check programmatic access which will enable access key ID and secret access key which we will need later to initialize amplify. Hit the next permission button and make sure administrator access is checked and should be by default. Hit next, we won’t be adding any tags, hit the create user button and once the user is created, it will provide us with a key ID and secret access key.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a new user
&lt;/h2&gt;

&lt;p&gt;Copy the keys, go back to your terminal and paste the keys and its going to prompt us to create an AWS profile, so we are going to create a profile and all we need to do is give it a name and our profile will be created.&lt;/p&gt;
&lt;h2&gt;
  
  
  Initializing AWS Amplify in our Vue.js project
&lt;/h2&gt;

&lt;p&gt;Next, run the command on your terminal amplify init&lt;br&gt;
It will prompt us to enter a name for the project, let us use the default name and it is going to ask us for our environment and we are going to choose Dev, it's going to prompt us to choose the IDE we are using, the language and framework, that is if yours is not detected automatically.&lt;br&gt;
It will ask us if we want to use an AWS profile, we are going to say yes and then we choose the profile we created a few seconds ago. Hit enter and amplify CLI will initialize the project on the cloud.&lt;/p&gt;
&lt;h2&gt;
  
  
  Adding chatbot assets to AWS Amplify
&lt;/h2&gt;

&lt;p&gt;Once the initialization is over, we are going to add resources to the project, let us go ahead and run the command amplify add interactions and we are going to hit enter for the default and we are going to choose a sample, we will do “Order Flowers”. We will be asked if we will be targeting children with this bot, say no and the resources will be added successfully.&lt;/p&gt;
&lt;h2&gt;
  
  
  Push Interaction in Vue project
&lt;/h2&gt;

&lt;p&gt;We will use another command amplify push to add the interaction to our project in AWS, recall that we created a project name. After that, it will give us a summary of all the resources we have selected that will be added to the cloud and we will say yes and this will provision our chatbot on AWS.&lt;/p&gt;
&lt;h2&gt;
  
  
  Amplify console
&lt;/h2&gt;

&lt;p&gt;Next, use the command amplify console which will open a new web page, and on this page is where we will see all bots we have created but unfortunately, we won’t be able to access the bot from this page, we will use the search box to search amazon services. So we will search for Amazon Lex and once that is done, we should see the bot we just created.&lt;br&gt;
So let’s go ahead and play around with it.&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%2Fpaper-attachments.dropbox.com%2Fs_DFBD4AC18533C538296C378684504D1C4B9A26808667739F6C34F7483A21930A_1630926344530_aws_chatbot_console.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%2Fpaper-attachments.dropbox.com%2Fs_DFBD4AC18533C538296C378684504D1C4B9A26808667739F6C34F7483A21930A_1630926344530_aws_chatbot_console.png" alt="This is our Chatbot Console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recall that we have talked about some of these terms above but now let’s practically use them and learn more terms to get us acquainted with using the chatbot console.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OrderFlowers_dev&lt;/strong&gt;: Name of bot&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sample Utterances&lt;/strong&gt; (purple arrow): These are possible questions the user might ask and it does not have to be the exact word you use, the user could say something close or around that, the chatbot would be able to understand.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Name&lt;/strong&gt; (green arrow): These are variables that will store all information provided by the user to process their request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slot type&lt;/strong&gt; (red arrow): These are the data types that the variables are to store.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Build &amp;amp; Publish&lt;/strong&gt;: The build button on the console builds the bot ready for testing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prompt&lt;/strong&gt; (blue arrow): Prompts are questions asked by the bot after the user has triggered the bot with the first utterance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Confirmation Prompt&lt;/strong&gt; : This prompt collects the information of the user to see if he/she is satisfied.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fulfillment Prompt&lt;/strong&gt;: This is a function or business logic that processes all the data and returns the users intent, the fulfillment prompt has two sub prompts which we will get to understand below.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;AWS Lamda function&lt;/strong&gt;: This function or logic processes the user's data and gives back a response and it is mostly used when the intent of the user would need to integrate with a third party API to gather information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Return Parameter to the client&lt;/strong&gt;: This function just retrieves all the data inputted by the user and displays it to the user.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Adding our Chatbot to our Vue Project
&lt;/h2&gt;

&lt;p&gt;What we are most interested in is adding our bot to our Vue project, so let’s dive right in&lt;br&gt;
To integrate this chatbot into our app, let's get some dependencies into the project by using the command &lt;code&gt;npm i AWS-amplify aws-amplify-vue&lt;/code&gt; . The new folder &lt;code&gt;aws-exports.js&lt;/code&gt; was added to our project.&lt;/p&gt;

&lt;p&gt;Let's go ahead and add all necessary library to our Vue app&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="c1"&gt;// Import Amplify Modules, Plugins, and aws exports file&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Amplify&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aws-amplify&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;awsconfig&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./aws-exports&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Configure Amplify in project&lt;/span&gt;
    &lt;span class="nx"&gt;Amplify&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;awsconfig&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// Configure vue to use plugins and modules&lt;/span&gt;
    &lt;span class="c1"&gt;// Vue.use(AmplifyPlugin, AmplifyModules);&lt;/span&gt;
    &lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;productionTip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;render&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;h&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;$mount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#app&lt;/span&gt;&lt;span class="dl"&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 code above should go into the &lt;code&gt;main.js&lt;/code&gt; file&lt;/p&gt;

&lt;p&gt;Let's go into our &lt;code&gt;app.vue&lt;/code&gt; folder and do some configuration.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;app&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;max-height:300px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ChatComponent&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;chatbotConfig&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chatbotConfig&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;OrderFlowers_dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;completed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/template&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let us &lt;code&gt;v-bind&lt;/code&gt; the chatbotconfig to our chat component and pass the name of the chatbot as a parameter and boolean value call completed to our chat component where we will be needing it.&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Interactions&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aws-amplify&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ChatComponent&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./components/ChatComponent.vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ChatComponent&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&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;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;chatbotConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;OrderFlowers_dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;clearComplete&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;chatBot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Interactions&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;Here, we create a data entry point with where we define our bots and configs to get our bot working.&lt;br&gt;
Inside the &lt;code&gt;chatbotConfig&lt;/code&gt;, we call the bot name and you get the name from the AWS console.&lt;/p&gt;

&lt;p&gt;The property &lt;code&gt;clearComplete&lt;/code&gt; is set to false so that the bot does not close on completion of an order, instead it will give a response like “thank you for your order”&lt;br&gt;
We will also register the interactions from the AWS-Amplify library using the ChatBot property which will help us know all the values captured by the bot.&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="nf"&gt;mounted&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;Interactions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onComplete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;OrderFlowers_dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleComplete&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="nx"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;handleComplete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;confirmation&lt;/span&gt;&lt;span class="p"&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;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bot conversation failed&lt;/span&gt;&lt;span class="dl"&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="p"&gt;}&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;confirmation&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 code above does error checks incase there is failure communicating with the bot.&lt;br&gt;
We will also create a component that will be a user interface between our bot and the user.&lt;br&gt;
You can find the full source code in my repository on github.&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;messages clearfix&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;messages === []&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Please&lt;/span&gt; &lt;span class="nx"&gt;enter&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(msg, _) in messages&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{
              'message': true, 
              'sender': msg.sender === 'user', 
              'bot': msg.sender !== 'user' 
              }&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;msg.msg.slots&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;strong&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;FlowerType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/strong&amp;gt; {{msg.msg.slots.FlowerType}}&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;strong&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;PickupDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/strong&amp;gt; {{msg.msg.slots.PickupDate}}&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;strong&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;PickupTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/strong&amp;gt; {{msg.msg.slots.PickupTime}}&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;span&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;br&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;strong&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;padding-right: 10px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;}}:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/strong&amp;gt; {{msg.msg}} &amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;input-container&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;keypress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sendMessage&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;message&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;click&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sendMessage&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;Send&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/template&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HelloWorld&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;chatbotConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getHours&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getMinutes&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getSeconds&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="nf"&gt;data&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;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
          &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;sendMessage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;
          &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chatbotConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chatBot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
          &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&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;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&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;Let’s dive into what is happening up there&lt;/p&gt;

&lt;p&gt;First, the chat component is created and is imported into the &lt;code&gt;app.vue&lt;/code&gt; file.&lt;br&gt;
The data entry point contains all variables to be used in the component.&lt;br&gt;
The Message variable bears the messages that the user will send to the chatbot.&lt;br&gt;
The messages variable contains both the messages of the user and the chatbot.&lt;br&gt;
The loading variable is responsible for showing the loader that displays when a message is being sent to the chatbot.&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="nf"&gt;data&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;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
          &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&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;&lt;strong&gt;NOTE&lt;/strong&gt;: props are used to pass data down a component (from a parent component to a child component) the props which are passed are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;ChatbotConfig props containing all configurations of the chatbot (the bot name, the chatbot interaction, and a boolean to show if the chatbot action is completed).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the computed property bears a function that returns the present time a message was sent to the chatbot.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The method property  bears the send message function which is responsible for sending messages from the user to the chatbot.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;sendMessage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chatbotConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chatBot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&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;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;sender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;completed&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;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The flow of the chat component:
&lt;/h2&gt;

&lt;p&gt;With the messages variable, the message is rendered on the component using a &lt;code&gt;v-for&lt;/code&gt; directive. (the v-for directive loops through the variables of the message and renders all the messages (both from the user and the chatbot) into the component), when a user sends a message, the &lt;code&gt;sendMessage()&lt;/code&gt; function is triggered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the send message function does:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The function sets the loading variable to true (this is to show that a loading indicator is shown  to indicate that the message is being sent to the chatbot). &lt;br&gt;
An if statement to check if there was a message being passed into the message variable and if there isn’t, it returns thereby stopping the process of sending a message to the chatbot, furthermore the message variable is reinitialized to an empty string to clear the message from the input box on the user interface (to give a semblance that the message has been sent and can enter a new text). &lt;br&gt;
The user and the message are added to an object which is eventually pushed to the messages variable which contains the messages for both the user and the chatbot, the message is sent to the chatbot.&lt;/p&gt;

&lt;p&gt;The loading variable is set to false indicating that the message has been sent and it disables the loading indicator shown previously and an if statement checks if the chatbot returns a response with a message and if it doesn't, it returns and stops the process.&lt;br&gt;
An if statement checks if the chatbot message is completed and pushes the message into the messages variable that holds all messages. If it doesn't, it returns and stops the process.&lt;/p&gt;

&lt;p&gt;Furthermore, run your app and get chatting with your bot in your app, this is what your app should look like.&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%2Fpaper-attachments.dropbox.com%2Fs_DFBD4AC18533C538296C378684504D1C4B9A26808667739F6C34F7483A21930A_1632232137428_Screenshot%2Bfrom%2B2021-09-21%2B14.47.14.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%2Fpaper-attachments.dropbox.com%2Fs_DFBD4AC18533C538296C378684504D1C4B9A26808667739F6C34F7483A21930A_1632232137428_Screenshot%2Bfrom%2B2021-09-21%2B14.47.14.png" alt="This is how your conversation should turn out"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we have looked at simple steps to add fully equipped bots to your web apps, we have also looked at how to configure and use AWS amplify console and if you have not noticed, we have also learnt cloud operations because this bot is  hosted on the cloud.&lt;br&gt;
We started with very basic explanations as to how important bots are to everyday life and how it can ease stress on companies and help improve user experiences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Further Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Maxiggle/awsChatbot" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>aws</category>
      <category>webdev</category>
    </item>
    <item>
      <title>A definitive guide to using serverless functions with Fauna, Netlify, and VueJS</title>
      <dc:creator>Godwin Alexander Ekainu</dc:creator>
      <pubDate>Mon, 08 Nov 2021 22:49:06 +0000</pubDate>
      <link>https://dev.to/maxiggle/a-definitive-guide-to-using-serverless-functions-in-a-serverless-databases-with-netlify-and-vuejs-4ieg</link>
      <guid>https://dev.to/maxiggle/a-definitive-guide-to-using-serverless-functions-in-a-serverless-databases-with-netlify-and-vuejs-4ieg</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Most of the big streaming companies we see today, like Netflix, Hulu, or Crunchyroll, use some kind of serverless database. If you want to build a product that scales, then a serverless database like Fauna is the right choice. Serverless functions play a big role in this scalability, so in this tutorial, we'll look at how we can use serverless functions in Netlify.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here's a simple definition to get us started:&lt;br&gt;
👉 Serverless functions are single-purpose functions deployed and hosted on infrastructure managed by cloud computing companies like AWS. Tasks that would easily require a fully-fledged backend hosted on a server — like communicating with APIs or a database like Fauna — can easily be done with serverless functions without having to manage backend servers for your application.&lt;br&gt;
The main goal of this tutorial is to give you a definitive guide on running your serverless functions locally using Netlify CLI and the Netlify dev command.&lt;/p&gt;
&lt;h2&gt;
  
  
  Goal
&lt;/h2&gt;

&lt;p&gt;It’s never been easier to create and deploy serverless functions with Netlify!&lt;br&gt;
We’ll also explore how we can integrate Fauna, a serverless database which gives us the simplicity of a NoSQL and the ability to model complex relationships for applications. It also supports multi-tenency, which allows a database to have multiple collections or even child databases.&lt;/p&gt;
&lt;h2&gt;
  
  
  What you need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Netlify account&lt;/li&gt;
&lt;li&gt;Fauna account and database&lt;/li&gt;
&lt;li&gt;A project you want to use serverless functions in&lt;/li&gt;
&lt;li&gt;Some JavaScript knowledge&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Set up a Netlify Account
&lt;/h2&gt;

&lt;p&gt;To get started with Netlify serverless functions, we need to have a Netlify account. Go to &lt;a href="https://app.netlify.com/signup"&gt;https://app.netlify.com/signup&lt;/a&gt; and choose a sign-up option to create an account if you haven't already. Keep in mind that you might have to answer a few questions if you’re creating a Netlify account for the first time.&lt;br&gt;
&lt;a href="https://lh6.googleusercontent.com/4Si4vuf2hPxwh18qqw_vGleogPr5xdoPy9UyG-adtznuMKSyCy8FnQ5LQd5GNs69bOSOJTtuwW_D8fKK3ITeeTPFOz60XkufEYZLhSPBZ1N4UW2RMOK6ESlQTTzXiUSmijWjcTVI"&gt;https://lh6.googleusercontent.com/4Si4vuf2hPxwh18qqw_vGleogPr5xdoPy9UyG-adtznuMKSyCy8FnQ5LQd5GNs69bOSOJTtuwW_D8fKK3ITeeTPFOz60XkufEYZLhSPBZ1N4UW2RMOK6ESlQTTzXiUSmijWjcTVI&lt;/a&gt;&lt;br&gt;
We’ll be using the Netlify dashboard to manage our sites and functions, so it’ll make sense if we knew our way around the interface.&lt;br&gt;
Once signed in, you'll be taken to your Netlify dashboard. &lt;br&gt;
Here, you’ll see an overview of your Netlify account on the Team Overview page, which includes some stats about your usage.&lt;br&gt;
The Sites section displays the sites you have deployed to Netlify.&lt;br&gt;
You can manually upload the static (HTML, CSS, and JS) files to your static site by simply dragging and dropping from your computer to your dashboard.&lt;br&gt;
You also have the option to connect your Netlify account to a GitHub repo of your project and Netlify will run the build process and generate static files and for your app and deploy it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating a functions folder
&lt;/h2&gt;

&lt;p&gt;To get started with Netlify functions on your project, create a &lt;code&gt;/functions&lt;/code&gt; folder in your project directory. This folder is where all our Netlify functions will live, we will later make some configurations for Netlify to access the functions in this folder.&lt;br&gt;
For this article, we’ll be using a simple Vue project to get us started. It's nothing to get too excited over; it just gets random images from &lt;a href="http://unsplash.com"&gt;Unsplash&lt;/a&gt; and display them to users.&lt;br&gt;
If you want to follow along, you can go ahead and clone the repo on your computer, navigate to the newly created folder, and install the dependencies.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &amp;lt;https://github.com/Maxiggle/randomImages.git&amp;gt;
cd random-images
npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This is a Vue3 project created with Vue CLI. The basic structure should look like this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;random-images
 ┣ public
 ┃ ┣ favicon.ico
 ┃ ┗ index.html
 ┣ functions
 ┃ ┣ getAPIUrl.js
 ┃ ┗ hello.js
 ┃ main.js
 ┣ src
 ┃ ┣ assets
 ┃ ┃ ┗ logo.png
 ┃ ┣ components
 ┃ ┃ ┗ ImgCont.vue
 ┃ ┣ App.vue
 ┃ ┗ main.js
 ┣ .env
 ┣ .gitignore
 ┣ README.md
 ┣ babel.config.js
 ┣ package-lock.json
 ┗ package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;For now, we'll just have a simple function to show how functions work. Create a new file, &lt;code&gt;/functions/hello.js&lt;/code&gt;. This is the basic structure of a Netlify function.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// /functions/hello.js

exports.handler = async function(event, context){
        return {
                statusCode: 200,
                body: JSON.stringify({message: "Hello World!"})
        };
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;In our function, &lt;code&gt;exports.handler&lt;/code&gt; is assigned an async function that accepts two arguments, &lt;code&gt;event&lt;/code&gt; and &lt;code&gt;context&lt;/code&gt;. Inside, we return an object with two basic properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;statusCode&lt;/code&gt;, which in this case is &lt;code&gt;200 OK&lt;/code&gt; and,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;body&lt;/code&gt;. The value of body is an object: &lt;code&gt;{message: "Hello World!"}&lt;/code&gt;. That's converted to valid JSON using the &lt;code&gt;JSON.stringify()&lt;/code&gt; method.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, that's our simple function right there. Next, we'll add some configurations to be able to run this function.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up our Netlify configuration
&lt;/h2&gt;

&lt;p&gt;In order to run our Netlify function, we need to designate a folder in a project where Netlify would look for our functions that will be deployed. To do this, create a netlify.toml file at the root of the project and add the following:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# netlify.toml

[functions]
        directory = "./functions"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This tells Netlify to look for our functions in the &lt;code&gt;./functions&lt;/code&gt; folder, which is a relative path from the root of the project. Netlify will locate and deploy the functions in this folder at build time.&lt;/p&gt;

&lt;p&gt;Installing the Netlify CLI&lt;/p&gt;

&lt;p&gt;Netlify's CLI lets us deploy our project locally on our own computers. To install it, make sure you have at least Node.js version 10 or later installed on your computer. Install it with:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install netlify-cli -g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This gives you a global installation of Netlify CLI, so you can run it from any directory. &lt;code&gt;cd&lt;/code&gt; into the root folder of the project and run:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netlify dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;You should see a few things happening here:&lt;br&gt;
&lt;a href="https://lh3.googleusercontent.com/jqJ-0GypwHBTSu836AcmiDz3900ziW6FU4m4aKrZQrHc84NNOZo8AasOyq-BwmY4RnM9ZqwW62hwxM25xhcWsE5X8rxRlKYgu_Qihh_BHr234Xeco-vYUOPkW6fJ4utvisaPFge3"&gt;https://lh3.googleusercontent.com/jqJ-0GypwHBTSu836AcmiDz3900ziW6FU4m4aKrZQrHc84NNOZo8AasOyq-BwmY4RnM9ZqwW62hwxM25xhcWsE5X8rxRlKYgu_Qihh_BHr234Xeco-vYUOPkW6fJ4utvisaPFge3&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  A few things of note:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Netlify injects environment variables from our .env files into the build process which can be accessed by our serverless functions.&lt;/li&gt;
&lt;li&gt;It loads or deploys the functions located in the specified directory. The &lt;code&gt;/functions&lt;/code&gt; server is deployed on a different port from the main application, it's given a random port of 45661, as you’ll notice in the screenshot above.&lt;/li&gt;
&lt;li&gt;It automatically detects what framework the application was built with and runs the necessary build processes to deploy the application. In this case, it’s Vue.js, but it also supports React and other popular frameworks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that our functions are deployed, let’s go ahead and test them. The route will look like &lt;code&gt;/.netlify/functions/&amp;lt;function name&amp;gt;&lt;/code&gt;. When deployed, they can be accessed through the application's default URL and port because Netlify performs some proxying in the background so that the frontend can communicate with the functions.&lt;br&gt;
If we send a GET request to &lt;code&gt;https://localhost:8888/.netlify/functions/hello&lt;/code&gt;, we should get a response of &lt;code&gt;{"message":"Hello World!"}&lt;/code&gt;. And sure enough:&lt;br&gt;
&lt;a href="https://lh5.googleusercontent.com/UmE0NPD_Woqr7poda32u9eooB-JreuQR7sLrl5lD7koZQ6yzD5cj0a-LWPByCZekXnkfLmL-xoWD1wihfZSuDIsP53GPHiaqYaX0wNbWsLsi9jnPNtdtQTp5OVUNLxCkzn6T25I2"&gt;https://lh5.googleusercontent.com/UmE0NPD_Woqr7poda32u9eooB-JreuQR7sLrl5lD7koZQ6yzD5cj0a-LWPByCZekXnkfLmL-xoWD1wihfZSuDIsP53GPHiaqYaX0wNbWsLsi9jnPNtdtQTp5OVUNLxCkzn6T25I2&lt;/a&gt;&lt;br&gt;
It works!&lt;br&gt;
Now, let’s do something useful with the functions. Create a new function at&lt;br&gt;
 &lt;code&gt;/functions/getImg.js&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// /functions/getImg.js

const fetch = require('node-fetch')
const unsplashURL = `https://api.unsplash.com/photos/random/?client_id=j3uex5UW8H34vNuI_2e6h76CNYYkFWSfTQmsiMxs2qQ&amp;amp;?query=lucky&amp;amp;orientation=landscape`;
const getImgData = async () =&amp;gt; {
    const res = await fetch(unsplashURL);
    const data = await res.json()
    return data
}
exports.handler = async function () {
    const imgData = await getImgData();
    return {
        statusCode: 200,
        body: JSON.stringify({ data: imgData }),
        headers: {
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Headers": "Content-Type",
            "Content-Type": "application/json"
            // "Access-Control-Allow-Methods": "GET, POST, OPTION",
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;In the code above, we first require &lt;code&gt;node-fetch&lt;/code&gt;, a Node.js implementation of the window.fetch API. To install the version used for this project, run:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i node-fetch@2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This will install version ^2.x.x of node-fetch. Once that’s installed (if it wasn't already), you can now &lt;code&gt;require&lt;/code&gt; it in your function code.&lt;br&gt;
Now, we can ping the &lt;code&gt;unsplashURL&lt;/code&gt; from our API endpoint. It’s just an Unsplash API URL with some hard-coded parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client ID - &lt;code&gt;client_id=&lt;/code&gt;&lt;code&gt;redacted-redacted-redacted&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Query - &lt;code&gt;query=lucky&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Orientation - &lt;code&gt;orientation=landscape&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Later on, we’ll use a .env variable to store our Client ID.&lt;br&gt;
After that, we have a function &lt;code&gt;getImgURL()&lt;/code&gt; which simply fetches and returns the image data from Unsplash.&lt;br&gt;
Finally, we have our &lt;code&gt;exports.handler&lt;/code&gt; function. Here, &lt;code&gt;imgURL&lt;/code&gt; is assigned the value image data received from the &lt;code&gt;getImgData()&lt;/code&gt; function. The function then returns that same object from before, with the &lt;code&gt;statusCode&lt;/code&gt;, &lt;code&gt;body&lt;/code&gt; with the &lt;code&gt;imgData&lt;/code&gt;, and &lt;code&gt;headers&lt;/code&gt;.&lt;br&gt;
To use this function in our app, we have our Vue component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- src/components/ImgCont.vue --&amp;gt;

    &amp;lt;template&amp;gt;
      &amp;lt;div v-if="img.urls" class="cont"&amp;gt;
        &amp;lt;div class="img-cont"&amp;gt;
          &amp;lt;img :src="img.urls.regular" :alt="img.alt_description" /&amp;gt;
          &amp;lt;span&amp;gt;{{ img.description }}&amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;button class="like"&amp;gt;💖&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;button @click="getImg()"&amp;gt;Get a lucky picture&amp;lt;/button&amp;gt;
    &amp;lt;/template&amp;gt;

    &amp;lt;script&amp;gt;
            import { ref } from "@vue/reactivity";
            export default {
              setup() {
                const clicked = ref(false);
                const img = ref({});
                const getImgData = async () =&amp;gt; {
                  const API_URL = `/.netlify/functions/getImg`;
                  let imgData;
                  try {
                    const res = await fetch(API_URL);
                    imgData = await res.json();
                  } catch (err) {
                    console.log(err);
                  }
                  return imgData.data;
                };
                const getImg = async () =&amp;gt; {
                  img.value = await getImgData();
                };

                return { getImg, img, clicked };
                    },
            };
    &amp;lt;/script&amp;gt;
    &amp;lt;style scoped&amp;gt; ... &amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this component, we declared &lt;code&gt;API_URL&lt;/code&gt; as our Netlify function route.&lt;br&gt;
To get the data from the function, we have &lt;code&gt;getImgData()&lt;/code&gt; which just fetches and returns the data from the route.&lt;br&gt;
Another function — &lt;code&gt;getImg()&lt;/code&gt; — runs when the button is clicked. It runs the &lt;code&gt;getImgData()&lt;/code&gt; function that sets the value of &lt;code&gt;img&lt;/code&gt; to the data returned data. We can now use the image data in the app.&lt;br&gt;
We also have a button near the end of our markup which will run a function &lt;code&gt;savePictureToFauna&lt;/code&gt;&lt;code&gt;()&lt;/code&gt; that’ll add the current image to Fauna. We'll get back to all of this later on.&lt;/p&gt;
&lt;h2&gt;
  
  
  Adding environment variables
&lt;/h2&gt;

&lt;p&gt;In our Netlify function &lt;code&gt;/functions/getImg.js&lt;/code&gt;, the Client ID is hard-coded into the URL in the file. We need to save this as an environment variable instead. To do that locally, create a new &lt;code&gt;.env&lt;/code&gt; file in the root folder:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UNSPLASH_CLIENT_ID=j3uex5UW8H34vNuI_2e6h76CNYYkFWSfTQmsiMxs2qQ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now, go to &lt;code&gt;/functions/getImg.js&lt;/code&gt; and add the environment variable:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// /functions/getImg.js
...

const CLIENT_ID = process.env.UNSPLASH_CLIENT_ID;
const unsplashURL = `https://api.unsplash.com/photos/random/?client_id=${CLIENT_ID}&amp;amp;?query=lucky&amp;amp;orientation=landscape`;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Another great thing about Netlify CLI is its hot-reload feature. Saving this file will automatically load the function again.&lt;/p&gt;
&lt;h2&gt;
  
  
  Deploying the project
&lt;/h2&gt;

&lt;p&gt;We can deploy our project to Netlify from the CLI. In order to do this, we have to build our project locally and then deploy.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
netlify deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;This creates a dist/ folder where our site lives.&lt;br&gt;
Then, follow the prompts. Netlify asks for authorization on your first deploy:&lt;br&gt;
&lt;a href="https://lh4.googleusercontent.com/btrMlvuyLEQ8gwQcugHsOuS3EOw5W5LWABhctvFv03fo59p0LT5vp39t3R_8fMYxAa5MJA-Ndrx3vNu2uHwwuARbwyTo6-cN09E-p4Nc0pJiOrOoqB3ZJQoG69f0ekeblFZu2XEE"&gt;https://lh4.googleusercontent.com/btrMlvuyLEQ8gwQcugHsOuS3EOw5W5LWABhctvFv03fo59p0LT5vp39t3R_8fMYxAa5MJA-Ndrx3vNu2uHwwuARbwyTo6-cN09E-p4Nc0pJiOrOoqB3ZJQoG69f0ekeblFZu2XEE&lt;/a&gt;&lt;br&gt;
&lt;a href="https://lh3.googleusercontent.com/1oX-hGq8RrYhKmEw6l_VuNX14TtCy7OjyqTyQreydDcbNxxmrG1SFdSVLbqkhLcMveJA7GP5-FHuBodz-KIl2fpqNOFCjeL-bNedMe9CfNbeznjXXRArxd3Ferpz6HvVr7rcPOR2"&gt;https://lh3.googleusercontent.com/1oX-hGq8RrYhKmEw6l_VuNX14TtCy7OjyqTyQreydDcbNxxmrG1SFdSVLbqkhLcMveJA7GP5-FHuBodz-KIl2fpqNOFCjeL-bNedMe9CfNbeznjXXRArxd3Ferpz6HvVr7rcPOR2&lt;/a&gt;&lt;br&gt;
It'll ask for a few other things too:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whether to link to an existing site or create and configure a new site — we’ll create a new site&lt;/li&gt;
&lt;li&gt;A unique site name/URL — you can use whatever you want&lt;/li&gt;
&lt;li&gt;The publish directory — Vue put our build files in &lt;code&gt;dist/&lt;/code&gt;, so we'll use that&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We now have a draft deployment of the project. To deploy the production build on the main site URL, we just have to run:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netlify deploy --prod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Pulling environment variables from Netlify dashboard
&lt;/h2&gt;

&lt;p&gt;To add our .env variables to our deploy, go to your Netlify dashboard, select your site, then go to Site settings &amp;gt; Build &amp;amp; Deploy &amp;gt; Environment and add your environment variables.&lt;br&gt;
&lt;a href="https://lh6.googleusercontent.com/bxMh5-4lpA12RziPe3VTdlJ7qhbK7G3XPVid7WtB1kMYSbzDPWAdELPyLT5IvCLAGMBuIo_vwBDKL1Jsm2kJqlBlMeDFa1MZY5jwpwK7ez-PkbJlZoUx0vdil9hjkordCTExuetL"&gt;https://lh6.googleusercontent.com/bxMh5-4lpA12RziPe3VTdlJ7qhbK7G3XPVid7WtB1kMYSbzDPWAdELPyLT5IvCLAGMBuIo_vwBDKL1Jsm2kJqlBlMeDFa1MZY5jwpwK7ez-PkbJlZoUx0vdil9hjkordCTExuetL&lt;/a&gt;&lt;br&gt;
We can also use the env variables we add to our Netlify dashboard for our local deployment when running &lt;code&gt;netlify dev&lt;/code&gt; again.&lt;br&gt;
&lt;a href="https://lh4.googleusercontent.com/RBsCL8CtrI8KXahXGORQ3ZiXbnZEZMblGuy4992NSx18RdqS7j_7gw-7s0lB0CbJg6E6FUH_OfGm5YlHhpRCtztZL898fb_tznaCMT2zIl3NNge4Mnn0zo_5pUJU7n_rlbGtmgI3"&gt;https://lh4.googleusercontent.com/RBsCL8CtrI8KXahXGORQ3ZiXbnZEZMblGuy4992NSx18RdqS7j_7gw-7s0lB0CbJg6E6FUH_OfGm5YlHhpRCtztZL898fb_tznaCMT2zIl3NNge4Mnn0zo_5pUJU7n_rlbGtmgI3&lt;/a&gt;&lt;br&gt;
You can see that it ignores the environment variable from the build settings we defined on our dashboard and injects the one in the &lt;code&gt;.env&lt;/code&gt; file. If we delete the &lt;code&gt;.env&lt;/code&gt; file, Netlify still injects the variable from the build settings of the site.&lt;/p&gt;

 👉 Quick note: this is only possible because the local project has been linked to the site. To link a local project to an already existing site on Netlify, simply run `netlify link`.

&lt;h3&gt;
  
  
  View functions on your dashboard:
&lt;/h3&gt;

&lt;p&gt;To see your functions and their logs on your dashboard, select your site and go to Functions:&lt;br&gt;
&lt;a href="https://lh5.googleusercontent.com/w7K8CyXo7Oh1NisUhYJZiKykxwxzMUxx6glfjTO5GV4Mei5Fujfn7YJ7MT1uzj56xMbrR3aUtGHZeML4j6ABjsmHyg1Tin1jO1LP1cR2xqtbnx1uXjyp9mfC5cCUaRn4T3BvR1X4"&gt;https://lh5.googleusercontent.com/w7K8CyXo7Oh1NisUhYJZiKykxwxzMUxx6glfjTO5GV4Mei5Fujfn7YJ7MT1uzj56xMbrR3aUtGHZeML4j6ABjsmHyg1Tin1jO1LP1cR2xqtbnx1uXjyp9mfC5cCUaRn4T3BvR1X4&lt;/a&gt;&lt;br&gt;
Select a function to view its details and logs:&lt;br&gt;
&lt;a href="https://lh6.googleusercontent.com/QX2NtwCHIfkQ7cB5Q37ZnJvHBF-0CHcY7UGB9pbwu0BzlDDvCd2wfC5fHYFffBIEu-7disxrI_W9qZd8NjenH_Txl2nK8AENx6BnYpYl0aEWjC-IVzQXoyOZSlBs97Fp9GRoyA77"&gt;https://lh6.googleusercontent.com/QX2NtwCHIfkQ7cB5Q37ZnJvHBF-0CHcY7UGB9pbwu0BzlDDvCd2wfC5fHYFffBIEu-7disxrI_W9qZd8NjenH_Txl2nK8AENx6BnYpYl0aEWjC-IVzQXoyOZSlBs97Fp9GRoyA77&lt;/a&gt;&lt;br&gt;
Awesome!&lt;br&gt;
Now that we’ve seen how to work with Netlify serverless functions, let’s explore how we can add more functionality, like connecting to a database. This would normally require setting up a complete backend, but with Netlify functions we can easily pull this off without managing a backend server.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up Fauna
&lt;/h2&gt;

&lt;p&gt;To get up and running with Fauna, &lt;a href="https://dashboard.fauna.com/accounts/register?utm_source=DevTo&amp;amp;utm_medium=referral&amp;amp;utm_campaign=WritewithFauna_ServerlessFunctions_AGodwin"&gt;create an account&lt;/a&gt; and follow the steps on their &lt;a href="https://docs.fauna.com/fauna/current/learn/quick_start/quick_start"&gt;quick start guide&lt;/a&gt; . Once you’re all set up, go to your dashboard and create a new database.&lt;br&gt;
&lt;a href="https://lh3.googleusercontent.com/OpbsbEzjMBRyurul_UqNobCpkYuESCTRBzow-zUSRCvxihTOUUbiBUTt4-as0Yh7b4e9DgDKNZN4D7L5gDfGyRUu-xV6EmiJnq_DZfP6I-lsH36iPk4cMv7u83fBhdCNR-H31SUh"&gt;https://lh3.googleusercontent.com/OpbsbEzjMBRyurul_UqNobCpkYuESCTRBzow-zUSRCvxihTOUUbiBUTt4-as0Yh7b4e9DgDKNZN4D7L5gDfGyRUu-xV6EmiJnq_DZfP6I-lsH36iPk4cMv7u83fBhdCNR-H31SUh&lt;/a&gt;&lt;br&gt;
Then, create a new collection.&lt;br&gt;
&lt;a href="https://lh5.googleusercontent.com/q-d5zKLxwZF3A-ugupC9fYOZ1WovIlri-mGQ4Y0xx8YJ5PxLFaynkJpXbCNS1XmUyxrknRJLCSZ7TU3hrxJ0vb2zoP75EidwiDNS99k4XxdMzmuas12rkVBI8K825XtcCH_6qhNi"&gt;https://lh5.googleusercontent.com/q-d5zKLxwZF3A-ugupC9fYOZ1WovIlri-mGQ4Y0xx8YJ5PxLFaynkJpXbCNS1XmUyxrknRJLCSZ7TU3hrxJ0vb2zoP75EidwiDNS99k4XxdMzmuas12rkVBI8K825XtcCH_6qhNi&lt;/a&gt;&lt;br&gt;
Great! Now that you’ve created your collection, you can now create your own API key that you can use to access your database from your function.&lt;br&gt;
&lt;a href="https://lh3.googleusercontent.com/xNWyrVMbC6EvJc_G-7BxDfvpbk2KQoYhSt98eaKeW5286oviWlSOvrd8xHDINqsbK0d3RhMAM2ksg8cZjROuN1KQIrKyJCSe0kz5Amn6DDv1leFWwTMrgCzyLduTwA-_Mndca6wP"&gt;https://lh3.googleusercontent.com/xNWyrVMbC6EvJc_G-7BxDfvpbk2KQoYhSt98eaKeW5286oviWlSOvrd8xHDINqsbK0d3RhMAM2ksg8cZjROuN1KQIrKyJCSe0kz5Amn6DDv1leFWwTMrgCzyLduTwA-_Mndca6wP&lt;/a&gt;&lt;br&gt;
Once you’ve generated the key, you can add it to your .env file.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FAUNADB_SERVER_SECRET=&amp;lt;secret&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;To use Fauna in your project, install the &lt;a href="https://docs.fauna.com/fauna/current/drivers/javascript"&gt;driver for Javascript&lt;/a&gt;. You can simply install the Fauna npm project if you prefer:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install faunadb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;After successfully installing the package, create a new Netlify function  &lt;code&gt;functions/&lt;/code&gt;&lt;code&gt;savePictureToFauna&lt;/code&gt;&lt;code&gt;.js&lt;/code&gt;  that’ll save liked pics to the database.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ./functions/savePictureToFauna.js

const faunadb = require('faunadb');
// initialize faunaDB client with our secret
const client = new faunadb.Client({
    secret: process.env.FAUNADB_SERVER_SECRET,
    domain: 'db.fauna.com',
    scheme: 'https'
});
// the query object provides us with functions to create a new document in the collection
const q = faunadb.query;

exports.handler = async (event, context) =&amp;gt; {
    // get the data from the body of the request
    const data = JSON.parse(event.body);
    try {
        // create document in existing collection
        const response = await client.query(
            q.Create(q.Collection('fav_piks'), {
                data
            })
        );
        return {
            statusCode: 200,
            body: JSON.stringify({
                message: 'Successfully created document',
                data: response
            })
        };
    } catch (error) {
        console.log(error);
        return {
            statusCode: 400,
            body: JSON.stringify({
                error
            })
        };
    }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Then to run this, in the &lt;code&gt;imgCont&lt;/code&gt; component of this example project, create a new function &lt;code&gt;savePictureToFauna&lt;/code&gt;&lt;code&gt;()&lt;/code&gt; that’ll send the &lt;code&gt;img&lt;/code&gt; data when clicked.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- src/components/ImgCont.vue --&amp;gt;

&amp;lt;template&amp;gt;
  &amp;lt;div v-if="img.urls" class="cont"&amp;gt;
    &amp;lt;div class="img-cont"&amp;gt;
      ...
    &amp;lt;/div&amp;gt;
    &amp;lt;!-- run savePictureToFauna() with the img as an argument --&amp;gt;
    &amp;lt;button ref="likeBtn" class="like" :disabled="!canLike" @click="savePictureToFauna(img)"&amp;gt; 💖&amp;lt;/button&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;button @click="getImg()"&amp;gt;Get a lucky picture&amp;lt;/button&amp;gt;
&amp;lt;/template&amp;gt;
&amp;lt;script&amp;gt;
        import { ref } from "@vue/reactivity";
        export default {
          emits: ["savedPik"],
          setup(props, { emit }) {
            const img = ref({});
            const canLike = ref(true);

            const getImgData = async () =&amp;gt; { ... };
            const getImg = async () =&amp;gt; { ... };

            // function to POST img data to our function
            const savePictureToFauna = async (img) =&amp;gt; {
              try {
                fetch(`/.netlify/functions/savePictureToFauna`, {
                  method: "POST",
                  headers: {
                    "Content-Type": "application/json",
                  },
                  body: JSON.stringify({
                    img,
                  }),
                });

                alert("Pik saved!");
                // emit custom savedPik event
                emit("savedPik");
                canLike.value = false;
              } catch (err) {
                console.log(err);
              }
            };

            return { getImg, img, savePictureToFauna, canLike };
          },
        };
&amp;lt;/script&amp;gt;
&amp;lt;style scoped&amp;gt; ... &amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;In the code above, the &lt;code&gt;savePictureToFauna&lt;/code&gt; function which takes the &lt;code&gt;img&lt;/code&gt; data as an argument, performs a POST request to the &lt;code&gt;savePictureToFauna&lt;/code&gt;&lt;code&gt;.js&lt;/code&gt; Netlify function, which in turn sends the data to Fauna, saving our favorite pictures in the database!&lt;br&gt;
We can also get back pics sent to Fauna. In order to retrieve data from the collection, you can use the &lt;code&gt;[Paginate](&amp;lt;https://docs.fauna.com/fauna/current/api/fql/functions/paginate?lang=javascript#examples&amp;gt;)&lt;/code&gt; function. This function allows us to fetch documents in a collection from Fauna. &lt;code&gt;Paginate&lt;/code&gt; takes in a &lt;code&gt;Set&lt;/code&gt; or &lt;code&gt;Reference&lt;/code&gt; and returns a page of results.&lt;br&gt;
The problem with this is that it simply returns a list of references to each document in the collection without the actual data. You can get the content of the documents by running &lt;code&gt;Paginate&lt;/code&gt; within the &lt;code&gt;[Map](&amp;lt;https://docs.fauna.com/fauna/current/api/fql/functions/map?lang=javascript&amp;gt;)&lt;/code&gt; function. It'll iterate on the array of documents from our collection and call the provided lambda function on each one, returning the results.&lt;br&gt;
To do this, create a new file at &lt;code&gt;functions/&lt;/code&gt;&lt;code&gt;getPicsFromFauna&lt;/code&gt;&lt;code&gt;.js&lt;/code&gt;, similar to the others.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // ./functions/getPicsFromFauna.js

    const faunadb = require('faunadb');
    const client = new faunadb.Client({ ... });

    // the query object provides us with functions to create a new document in the collection
    const q = faunadb.query;

    exports.handler = async (event, context) =&amp;gt; {
        console.log('Function `savePictureToFauna` invoked');
        try {
            const res = await client.query(
                // map through each document returned by paginate
                q.Map(
                    // get documents from collection
                    q.Paginate(
                        q.Documents(
                            q.Collection('fav_piks')
                        )
                    ),
                    // get content of each document
                    q.Lambda('doc', q.Get(q.Var('doc')))
                )
            );
            return {
                statusCode: 200,
                body: JSON.stringify({
                    message: 'Successfully fetched documents',
                    data: res.data
                })
            };
                    } catch (error) {
            console.log(error);
            return {
                statusCode: 400,
                body: JSON.stringify({
                    error
                })
            };
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;App.vue&lt;/code&gt; file has been modified to fetch and display the list of saved pics fetched from the &lt;code&gt;functions/&lt;/code&gt;&lt;code&gt;getPicsFromFauna&lt;/code&gt;&lt;code&gt;.js&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;!-- src/App.vue --&amp;gt;

    &amp;lt;template&amp;gt;
      &amp;lt;main&amp;gt;
        ...
          &amp;lt;!-- run getPicsFromFauna() each time the "saved-pik" event is fired from the child component --&amp;gt;
          &amp;lt;img-cont @saved-pik="getPicsFromFauna()" /&amp;gt;
          &amp;lt;section&amp;gt;
            &amp;lt;h2&amp;gt;Liked Pics&amp;lt;/h2&amp;gt;
            &amp;lt;ul v-if="favPiks.length &amp;gt; 0" class="favPiks"&amp;gt;
              &amp;lt;li v-for="favPik in favPiks" :key="favPik.ref['@ref'].id"&amp;gt;
                &amp;lt;div class="img-cont"&amp;gt;
                  &amp;lt;img :src="favPik.data.img.urls.small" :alt="favPik.data.img.description" class="favPik" /&amp;gt;
                &amp;lt;/div&amp;gt;
              &amp;lt;/li&amp;gt;
            &amp;lt;/ul&amp;gt;
            &amp;lt;span v-else&amp;gt; No fav piks&amp;lt;/span&amp;gt;
          &amp;lt;/section&amp;gt;
        ...
      &amp;lt;/main&amp;gt;
    &amp;lt;/template&amp;gt;
    &amp;lt;script&amp;gt;
    import { ref } from "@vue/reactivity";
    import ImgCont from "./components/ImgCont.vue";
    export default {
      components: { ImgCont },
      setup() {
        const favPiks = ref([]);
        // get pics function
        const getPicsFromFauna = async () =&amp;gt; {
          try {
            // get pics from Netlify function
            const res = await fetch("/.netlify/functions/getPicsFromFauna");
            const data = await res.json();
            favPiks.value = data.data.reverse()
          } catch (error) {
            favPiks.value = null
          }
        };
        return { favPiks, getPicsFromFauna };
      },
      async mounted() {
        this.getPicsFromFauna()
      },
    };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sweet! That's it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;You’ve seen how you can build modern applications on the JAMstack with serverless functions. This makes development a whole lot easier since we no longer need to create a backend to interact with our database.&lt;br&gt;
Serverless functions are the bread and butter of the Jamstack, and Netlify makes them easy. We’ve covered only a few of their capabilities, but if you want to learn more, check out some of these useful links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Maxiggle/Fav-Apik/tree/master"&gt;GitHub Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Maxiggle/Fav-Apik/tree/master"&gt;Get started with Netlify CLI | Netlify Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://explorers.netlify.com/learn/up-and-running-with-serverless-functions/create-your-first-serverless-function"&gt;Create Your First Serverless Function - Up and Running with Serverless Functions - Jamstack Explorers (netlify.com)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.netlify.com/functions/overview/"&gt;Functions overview | Netlify Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Written in connection with the &lt;a href="https://fauna.com/blog/write-with-fauna"&gt;Write with&lt;/a&gt; Fauna Program&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>fauna</category>
      <category>tutorial</category>
      <category>netlify</category>
    </item>
    <item>
      <title>Manage Your AWS Secrets With Doppler</title>
      <dc:creator>Godwin Alexander Ekainu</dc:creator>
      <pubDate>Tue, 12 Oct 2021 03:14:34 +0000</pubDate>
      <link>https://dev.to/maxiggle/manage-your-aws-secrets-with-doppler-21d</link>
      <guid>https://dev.to/maxiggle/manage-your-aws-secrets-with-doppler-21d</guid>
      <description>&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Password, key, or identification is the most broadly used and is one of the most important tools used by organizations to authenticate applications and users, providing them with sensitive systems, information, and services. Because secrets have to be transmitted securely, secret management has to account for and mitigate the risks to these secrets both in transit and at rest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goals
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we will create a simple lambda function,&lt;br&gt;
We will also be creating a registration form screen, login screen using AWS cognito and an api gateway from AWS. This application will contain vital information like a JWT token we would like to keep safe and secure, so we can learn how to manage that token with Doppler&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Secret Management
&lt;/h2&gt;

&lt;p&gt;Tokens, passwords, and keys are the most broadly used form of authentication for authenticating users and other applications before they can access any other service on your application or collect any sensitive information that they would need. Notwithstanding, hackers are on the loose looking for systems that they can exploit from time to time, and to help save yourself or the organization you work for, some money, all secrets that concern your application must be securely stored.&lt;/p&gt;
&lt;h2&gt;
  
  
  Doppler as a Secret Management Solution
&lt;/h2&gt;

&lt;p&gt;Passwords and other secrets are needed to authenticate Application to Application(A2A) and Authentication to Database(A2B) communication and access. Most at times, applications and IoT devices are shipped and deployed with hardcoded credentials which are easily crackable by hackers with a simple dictionary method attack but with Doppler, you don’t have to keep those keys in those scripts anymore as you can securely keep them in Doppler.&lt;br&gt;
Doppler has improved my productivity in just a little time of using the platform. Doppler provides its users with easy ways to set up projects as their documentation is easy and simple to understand.&lt;/p&gt;

&lt;p&gt;Let's dive right into this tutorial and see how Doppler can make things so easy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create users using AWS Cognito
&lt;/h2&gt;

&lt;p&gt;We are going to create users on AWS cognito which has a hosted UI which users can use to sign up and sign in users and it is a very simple work through if you follow the instructions. Below is an image of the user I created.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6ekq5urbkirp9w84iii.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6ekq5urbkirp9w84iii.png" alt="signup"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbivpwsgjnj5bnwrk218.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbivpwsgjnj5bnwrk218.png" alt="signedin user"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our aim of creating this user is to make sure only authenticated users can login to use our app services and we will achieve this using an AWS gate-way that will give us a JWT token, specific to every user and it is this token we will want to secure because we would not want that token to be displayed on the frontend because it can be accessed by anybody and be used to cause severe havoc to our app.&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a lambda function
&lt;/h2&gt;

&lt;p&gt;So let’s create a lambda function that will use an api gate-way that will help us get a JWT token to authenticate our users. &lt;br&gt;
We won’t be getting much detail on creating a lambda function or adding the api gateway as our main focus is to add our JWT token to Doppler.&lt;br&gt;
Below is an image of the lambda function we have created which we will integrate with the api gateway a little 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiko4y4nmumlu20y1frzl.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiko4y4nmumlu20y1frzl.png" alt="lambda function"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Add API Gateway
&lt;/h2&gt;

&lt;p&gt;Amazon API Gateway is an AWS service for creating and securing REST, HTTP, and WebSocket APIs at any scale. API developers can create APIs that access AWS or other web services, as well as data stored in the AWS Cloud.&lt;br&gt;
We will be creating a HTTP gateway in this case.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4p3u8igll5dkyqqbimsy.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4p3u8igll5dkyqqbimsy.png" alt="Add Api"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Create a project on Doppler
&lt;/h2&gt;

&lt;p&gt;Creating a project on Doppler is extremely simple and straightforward, all you just need to do is to hit the plus icon to create a new project.&lt;br&gt;
Log on to your Doppler account and create a new project sort of like so&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3yur968b14rgrc62q0rj.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3yur968b14rgrc62q0rj.png" alt="new Doppler project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once a new project is created, three stages/environments are created which are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Development&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Staging &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Production&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These environments are where we store our  secrets.&lt;/p&gt;
&lt;h2&gt;
  
  
  Sync Doppler with AWS Secret Manager
&lt;/h2&gt;

&lt;p&gt;Before we can sync our secrets with Doppler, we will need to integrate AWS secret manager with Doppler and sync AWS with Doppler, let us follow the steps below&lt;/p&gt;

&lt;p&gt;After creating a project, click on integrations&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhea9zldfpia7wfe9ipnk.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhea9zldfpia7wfe9ipnk.png" alt="Integrate your project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you click on integrations, it should take us to a new web page where we will see a list of different services we can integrate Doppler with but in our case, we will be using Secrets Manager for integration.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2n21yob76avyxkb485ur.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2n21yob76avyxkb485ur.png" alt="setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on Secrets Manager and we will be directed to another page where we will be asked to give the key ID and Access key to our AWS secrets manager. If you do not have one, you can get it while creating a new AWS Amplify user after hitting the Create User button, but if you have one, this is how you access it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Go to I AM management console &amp;gt; select users &amp;gt;  Select the current user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see something 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7n5f8ht1l8ih50p7nza.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7n5f8ht1l8ih50p7nza.png" alt="create accesskey"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where you will find your Access Key ID and then you will have to generate a new Access key.&lt;br&gt;
Add these keys above to Doppler to sync with your AWS secret manager.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j4fjk2lfb6qzdodsjk4.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4j4fjk2lfb6qzdodsjk4.png" alt="sync aws secret manager"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Doppler requires permissions to integrate with our AWS secret manager and these policies can easily be added in JSON format.&lt;/p&gt;

&lt;p&gt;If you have an already existing IAM user and you want to add a new policy, it is pretty easy.&lt;br&gt;
Search for the keyword IAM in the AWS search box and it will show you the IAM AWS feature, click on it, and next select Users.&lt;br&gt;
The first open tab is the permissions tab&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fghc1b19735xjvjrmxpky.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fghc1b19735xjvjrmxpky.png" alt="AWS permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on Add Inline Policy to create a custom policy, give it a name and add these policies in JSON 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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Version&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;2012-10-17&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;Statement&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sid&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;AllowSecretsManagerAccess&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;Effect&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;Allow&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;Action&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secretsmanager:GetSecretValue&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;secretsmanager:DescribeSecret&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;secretsmanager:PutSecretValue&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;secretsmanager:CreateSecret&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;secretsmanager:DeleteSecret&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;secretsmanager:TagResource&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;secretsmanager:UpdateSecret&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;Resource&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;*&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Furthermore, after adding our Keys to integrate Doppler with AWS secret manager, we need to configure the Doppler 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61i9jlxa309kuox929wt.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F61i9jlxa309kuox929wt.png" alt="Addconfig"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select config to sync, the AWS Region where mine is US-east-2 and optionally choose a path in Doppler where all your secrets from AWS will be stored.&lt;/p&gt;

&lt;h2&gt;
  
  
  Save JWT token to Doppler
&lt;/h2&gt;

&lt;p&gt;To get our JWT token, after the user signs in, look on your browser search bar, we will copy that token and store it on Doppler as so&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97t0ebso11p5ujo0p7pl.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97t0ebso11p5ujo0p7pl.png" alt="Copy jwt token"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And now the most interesting part of this topic is to store this secret token on Doppler.&lt;/p&gt;

&lt;p&gt;After syncing your new project to AWS, open the newly created project on your Doppler dashboard.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fno94ubkfa6lxqus3uu04.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fno94ubkfa6lxqus3uu04.png" alt="dashboard"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;newdopplersecrets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose the new project that you created and synced with AWS, I will be choosing&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fennm9cepx1lu51ri9z8w.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fennm9cepx1lu51ri9z8w.png" alt="manager"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recall that you chose an environment while syncing to AWS and in my case, I chose&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Production(prd) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is why according to the image above, prd is colored green because it is active.&lt;/p&gt;

&lt;p&gt;We will click on the active environment to navigate to a new page where we can add the secrets we want to upload on AWS.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxubwnkmpa1o9zcuwq80a.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxubwnkmpa1o9zcuwq80a.png" alt="Add new secrets"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above should be the next page we will see, click on the Add First Secret button to add the JWT token we copied from the browser earlier.&lt;br&gt;
You can add any key name and the token as value&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BASE_URL : https://doppler.com

BEARER_TOKEN : eyJraWQiOiJCUVRvNG9pSHNoK3FodGUrNGwydW9JKzBXZjFsK2tMQkJpckw3dHlXeUFNPSIsImFsZyI6IlJTMjU2In0.eyJhdF9oYXNoIjoiN19fa3VxOG5nV1hiN3ZEZmNTSTJaUSIsInN1YiI6ImU3YjQ0YWRjLTkyYjUtNDZmOS04M2EzLTlkNGMyMDc1ZmM0NiIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0yLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMl9KM2ppVmtrbGIiLCJjb2duaXRvOnVzZXJuYW1lIjoiY2xzeWZyaWRheSIsImF1ZCI6IjIzcmRjdTRhZjFxdDc5MzRsMmE5cTZxbXM1IiwiZXZlbnRfaWQiOiJjNzdkZjdjZS1hZGE1LTQ4YmYtODM2YS0yNzJmYjViMmJkYjkiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTYzMzE3NDI4NiwiZXhwIjoxNjMzMTc3ODg2LCJpYXQiOjE2MzMxNzQyODYsImp0aSI6IjY5NjhiZjZkLWEwYzAtNDkyZi04ODA0LWQ0ZjE2OTRkMWY4YiIsImVtYWlsIjoiY2xzeWZyaWRheUBnbWFpbC5jb20ifQ.U43PFIzcIJOk0MHmCr1a87WKXE4LIosl7ZvoO6Eo27d_rnxGHeUyrP4r0xH9XUeAH7zQR6e4Uk75hCNI1RgD0wpgbaOrmVfnZGnnrBBJTVN9BKs2ZrcPd_53ky8vwSNKAaTYlqvCNRnzARZim85HCYdL0aJaqz-R0jteyb0_7aEvaum2RMHG6RYJ0aYP46fNv8TaYW9imlvGs774kKzLmnHuIHwfN74iHxs68tcT0HcTHMUWqlo08uIZ3szceLszRqmSc7DjU24-Y1qvcsMh01eHbUDq-pdmZTUqaQ1uVTY1vBs-EhlrYNKOr8P-oBga6CiwXWXTfPmf_BYM2pTtvw

PASSWORD : 0123456789

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaeamg9xx4xjab6rv9cp.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbaeamg9xx4xjab6rv9cp.png" alt="Add secrets to Doppler"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding keys and values, your secrets should look like the image above, we should hit the save button at the top right to save our secrets.&lt;/p&gt;

&lt;p&gt;Furthermore, click on the next tab titled Integrations and we should see 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpooodiohgmlho33ppapc.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpooodiohgmlho33ppapc.png" alt="Integrated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let us click on the text &lt;em&gt;Manage&lt;/em&gt; at the extreme, it should lead us to a new web page where we can hit sync to upload all our secrets to AWS secret manager.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjv0n6g7qlp91y65p8xj2.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjv0n6g7qlp91y65p8xj2.png" alt="synced"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hit the Sync text and all our secrets will be added to AWS Secrets manager.&lt;br&gt;
To confirm that all our secrets got uploaded to AWS from Doppler, click the link under the DESTINATION tab just like the picture above and we should see the name doppler added to the project name we created in AWS.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbdpmntn6jy8djz8rqqp.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcbdpmntn6jy8djz8rqqp.png" alt="confirm integration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hurray, we just saved our secrets on Doppler and successfully pushed it to AWS where we can access it for use and whenever we update the secrets on Doppler, it gets updated on AWS automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We have come to the end of this tutorial.&lt;br&gt;
We looked at how to use AWS Cognito to create users using their hosted UI. We also learned how to create a lambda function and integrate the lambda function with an API gateway that helped us give JWT tokens to the users and we looked at how to store that token in Doppler.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
