<?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: PikuBITSPilani</title>
    <description>The latest articles on DEV Community by PikuBITSPilani (@pikubitspilani).</description>
    <link>https://dev.to/pikubitspilani</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%2F822464%2F632a380f-c1c2-40dc-883a-b91c17b0883b.png</url>
      <title>DEV Community: PikuBITSPilani</title>
      <link>https://dev.to/pikubitspilani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pikubitspilani"/>
    <language>en</language>
    <item>
      <title>Azure Trial Hackathon Submission - Favorite Cloud Provider Voting App</title>
      <dc:creator>PikuBITSPilani</dc:creator>
      <pubDate>Sun, 06 Mar 2022 11:22:29 +0000</pubDate>
      <link>https://dev.to/pikubitspilani/azure-trial-hackathon-submission-favorite-cloud-provider-voting-app-248o</link>
      <guid>https://dev.to/pikubitspilani/azure-trial-hackathon-submission-favorite-cloud-provider-voting-app-248o</guid>
      <description>&lt;h3&gt;
  
  
  Overview of My Submission
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;Category chosen by me is - Computing Captains&lt;br&gt;
I have hosted my application on AKS , and used ACR to host the container images&lt;/p&gt;
&lt;h3&gt;
  
  
  Link to Code on GitHub
&lt;/h3&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/turjachaudhuri"&gt;
        turjachaudhuri
      &lt;/a&gt; / &lt;a href="https://github.com/turjachaudhuri/microsoft-azure-trial-hackathon-dev-to"&gt;
        microsoft-azure-trial-hackathon-dev-to
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      https://dev.to/devteam/hack-the-microsoft-azure-trial-on-dev-2ne5
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
microsoft-azure-trial-hackathon-dev-to&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://dev.to/devteam/hack-the-microsoft-azure-trial-on-dev-2ne5" rel="nofollow"&gt;https://dev.to/devteam/hack-the-microsoft-azure-trial-on-dev-2ne5&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/turjachaudhuri/microsoft-azure-trial-hackathon-dev-to"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h3&gt;
  
  
  Additional Resources / Info
&lt;/h3&gt;

&lt;p&gt;[Note:] # Screenshots/demo videos are encouraged!&lt;/p&gt;

&lt;p&gt;This screenshots shows the actual app page , that is running on AKS.&lt;br&gt;
It is a simple voting app , backed by a Redis cache (as backend).&lt;br&gt;
The app is accessible at - &lt;a href="http://20.62.221.90/"&gt;http://20.62.221.90/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6hKbYSkL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b7j4r2vu7x8m9qwey9p.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6hKbYSkL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b7j4r2vu7x8m9qwey9p.PNG" alt="Image description" width="880" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see , Azure is clearly the winner.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Serverless Chatbot based on AWS Lex and Lambda to control your EC2 instances</title>
      <dc:creator>PikuBITSPilani</dc:creator>
      <pubDate>Sun, 27 Feb 2022 09:28:21 +0000</pubDate>
      <link>https://dev.to/pikubitspilani/a-serverless-chatbot-based-on-aws-lex-and-lambda-to-control-your-ec2-instances-ga0</link>
      <guid>https://dev.to/pikubitspilani/a-serverless-chatbot-based-on-aws-lex-and-lambda-to-control-your-ec2-instances-ga0</guid>
      <description>&lt;p&gt;For a long time now ,I wanted to work on a chatbot , just to get my hands dirty with that kind of stuff . I had heard about AWS Lex and how it's pretty easy to setup a chatbot with Lex , so I wanted to give it a try .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Disclaimer &lt;/u&gt;&lt;/strong&gt;: The ideas for the work that I am demonstrating here are derived from the following 2 blog posts&lt;/p&gt;

&lt;p&gt;&lt;a href="https://devpost.com/software/ec2-bot"&gt;https://devpost.com/software/ec2-bot&lt;/a&gt;&lt;br&gt;
&lt;a href="https://chatbotslife.com/aws-lex-insights-after-building-my-shakira-chatbot-663f71967902"&gt;https://chatbotslife.com/aws-lex-insights-after-building-my-shakira-chatbot-663f71967902&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;u&gt;So , what am I trying to achieve here ?&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;So , I went through the 2 blog posts mentioned above , and came upon the idea of creating a bot that would help me control my infrastructure , like say , allow me to do the following things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;list my EC2 instances&lt;/li&gt;
&lt;li&gt;start/stop/terminate an EC2 server&lt;/li&gt;
&lt;li&gt;launch a new EC2 server based on some properties&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also I wanted to integrate my Lex bot with a slack channel so that I can use slack to test , rather than use the AWS Lex Test Console which is pretty basic .&lt;/p&gt;

&lt;p&gt;The bot would finally look like this :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--20lKp1K8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/683caktqhnltsj1agmvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--20lKp1K8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/683caktqhnltsj1agmvi.png" alt="Image description" width="880" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You would be able to use conversational message to control your EC2 infrastructure (basic functions) which in a way is pretty cool.&lt;/p&gt;

&lt;p&gt;You can find the entire video of the bot functioning here-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://vimeo.com/user90131375/review/292679817/1e58b77be0"&gt;https://vimeo.com/user90131375/review/292679817/1e58b77be0&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Ok , how to get started?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To understand how AWS Lex works and truly leverage it to solve your problems , you ideally need to go through the developer guide at least once :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/lex/latest/dg/what-is.html"&gt;https://docs.aws.amazon.com/lex/latest/dg/what-is.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However the basic premise is that , you can create a number of intents for your bot . An intent should be created to fulfil a single intention - say for example ,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an intent to describe instances&lt;/li&gt;
&lt;li&gt;an intent to launch new instances&lt;/li&gt;
&lt;li&gt;an intent to greet/say hi , and so on.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your intents should not overlap both in sense or in functioning.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;How does Lex know which intent to fire always?&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This is based on sample utterances for an intent. An intent can have one/more sample utterances . Enumerate all the different types of ways an end-user might interact with your bot . These sample utterances are the voice/text commands that lex interprets and tries to associate to one or more intent for your bot . For an intent to start a new instance , the sample utterances might be like this -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--etzqxzwD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/869ud4kso567p1y6av83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--etzqxzwD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/869ud4kso567p1y6av83.png" alt="Image description" width="880" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now , in Lex there is also a concept of slots . Slots can be used to extract important information from the utterances . For example , say I have an intent to operate on an instance like say Start/Stop an instance . Then , I can define 2 slots &lt;strong&gt;{action}&lt;/strong&gt; and &lt;strong&gt;{serverName}&lt;/strong&gt; . When , an user provides a sample utterance like -&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I want to start DEV&lt;/strong&gt; , it will correspond to the sample utterance -&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I want to {Action}{ServerName}&lt;/strong&gt; , and the slot values - &lt;strong&gt;{Action}&lt;/strong&gt; will be populated to &lt;strong&gt;"Start"&lt;/strong&gt; , and &lt;strong&gt;{ServerName} *&lt;em&gt;populated to *&lt;/em&gt;"DEV"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--drBVwB3s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlkn6sduexssze6w1m3i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--drBVwB3s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlkn6sduexssze6w1m3i.png" alt="Image description" width="880" height="342"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;What happens after the intent and slots are configured?&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You can configure Lex to call AWS Lambda functions both for initial validation as well as final fulfilment . Lex supports two points of interaction with AWS Lambda . You can perform validation first to check whether the slot values are proper or not , and perform custom validation in your lambda function . Also , you can use a lambda function for fulfillment. Fulfilment refers to the final resolution of an intent , meaning performing the operation that the intent was created to do .&lt;/p&gt;

&lt;p&gt;For example , for an intent to BookACar , the final resolution might be calling an UberAPI with uber details to book the car.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Iq31NQt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czm5n7080fj1q46hseeb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Iq31NQt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czm5n7080fj1q46hseeb.png" alt="Image description" width="723" height="547"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;What does the lambda function do , and how does it connect back with AWS Lex ?&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The lambda function can perform both initial validation as well as final fulfillment. Say , the slot values provided by the user are not values that are supported by the application  , then you can return an &lt;strong&gt;ElicitSlot&lt;/strong&gt; event from the lambda function back to Lex , with an associated message , saying what was wrong with the slot value provided , and optionally providing a list of valid slot values. This event will be parsed by Lex , and Lex will show the message to the user , and ask for the valid slot values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// If any slots are invalid, re-elicit for their value
TryInferSlots(instanceLaunchRequest, previousLaunchRequest);
ValidationResult validateResult = Validate(instanceLaunchRequest);
if (!validateResult.IsValid)
{
lexEvent.CurrentIntent.Slots[validateResult.ViolationSlot] = null;
return ElicitSlot(sessionAttributes, lexEvent.CurrentIntent.Name, lexEvent.CurrentIntent.Slots,
validateResult.ViolationSlot, validateResult.Message , validateResult.ResponseCard);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are a few basic events that are supported by Lex , and they are as follows :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;Delegate&lt;/u&gt;&lt;/strong&gt; - delegating responsibility to AWS Lex to figure out the next step&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;ElicitSlot &lt;/u&gt;&lt;/strong&gt;- provide a slot value and a message that Lex will display to the user asking the user to input the value , that Lex will then put into that slot and pass on to the lambda function in the next call&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;ConfirmIntent &lt;/u&gt;&lt;/strong&gt;- Asking the user to confirm that the user really wants to perform that action via a Yes/No response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These events typically guide the lambda-lex integration and seamlessly allows the user to interact with the chatbot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Integrating the chatbot with Lex&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the easiest part . You can choose to publish your bot and integrate it with a messaging platform like Facebook Messenger/Slack . Here , I chose Slack . The steps are extremely well articulated here . Just follow them judiciously , and you are good to go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/lex/latest/dg/slack-bot-association.html"&gt;https://docs.aws.amazon.com/lex/latest/dg/slack-bot-association.html&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Response Cards&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Response cards are a nice way for users to interact with your chatbot . Rather than asking your users to write down an option , you can show users an image depicting the chatbot response , and provide options for the user to interact with . They are very easy to code , and a lambda response can return a response card , that Lex will then display to the user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LexResponse.LexResponseCard card = new LexResponse.LexResponseCard();
List cardButtons = new List();
LexResponse.LexGenericAttachments cardGenericAttachments = new LexResponse.LexGenericAttachments();
card.Version = 1;
card.ContentType = "application/vnd.amazonaws.card.generic";
cardGenericAttachments.Title = "Instance count";
cardGenericAttachments.SubTitle = "Select the number of instances to launch";
cardButtons = new List()
{
 new LexResponse.LexButton(){Text = "1" , Value = "1"},
 new LexResponse.LexButton(){Text = "2" , Value = "2"},
 new LexResponse.LexButton(){Text = "3" , Value = "3"},
 new LexResponse.LexButton(){Text = "4" , Value = "4"},
 new LexResponse.LexButton(){Text = "5" , Value = "5"},
};
cardGenericAttachments.Buttons = cardButtons;
card.GenericAttachments = new List()
                                  { cardGenericAttachments };&amp;lt;span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"&amp;gt;&amp;lt;/span&amp;gt;                    return card;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;And the response cards look something like this on the final UI -&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yjqSb9y3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3uftbxb5xxa7dt719gp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yjqSb9y3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3uftbxb5xxa7dt719gp.png" alt="Image description" width="410" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 1 :&lt;/u&gt;&lt;/strong&gt; The Lex Test Chatbot console does not render response cards , however the slack UI displays them perfectly . This is also true for indentation or special characters . If you add "\n" to the message , the messages will not come in new lines in the Test Chatbot Console in AWS , however they will appear perfectly on new lines in Slack.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Limitations&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This is a pretty basic chatbot , and not at all production ready . Also , I personally don't think launching EC2 instances via a chatbot is a viable practical application of AWS Lex as there are too many variables involved.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An EC2 instance launch needs a key pair , that you can create/select and then download the private key of that key pair to later on login to the instance . You can not directly download the key pair from Slack while the conversation is going on . So , I have coded the lambda to create a new key pair with an auto-generated name , and saved it in a pre-configured AWS S3 bucket . The details will be communicated by the chatbot to the end user ,and then end user is expected to download that key from S3 , and use it to login to the instance.&lt;/li&gt;
&lt;li&gt;The instances will be created in a default VPC , using a default security group and a subnet (in the availability zone selected) . This can obviously be extended to select/create a VPC.&lt;/li&gt;
&lt;li&gt;Also , I could not properly configure Lex to inject slot values from the sample utterances to the custom slot type values . Say , for example I created a custom slot type with values - QA1 , QA2 , DEV1 , DEV2 . Then my expectation was that if user inputs QA3 , Lex will be able to correlate with the slot . However , in my case , this desired outcome was not coming.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bKFDXqf7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdutunw6p7ch6g261vpw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bKFDXqf7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdutunw6p7ch6g261vpw.png" alt="Image description" width="452" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;u&gt;Where can we go from here?&lt;/u&gt;&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Check out the video at &lt;a href="https://vimeo.com/292679817%C2%A0to"&gt;https://vimeo.com/292679817 to&lt;/a&gt; understand how the chatbot works . Granted , this bot is pretty straightforward , but it was a really nice learning lesson.&lt;/p&gt;

&lt;p&gt;Go ahead , play with the code or create something awesome from scratch using the same principles . Any as always , let me know if you have any feedback on the same.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>cloud</category>
      <category>coding</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
