<?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: Ayush</title>
    <description>The latest articles on DEV Community by Ayush (@heyay).</description>
    <link>https://dev.to/heyay</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%2F39091%2Fc5a91cc7-a2be-42c1-a1c0-659e838cce4b.jpg</url>
      <title>DEV Community: Ayush</title>
      <link>https://dev.to/heyay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/heyay"/>
    <language>en</language>
    <item>
      <title>Build a lo-fi cafe for your Discord Server in 5 minutes</title>
      <dc:creator>Ayush</dc:creator>
      <pubDate>Mon, 14 Jun 2021 13:03:36 +0000</pubDate>
      <link>https://dev.to/heyay/build-a-lo-fi-cafe-for-your-discord-server-in-5-minutes-1e4</link>
      <guid>https://dev.to/heyay/build-a-lo-fi-cafe-for-your-discord-server-in-5-minutes-1e4</guid>
      <description>&lt;p&gt;This blog was originally published at &lt;a href="//blog.ayush.contact"&gt;my personal website&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I decided to have a chill voice channel where we all could sit together (virtually) and co-work while listening to a lo-fi audio stream and maybe have some occasional talks too.&lt;/p&gt;

&lt;p&gt;We will be learning how to create a bot that automatically joins a voice channel whenever someone joins, starts broadcasting music &amp;amp; leaves after 5 minutes of inactivity. &lt;/p&gt;

&lt;p&gt;Do you need something cool like this in your own server?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/heyAyushh/lo-fi-discord-cafe" rel="noopener noreferrer"&gt;here's the github code&lt;/a&gt; with one click deploy button for heroku, ready.&lt;/p&gt;

&lt;p&gt;Less gooo 🥳&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Prerequisites&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;NodeJS LTS&lt;/a&gt;  and VScode or IDE of your choice.&lt;/li&gt;
&lt;li&gt;Pen&lt;/li&gt;
&lt;li&gt;Pineapple&lt;/li&gt;
&lt;li&gt;Apple&lt;/li&gt;
&lt;li&gt;pen&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Just kidding, let's setup the project now,&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt;
&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt; 
&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="nx"&gt;discord&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt; &lt;span class="nx"&gt;dotenv&lt;/span&gt; &lt;span class="nx"&gt;ytdl&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;core&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;discord&lt;/span&gt; &lt;span class="nx"&gt;lodash&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Go to &lt;a href="https://discord.com/developers/applications" rel="noopener noreferrer"&gt;Discord Developer Portal&lt;/a&gt; and create an application.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&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%2F9qlxw6ias53lvnf0ag1w.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%2F9qlxw6ias53lvnf0ag1w.png" alt="image"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Go to Bot in menu&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%2Fblog.ayush.contact%2Fstatic%2Fd7d6dca1c0c1b6e4228b9cf69f6fb19c%2F4665c%2F1.png%2F" 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%2Fblog.ayush.contact%2Fstatic%2Fd7d6dca1c0c1b6e4228b9cf69f6fb19c%2F4665c%2F1.png%2F" alt="./images/1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the Build-A-Bot section here &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%2Fblog.ayush.contact%2Fstatic%2F030846760472ed4560580ebe4fbd1579%2F0f41c%2F2.png%2F" 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%2Fblog.ayush.contact%2Fstatic%2F030846760472ed4560580ebe4fbd1579%2F0f41c%2F2.png%2F" alt="./images/2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add copy the token and store it in a file. call it .env&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in .env file&lt;/span&gt;
&lt;span class="nx"&gt;DISCORD_BOT_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Your Bot Token here&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now let's invite the bot to our server&lt;br&gt;&lt;br&gt;
Go to OAuth2 Page&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%2Fblog.ayush.contact%2Fstatic%2F322837a4e59c81950f6920b17288ff96%2Fdf43e%2F3.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%2Fblog.ayush.contact%2Fstatic%2F322837a4e59c81950f6920b17288ff96%2Fdf43e%2F3.png" alt="./images/3.png"&gt;&lt;/a&gt;&lt;br&gt;
Scroll down to OAuth2 url generator andselect the bot permission&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%2Fblog.ayush.contact%2Fstatic%2Fb5c48bc3248b505ad02a2643435e88a7%2Fcbcb6%2F4.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%2Fblog.ayush.contact%2Fstatic%2Fb5c48bc3248b505ad02a2643435e88a7%2Fcbcb6%2F4.png" alt="./images/4.png"&gt;&lt;/a&gt;&lt;br&gt;
Scroll more and select these bot permission, &lt;br&gt;
It allows the bot to connect, speak , viewchannels, and use voice activity &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%2Fblog.ayush.contact%2Fstatic%2Fc7242f8f9e0147cf8492d02531acdd53%2Ff9260%2F5.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%2Fblog.ayush.contact%2Fstatic%2Fc7242f8f9e0147cf8492d02531acdd53%2Ff9260%2F5.png" alt="https://blog.ayush.contact/static/c7242f8f9e0147cf8492d02531acdd53/f9260/5.png"&gt;&lt;/a&gt;&lt;br&gt;
After selecting the appropriate permissions, click the 'copy' button above the permissions. That will copy a URL which can be used to add the bot to a server.&lt;br&gt;&lt;br&gt;
Paste the URL into your browser, choose a server to invite the bot to, and click “Authorize”.&lt;br&gt;&lt;br&gt;
To add the bot, your account needs "ManageServer" permissions.&lt;br&gt;&lt;br&gt;
Now that you've created the bot user, we'll start writing the NodeJS code for the bot.  &lt;/p&gt;
&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's the file and folder structure →&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;—&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;—&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;—&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;
&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="err"&gt;—&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;gitignore&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We don't want to push Petabytes of node modules to GitHub. so, we'll create a .gitignore file.&lt;br&gt;
Whatever we add inside here will be ignored by git and that's what we want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in .gitignore&lt;/span&gt;

&lt;span class="nx"&gt;node_modules&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside .env file you should have the bot token, If you don't see the setup section once again.&lt;br&gt;
You skippin' lines bro.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-" rel="noopener noreferrer"&gt;Copy your github server id&lt;/a&gt; and save it in your .env file.&lt;br&gt;
Also create a voice channel in your discord server, add the exact channel name in .env file. (avoid using ' ' in discord channel name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// in ./.env&lt;/span&gt;

&lt;span class="nx"&gt;DISCORD_BOT_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Your Bot Token here&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;DISCORD_GUILD_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;Your discord server id here&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;DISCORD_CHANNEL_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;lofi-channel-🎵&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="nx"&gt;VOICE_URLS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;add more than two urls, seperated by comma&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file called client.js and add these lines there.&lt;br&gt;
line number one implies that we are requiring dependency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ./client&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Discord&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;discord.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dotenv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;config&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;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Discord&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DISCORD_BOT_TOKEN&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;line number 2 means that we want to setup all variables,&lt;br&gt;
inside .env file to the environment variables.&lt;br&gt;
line number 6 and 8 wants the bot to login and then export it,&lt;br&gt;
so we can use it inside any file now.&lt;/p&gt;

&lt;p&gt;Now that we have our client ready, &lt;br&gt;
Let's code the Bot.&lt;/p&gt;

&lt;p&gt;Create a file index.js and require client.js.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ./index&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./client&lt;/span&gt;&lt;span class="dl"&gt;'&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;ytdl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ytdl-core-discord&lt;/span&gt;&lt;span class="dl"&gt;'&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;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash&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;This line means whenever the bot is ready (after login) announce it in console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ./index&lt;/span&gt;

&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ready&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &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="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="s2"&gt;`Bot client Logged in as &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tag&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now after the bot is ready, we will react on all the events that discord sends whenever there's a voice activity using the line below, &lt;em&gt;(voiceStateUpdate)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ./index&lt;/span&gt;

&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;voiceStateUpdate&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;lofiCafe&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;lofiCafe is a function that will handle this event, let's declare the function above the &lt;em&gt;voiceStateUpdate&lt;/em&gt; event handler.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lofiCafe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oldMember&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newMember&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;guild_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DISCORD_GUILD_ID&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;channel_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DISCORD_CHANNEL_NAME&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;VOICE_URLS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VOICE_URLS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// find the voice channel &lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;voiceChannel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;guild&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channels&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ch&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;ch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;channel_name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newUserChannel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newMember&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channelID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;oldUserChannel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;oldMember&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channelID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// a function to play audio in loop&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;play&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;play&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;ytdl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;VOICE_URLS&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;opus&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;highWaterMark&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.7&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;// When the song is finished, play it again.&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;finish&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;play&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;Guild&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;guilds&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;guild_id&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;botUserId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&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;discordBotUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;Guild&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;members&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;botUserId&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;newUserChannel&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;voiceChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// if a user joins lo-fi music channel &lt;/span&gt;

    &lt;span class="c1"&gt;// if bot not in voice channel and users connected to the channel&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;discordBotUser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;voice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channel&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;voiceChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;members&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// play music&lt;/span&gt;
      &lt;span class="nx"&gt;voiceChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;play&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oldMember&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;oldMember&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channel&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;oldMember&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;members&lt;/span&gt;
    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oldMember&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;members&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;oldUserChannel&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;voiceChannel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;
    &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;discordBotUser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;voice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="c1"&gt;// if there is only one member in the channel (bot itself)&lt;/span&gt;
        &lt;span class="c1"&gt;// leave the server after five minutes&lt;/span&gt;

    &lt;span class="nf"&gt;setTimeout&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="c1"&gt;// wait five minutes&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="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;oldMember&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;members&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
                    &lt;span class="c1"&gt;// if there's still 1 member,&lt;/span&gt;
        &lt;span class="nx"&gt;oldMember&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;leave&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="mi"&gt;60000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// leave in 1 minute&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;After writing these files, your client.js and index.js files should look exactly &lt;a href="https://github.com/heyAyushh/lo-fi-discord-cafe" rel="noopener noreferrer"&gt;like this repo&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://devcenter.heroku.com/articles/heroku-cli" rel="noopener noreferrer"&gt;Install Heroku CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Login to your heroku account in cli&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;heroku&lt;/span&gt; &lt;span class="nx"&gt;login&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a new app&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;heroku&lt;/span&gt; &lt;span class="nx"&gt;create&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Push your local git repository to heroku&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;git&lt;/span&gt; &lt;span class="nx"&gt;push&lt;/span&gt; &lt;span class="nx"&gt;heroku&lt;/span&gt; &lt;span class="nx"&gt;main&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go into your heroku app settings and add the config vars, like you added in .env .&lt;br&gt;
Just because .env file won't be pushed to GitHub.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Enjoy 🎉
&lt;/h2&gt;

&lt;p&gt;Have your friends sit and co-work in your new lo-fi cafe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Acknowledgements&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
icon: Cafe by Andrejs Kirma from the Noun Project&lt;br&gt;&lt;br&gt;
background: Jack Berry on Unsplash&lt;/p&gt;

</description>
      <category>discord</category>
      <category>node</category>
      <category>voice</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Use Immersive Reader to increase Reading Comprehension using Azure  Function and Cognitive Services</title>
      <dc:creator>Ayush</dc:creator>
      <pubDate>Fri, 10 Apr 2020 18:38:17 +0000</pubDate>
      <link>https://dev.to/heyayush/use-immersive-reader-to-increase-reading-comprehension-using-azure-function-and-cognitive-services-36j4</link>
      <guid>https://dev.to/heyayush/use-immersive-reader-to-increase-reading-comprehension-using-azure-function-and-cognitive-services-36j4</guid>
      <description>&lt;h3&gt;
  
  
  Use Immersive Reader to increase Reading Comprehension using Azure Function and Cognitive Services
&lt;/h3&gt;

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

&lt;p&gt;Immersive Reader is a tool that implements proven techniques to improve reading comprehension for emerging readers, language learners, and people with learning differences. The Immersive Reader is designed to make reading more accessible for everyone. The Immersive Reader&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shows content in a minimal reading view&lt;/li&gt;
&lt;li&gt;Displays pictures of commonly used words&lt;/li&gt;
&lt;li&gt;Highlights nouns, verbs, adjectives, and adverbs&lt;/li&gt;
&lt;li&gt;Reads your content out loud to you&lt;/li&gt;
&lt;li&gt;Translates your content into another language&lt;/li&gt;
&lt;li&gt;Breaks down words into syllables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Azure Functions is a solution for easily running small pieces of code, or “functions,” in the cloud. It’s a serverless offering from Microsoft Azure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/heyAyushh/ImmersiveFunction/raw/master/demo.gif"&gt;https://github.com/heyAyushh/ImmersiveFunction/raw/master/demo.gif&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;try the Demo &lt;a href="https://immersivefn.now.sh/"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blog post we will see how to enable Immersive reader for your frontend.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn how **&lt;a href="http://functions.azure.com/"&gt;Azure Functions**&lt;/a&gt; can access token from Azure portal on your web client’s behalf.&lt;/li&gt;
&lt;li&gt;Add immersive reader to any website.&lt;/li&gt;
&lt;li&gt;Enable images pls.&lt;/li&gt;
&lt;li&gt;Working code sample is &lt;a href="https://github.com/heyAyushh/ImmersiveFunction"&gt;available here&lt;/a&gt; -&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Prerequisites 🥚 -
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://nodejs.org/"&gt;NodeJS &amp;lt; 10+&lt;/a&gt; &amp;amp; &lt;a href="http://npmjs.com/"&gt;npm&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://portal.azure.com/"&gt;Azure&lt;/a&gt; Account — Get it Free, &lt;a href="https://blog.heyayush.live/get-100dollar-Azure-credits-for-Students-without-Credit-card"&gt;for Students&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-us/free/"&gt;for Professionals&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://code.visualstudio.com/"&gt;VSCode&lt;/a&gt; with &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions"&gt;Azure Functions Extension installed&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Go get your secrets first 🍕
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go &lt;a href="https://docs.microsoft.com/en-us/azure/cognitive-services/immersive-reader/how-to-create-immersive-reader"&gt;this page&lt;/a&gt; and Execute a powershell script&lt;/li&gt;
&lt;li&gt;Save the &lt;strong&gt;output&lt;/strong&gt; as those are the secrets.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zxpPJfCP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AITtPw8LcbJicztWFvmPbUw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zxpPJfCP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AITtPw8LcbJicztWFvmPbUw.gif" alt=""&gt;&lt;/a&gt;&lt;em&gt;(Alt-text: Getting credentials for the project)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It actually executes a powershell script which deploys immersive reader cognitive service, sets up azure active directory for your app and returns essential secrets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let’s Get Going 🍳
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Our first step will be installing Azure function core tools in local system so that we can test it.
To do that we need to instruct npm to install and enable it for us.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TWmjYpDR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Apuxk4NUbm-ioGfw5SoTbKA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TWmjYpDR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2Apuxk4NUbm-ioGfw5SoTbKA.gif" alt=""&gt;&lt;/a&gt;&lt;em&gt;(Alt-text: Just open terminal and install azure function core tools.)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g azure-functions-core-tools@3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Initialise a function App. This will be a folder where azure functions will be created and stored.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YEnaa5e3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AQ4F93Z7-0uT6vgNL9iPblw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YEnaa5e3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AQ4F93Z7-0uT6vgNL9iPblw.gif" alt=""&gt;&lt;/a&gt;(&lt;em&gt;Alt-text: Just open terminal and install azure function core tools.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Execute&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func init APPNAME
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and choose node and JavaScript worker. You’ll see a folder generated with your APPNAME and consists host.json file. We will call this location as root of the directory.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Let’s create a “HTTP Trigger” function now. This will be a serverless function endpoint which authenticates and passes us the token required to access immersive reader resource. “HTTP Trigger” here means the function to be triggered (Start execution) by HTTP requests.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rSbl7SFo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AqGqH6pQ6F5rj8TMs8xjwZA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rSbl7SFo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AqGqH6pQ6F5rj8TMs8xjwZA.gif" alt=""&gt;&lt;/a&gt;(&lt;em&gt;Alt-text: Create a “HTTP Trigger” Azure function for our App)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func new --name GetTokenAndSubdomain --template “HTTP trigger”
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Meanwhile you will see a sub-folder generated after this execution with files index.js and function.json.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Dependencies to be used in our app.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fcVwPKGR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ADYj6oZMILahhl7Qqv4WWhw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fcVwPKGR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ADYj6oZMILahhl7Qqv4WWhw.png" alt=""&gt;&lt;/a&gt;(&lt;em&gt;Alt-text: Installed axios dependency using npm)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -s axios dotenv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;axios here is a js library that will help us with requesting the immersive service AD for token and dotenv will be used to load tokens and Secrets from .env file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create .env file to add secrets that can be accessed by our function. We have to load our secrets which we obtained earlier by the powershell script.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TENANT\_ID={YOUR\_TENANT\_ID} 
CLIENT\_ID={YOUR\_CLIENT\_ID} 
CLIENT\_SECRET={YOUR\_CLIENT\_SECRET} 
SUBDOMAIN={YOUR\_SUBDOMAIN}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Copy the code below and paste it into index.js of our created function in step 3.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KcpjPeAK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AgePn7rmk7aC733LB4_IuQw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KcpjPeAK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AgePn7rmk7aC733LB4_IuQw.gif" alt=""&gt;&lt;/a&gt;(&lt;em&gt;Alt-text: Paste the code below in Index.js of /GetTokenAndSubdomain function)&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require('dotenv').config();
const axios = require('axios').default;

module.exports = async function(context, req) {
try {
const tokenResponse = await axios.post(
`https://login.windows.net/${process.env.TENANT_ID}/oauth2/token`,
new URLSearchParams({
grant\_type: 'client\_credentials',
client\_id: process.env.CLIENT\_ID,
client\_secret: process.env.CLIENT\_SECRET,
resource: 'https://cognitiveservices.azure.com/'
}).toString(),
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
);
var tokenResultParsed = tokenResponse.data;
context.res = {
status: 200,
body: { token: tokenResultParsed.access\_token, subdomain: process.env.SUBDOMAIN }
};
} catch (err) {
console.log(err);
context.res = {
status: 500,
error: 'Unable to acquire Azure AD token. Check the debugger for more information.'
};
}
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This code is a simple Client Credentials OAuth2 handler for our function to grab token from Azure, It submits a post request to our Active Directory with our Client_ID and Client_Secret.&lt;/p&gt;

&lt;p&gt;Line 1, Loads all the variables from .env file to actual processing environment. We are using them in our code with prefix process.env.&lt;/p&gt;

&lt;p&gt;Line 6 starts the post request execution and it saves the data to tokenResponse . The token is extracted from the data JSON object using tokenResponse.data and stored into tokenResultParsed . context.res now returns the token to the frontend client or whoever hitting our endpoint.&lt;/p&gt;

&lt;p&gt;You can go to root directory of the Function App and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func host start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which will start a local development server on port 7071.&lt;/p&gt;

&lt;p&gt;Try accessing &lt;a href="http://localhost:7071/api/GetTokenAndSubdomain"&gt;localhost:7071/api/GetTokenAndSubdomain&lt;/a&gt;in your browser and you'll see a token render on page. If you do get a token, "Congrats! you've followed the blog correctly". If not, Please go back and check for some points that you might have missed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Let’s Deploy our Function app with VSCode and azure function extension. Moreover we also need to copy the azure function url with authorization code in order to have it accessed by client.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hF_1TThh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/900/1%2A_WIAoZLi5qbabi7wu3Co_g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hF_1TThh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/900/1%2A_WIAoZLi5qbabi7wu3Co_g.gif" alt=""&gt;&lt;/a&gt;(&lt;em&gt;Alt-text: Deploy Azure function from VSCode and copy the function url in Azure portal)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;8 . Now it’s time to embed Immersive reader js sdk in your HTML . Developing whole frontend is again out of the scope for this blog, however I'll describe how to get your sample html up and running. Grab the sample HTML site from &lt;a href="https://github.com/heyAyushh/ImmersiveFunction/blob/master/web/index.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;line no. 10. loads the immersive reader Javascript sdk&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script
    src="https://contentstorage.onenote.office.net/onenoteltir/immersivereadersdk/immersive-reader-sdk.1.0.0.js"&amp;gt;
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;line 25 has a button with class immersive-reader-button Which on click handles function on line 75. handleLaunchImmersiveReader() Handles the authentication by executing the function getTokenAndSubdomainAsync() on line 55.&lt;/p&gt;

&lt;p&gt;getTokenAndSubdomainAsync() sends a get request to our function with url on line 58. we need to paste URL obtained in step 7 here so that our client can access it. line 82 and 83 extracts token and subdomain which is passed in ImmersiveReader.launchAsync() .&lt;/p&gt;

&lt;p&gt;line 87 has the extracts title from #ir-title class used in 26, Similarly content data which also needs to be passed in ImmersiveReader.launchAsync() is passed from #ir-content html class on line 27. Notice how the lang="en-us" is used to specify the language and dir="rtl"is used to specify rtl languages.&lt;/p&gt;

&lt;p&gt;ImmersiveReader.launchAsync() Launches a iframe with beautiful immersive reader.&lt;br&gt;&lt;br&gt;
You can deploy the sample anywhere you like, ex. GitHub pages (in a private repo) or &lt;a href="http://zeit.co/"&gt;zeit.co&lt;/a&gt;&lt;br&gt;&lt;br&gt;
learn how to deploy site in 15s with zeit &lt;a href="http://bit.ly/15secZEIT"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Point 🎯: The GetTokenAndSubdomain API endpoint should be secured behind some form of authentication (for example,&lt;/em&gt; &lt;a href="https://oauth.net/2/"&gt;&lt;em&gt;OAuth&lt;/em&gt;&lt;/a&gt;&lt;em&gt;) to prevent unauthorized users from obtaining tokens to use against your Immersive Reader service and billing; that work is beyond the scope of this quickstart.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can access the &lt;a href="https://docs.microsoft.com/en-us/azure/cognitive-services/immersive-reader/reference"&gt;JS SDK Refrence here&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Oops, we have a problem after deployment of frontend. Probably that’s a CORS issue.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--93j91gEl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ASBlvNv5nSmtRGMNjVYJqPQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--93j91gEl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ASBlvNv5nSmtRGMNjVYJqPQ.jpeg" alt=""&gt;&lt;/a&gt;(&lt;em&gt;Alt-text:Cross Origin Resource sharing issue)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is why the frontend can’t access our function because Azure has some security enabled by default. Cross Origin Resource Sharing is a technique that permits resource sharing between scripts running on a browser client and resources from a different origin.&lt;/p&gt;

&lt;p&gt;Let’s disable CORS just for our frontend so that it can have access to our function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hF_1TThh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/900/1%2A_WIAoZLi5qbabi7wu3Co_g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hF_1TThh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/900/1%2A_WIAoZLi5qbabi7wu3Co_g.gif" alt=""&gt;&lt;/a&gt;(&lt;em&gt;Alt-text: Solving Cross Origin Resource sharing issue from Azure portal)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;10 . Stay at Home&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/b664fc6fad92dabe727aa7af8b6bccbe/href"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/b664fc6fad92dabe727aa7af8b6bccbe/href"&gt;https://medium.com/media/b664fc6fad92dabe727aa7af8b6bccbe/href&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Thanks for reading
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/718ceaa86f20588648c8eb4f867151a7/href"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/718ceaa86f20588648c8eb4f867151a7/href"&gt;https://medium.com/media/718ceaa86f20588648c8eb4f867151a7/href&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me know the feedback.&lt;br&gt;&lt;br&gt;
Follow / Subscribe for more awesome azure content.&lt;/p&gt;




</description>
      <category>node</category>
      <category>azurefunctions</category>
      <category>cognitiveservices</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Deploy your frontend in 15 seconds with Zeit Now</title>
      <dc:creator>Ayush</dc:creator>
      <pubDate>Fri, 10 Apr 2020 00:22:11 +0000</pubDate>
      <link>https://dev.to/heyay/deploy-your-frontend-in-15-seconds-with-zeit-now-1b60</link>
      <guid>https://dev.to/heyay/deploy-your-frontend-in-15-seconds-with-zeit-now-1b60</guid>
      <description>&lt;p&gt;When I started deploying my frontends and stactic sites on zeit, I've never looked back. Zeit offers fast and zero config deployments and is my go to platform for frontend deployment.&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%2Fblog.heyayush.live%2Fstatic%2F3a375e8c2f61cea65eb7ac1c1c4b90dc%2Febf7c%2Fstaticzeit.webp" 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%2Fblog.heyayush.live%2Fstatic%2F3a375e8c2f61cea65eb7ac1c1c4b90dc%2Febf7c%2Fstaticzeit.webp" alt="staticzeit.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Alt-Text- &lt;a href="https://zeit.co" rel="noopener noreferrer"&gt;zeit.co&lt;/a&gt; homepage, Develop, Preview, Ship)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why Zeit?&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Free for personal use&lt;/li&gt;
&lt;li&gt;Instant static deploys&lt;/li&gt;
&lt;li&gt;Zero Config Required&lt;/li&gt;
&lt;li&gt;Collaborative&lt;/li&gt;
&lt;li&gt;Automatic SSL&lt;/li&gt;
&lt;li&gt;Blazing Fast&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Requirements&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;Node.JS&lt;/a&gt; and npm / yarn&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Let's go
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create a Account on &lt;a href="https://zeit.co" rel="noopener noreferrer"&gt;zeit.co&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tip : Go to &lt;a href="https://zeit.co" rel="noopener noreferrer"&gt;zeit.co&lt;/a&gt; on your phone and add the page to home screen for instant experience on mobile.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Go to your Terminal and Install &lt;strong&gt;Now&lt;/strong&gt; command line tool.&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%2Fblog.heyayush.live%2Fstatic%2F7e31946746dfa5fb1186e4aac8e94017%2F7d801%2Fzietnow.webp" 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%2Fblog.heyayush.live%2Fstatic%2F7e31946746dfa5fb1186e4aac8e94017%2F7d801%2Fzietnow.webp" alt="zietnow.jpg"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Alt-Text- &lt;a href="https://zeit.co" rel="noopener noreferrer"&gt;zeit.co&lt;/a&gt; homepage, download zeit CLI)&lt;/em&gt;&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -g now
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is &lt;strong&gt;now&lt;/strong&gt;? &lt;br&gt;
Now command-line interface enables instant cloud deployment and local development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigate to your project and deploy files.&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%2Fblog.heyayush.live%2Fb349dedd9b3ecca15da91e2ca2c67fa0%2Fzeitnow.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.heyayush.live%2Fb349dedd9b3ecca15da91e2ca2c67fa0%2Fzeitnow.gif" alt="zeitnow.gif"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;(Alt-Text- Me executing all steps)&lt;/em&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Make sure there is &lt;code&gt;index.html&lt;/code&gt; in your folder. &lt;/li&gt;
&lt;li&gt;Open your terminal at root of the folder you want to deploy.&lt;/li&gt;
&lt;li&gt;execute &lt;code&gt;now login&lt;/code&gt; to authenticate your cli with your id.&lt;/li&gt;
&lt;li&gt;type &lt;code&gt;now&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;That's it; Yep just that; all you need is &lt;code&gt;now&lt;/code&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>webdev</category>
      <category>zeit</category>
    </item>
    <item>
      <title>How to Build Google Actions using Azure Functions</title>
      <dc:creator>Ayush</dc:creator>
      <pubDate>Wed, 18 Sep 2019 13:40:46 +0000</pubDate>
      <link>https://dev.to/heyay/how-to-build-google-actions-using-azure-functions-34d1</link>
      <guid>https://dev.to/heyay/how-to-build-google-actions-using-azure-functions-34d1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is part of &lt;a href="https://dev.to/azure/serverless-september-content-collection-593p-temp-slug-4543319?preview=f13be4da8a729201c3ed6f23d46efb13851b6800b723ddb762f89e410cdc057436b66afc9bdc49068f5fd8afddc5fb72575f4035266fadea4345a207"&gt;#ServerlessSeptember&lt;/a&gt;. You'll find other helpful articles, detailed tutorials, and videos in this all-things-Serverless content collection. New articles are published every day — that's right, every day — from community members and cloud advocates in the month of September. &lt;/p&gt;

&lt;p&gt;Find out more about how Microsoft Azure enables your Serverless functions at &lt;a href="https://docs.microsoft.com/azure/azure-functions/?WT.mc_id=servsept_devto-blog-cxa"&gt;https://docs.microsoft.com/azure/azure-functions/&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  I’m going to show you how to use Azure functions to build an Action for Google Assistant.
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;More precisely we will look at how we can do fulfillment by webhook in Dialogflow, using a backend by Azure Functions.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;TL;DR&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="http://actions.google.com"&gt;Google Actions Console&lt;/a&gt; and create a new project.&lt;/li&gt;
&lt;li&gt; Setup Invocation &lt;/li&gt;
&lt;li&gt;Build actions -&amp;gt; Integrate actions from dialogflow -&amp;gt; go to dialogflow&lt;/li&gt;
&lt;li&gt;Set default welcome intent -&amp;gt; enable webhook call
Set default fallback intent -&amp;gt; enable webhook call&lt;/li&gt;
&lt;li&gt;for welcome, Store sessionID &amp;amp; word, generate a jumbled word from dictionary, send it as response.&lt;/li&gt;
&lt;li&gt;for fallback, look for same session id, return the word in response.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a story about how I built my first Google Action. You might be asking yourself,&lt;em&gt;“what is a Google Action?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qEfWnG6V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/12000/0%2AJyROyT2IkvhRTSO8" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qEfWnG6V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/12000/0%2AJyROyT2IkvhRTSO8" alt="Photo by [Kevin Bhagat](https://unsplash.com/@kevnbhagat?utm_source=medium&amp;amp;utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral)"&gt;&lt;/a&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@kevnbhagat?utm_source=medium&amp;amp;utm_medium=referral"&gt;Kevin Bhagat&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Actions on &lt;strong&gt;Google&lt;/strong&gt; is a platform allowing developers to create software applications known as “Actions” that extend the functionality of the &lt;strong&gt;&lt;em&gt;Google Assistant&lt;/em&gt;&lt;/strong&gt;.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Google Assistant&lt;/strong&gt; is an &lt;em&gt;artificial intelligence&lt;/em&gt;-powered &lt;em&gt;virtual assistant&lt;/em&gt; developed by Google that is primarily available on mobile and smart home devices. Google Assistant can Order food, Book Cabs by having Actions enabled by Zomato and Uber respectively.&lt;/p&gt;

&lt;p&gt;Some individuals (like my grandparents, some doctors, and the differently abled) find that using their voice, rather than keyboards, makes it easier to get day-to-day tasks done. There have &lt;a href="https://www.cnbc.com/2019/04/18/voice-technology-will-replace-keyboards-in-five-years-vc-investor.html"&gt;even been predictions&lt;/a&gt; that voice will replace keyboards on the workstations of the future! (But how will we code?!)&lt;/p&gt;

&lt;p&gt;One of the benefits of building an app on a voice platform (like Google Assistant) is that it helps bring inclusiveness in &lt;a href="https://assistant.google.com/explore"&gt;your Product&lt;/a&gt;, making sure everyone gets the same benefits of the changes you believe in.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;What’s word Jumblr?&lt;/em&gt;
&lt;/h2&gt;

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

&lt;p&gt;My app &lt;a href="https://assistant.google.com/u/2/services/a/uid/0000002f793261ed"&gt;word Jumblr&lt;/a&gt; is a game that gives you a jumbled word to unscramble.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ryXhCGxV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2160/1%2AlGtYG-200ax2TMvVZsQv0w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ryXhCGxV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2160/1%2AlGtYG-200ax2TMvVZsQv0w.jpeg" alt="For people with other devices — ex. Windows Phone"&gt;&lt;/a&gt;&lt;em&gt;For people with other devices — ex. Windows Phone&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And, if you have an &lt;em&gt;Android&lt;/em&gt; or &lt;em&gt;Apple&lt;/em&gt; device you can install google assistant from your App store and you’re good to go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Also, you can say to Google Assistant,
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;“ Hey Google, Talk to word Jumblr”.&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;Let’s understand what happens when we invoke word Jumblr.&lt;/p&gt;

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

&lt;p&gt;Whenever a user says the phrase (An invocation to the Action), it triggers the Action and that triggers the Azure Function backend to handle the Request sent by the User in the phrase. &lt;/p&gt;

&lt;p&gt;Example — &lt;br&gt;
It might be “&lt;em&gt;Book me a cab from **Uber&lt;/em&gt;*” *which will invoke uber google action listed in Google Assistant directory and it will invoke their backend service.&lt;/p&gt;

&lt;p&gt;For us it’s “&lt;em&gt;Talk to **word Jumblr&lt;/em&gt;**” what triggers our google action and then checks into dialogflow and then fowards request to our Backend Azure functions.&lt;/p&gt;

&lt;p&gt;Here’s what you’ll need to get started: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;A Google account (You don’t need a Google Assistant device, you can test in the Actions portal)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;a href="https://azure.microsoft.com/free/?wt.mc_id=heroesvue-github-jopapa&amp;amp;WT.mc_id=azuremedium-blog-chwarren"&gt;Microsoft Azure account&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Let’s get the party Started!
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Step I&lt;/em&gt;&lt;/strong&gt; —* Setup Google Actions*
&lt;/h3&gt;

&lt;p&gt;Go to &lt;a href="http://actions.google.com"&gt;Google Actions Console&lt;/a&gt; and create a new project.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DiwIMkoZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2880/1%2AA9gnN0C-iUBE2Fe0iEqztw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DiwIMkoZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2880/1%2AA9gnN0C-iUBE2Fe0iEqztw.png" alt="Actions Portal will suggest some Templates — Choose Conversational"&gt;&lt;/a&gt;&lt;em&gt;Actions Portal will suggest some Templates — Choose Conversational&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Choose Conversational as I’ll be guiding how to setup intents and webhooks on which Customized experience will suit us best for this project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hmtAEDuJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AtHrqL3qb0dr4hhuDu9vXhg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hmtAEDuJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AtHrqL3qb0dr4hhuDu9vXhg.png" alt="Choose Conversational down below the Menu."&gt;&lt;/a&gt;&lt;em&gt;Choose Conversational down below the Menu.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setup invocation of the project — Invocation sets up how people will be using phrases to trigger our google action.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x-8Ltz45--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2880/1%2Apr-_lDGPbUdYpXktsBIJqQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x-8Ltz45--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2880/1%2Apr-_lDGPbUdYpXktsBIJqQ.png" alt="Hey Dr. Music, can you play some good vibes?"&gt;&lt;/a&gt;&lt;em&gt;Hey Dr. Music, can you play some good vibes?&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build actions -&amp;gt; Integrate actions from dialogflow -&amp;gt; go to dialogflow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/YRzjXXj3JLWMIhTWQW/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/YRzjXXj3JLWMIhTWQW/giphy.gif" alt="Setup Actions and Intents — DIALOGFLOW"&gt;&lt;/a&gt;&lt;em&gt;Setup Actions and Intents — DIALOGFLOW&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step II. Dialogflow
&lt;/h2&gt;

&lt;p&gt;Dialogflow is a Google-owned developer of human–computer interaction technologies based on natural language conversations.&lt;/p&gt;

&lt;p&gt;We will be dealing with Intents here — &lt;br&gt;
The Merriam-Webster dictionary gives the meaning as “the state of mind with which an act is done.” Tim Hallbom.&lt;/p&gt;

&lt;p&gt;This means what Activity, or Events, or particular sets of message convey to do- Here, in** Welcome intent **— I want them to send request to my Azure function which will respond with a jumbled word.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zhv9a0Zx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2154/1%2AwEL71OPQtuXtrW7_MJ323A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zhv9a0Zx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2154/1%2AwEL71OPQtuXtrW7_MJ323A.png" alt="**Set default welcome intent**"&gt;&lt;/a&gt;** Set default welcome intent**&lt;/p&gt;

&lt;p&gt;Set up events — &lt;br&gt;
&lt;em&gt;Welcome by Dialogflow&lt;/em&gt;, &lt;em&gt;Google Assistant&lt;/em&gt; Welcome and &lt;em&gt;Play game&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes a user can ask a implicit invocation &lt;br&gt;
(instead of saying “Talk to word jumblr” he can say “play a game”)&lt;br&gt;
and google action can automatically invoke word jumblr.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o_3N47Zo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AQ2dkyV4wohKCVF0DGLpbbw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o_3N47Zo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AQ2dkyV4wohKCVF0DGLpbbw.png" alt="Setting Events which invoke Welcome intent"&gt;&lt;/a&gt;&lt;em&gt;Setting Events which invoke Welcome intent&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now we need to train on what messages/phrases our intent will be same which is Welcome intent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rjUvPvyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ANzLhyWgOWI-W1gPmkdsP-Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rjUvPvyI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2ANzLhyWgOWI-W1gPmkdsP-Q.png" alt="Here are some training phrases"&gt;&lt;/a&gt;&lt;em&gt;Here are some training phrases&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Action and Parameters simplifies on the backend what intent action invocated our Azure function. If this goes up don’t worry we will be covering it later in &lt;strong&gt;Step III&lt;/strong&gt;.&lt;/p&gt;

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

&lt;p&gt;Last step would be turn on fulfilment and Enable webhook, so that whenever this event occurs it sends the request to our azure function URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ow-20ztB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AXhfFcmSm6sm5-pE9Mq1XZw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ow-20ztB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AXhfFcmSm6sm5-pE9Mq1XZw.png" alt="Enable Webhook"&gt;&lt;/a&gt;&lt;em&gt;Enable Webhook&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We need to do the same for &lt;strong&gt;Default Fallback Intent&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set action to unknown. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--96sgpPTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AOl78qaaGVHgAbJsg1vZoKA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--96sgpPTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2000/1%2AOl78qaaGVHgAbJsg1vZoKA.png" alt="action of the intent"&gt;&lt;/a&gt;&lt;em&gt;action of the intent&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next go to Fulfilment and enable webhook.&lt;/p&gt;

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

&lt;p&gt;So we need a URL in webhook and that’s yet to happen.&lt;br&gt;
Hold on to this tab and open a new one with &lt;strong&gt;&lt;em&gt;portal.azure.com&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now i know you are like hey ayush, stop this choo choo train and explain why are we setting intents and fulfillments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/NGSbD5vI6lUvC/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/NGSbD5vI6lUvC/giphy.gif" alt="Choo-Choo Train"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Choo-Choo Train&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here we go with another diagram — &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jXvUtBy4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2924/1%2Ay6e6EJFX4xnwPInEZGfjLQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jXvUtBy4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2924/1%2Ay6e6EJFX4xnwPInEZGfjLQ.png" alt="Step after Invoking Welcome intent"&gt;&lt;/a&gt;&lt;em&gt;Step after Invoking Welcome intent&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When someone says, “&lt;em&gt;Talk to word jumblr&lt;/em&gt;”, “&lt;em&gt;hi&lt;/em&gt;”, “&lt;em&gt;hello&lt;/em&gt;” etc. &lt;br&gt;
A request is sent to our App with a sessionID and action of the welcome intent which is ‘&lt;em&gt;input.welcome’&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;have a look &lt;a href="https://dialogflow.com/docs/fulfillment/how-it-works"&gt;here&lt;/a&gt; at &lt;a href="https://dialogflow.com/docs/fulfillment/how-it-works"&gt;dialogflow documentation &lt;/a&gt;to know what’s under the hood.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zw7_GaoI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2676/1%2ArhFDmLhlyQC8vza-3TfzBA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zw7_GaoI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/2676/1%2ArhFDmLhlyQC8vza-3TfzBA.png" alt="Steps after fallback intent"&gt;&lt;/a&gt;&lt;em&gt;Steps after fallback intent&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So what’s fallback and Why do we need it here?&lt;br&gt;
Whenever a user attempts to solve a word, our app needs an intent for that. Now the attempt can be any word, like anything, even “quit” or “bye” or something ambiguous, so this way having no intent and letting it fall into fallback might help us here.&lt;/p&gt;

&lt;p&gt;A request is sent to our App with a sessionID and action of the fallback intent which is ‘&lt;em&gt;input.unknown’.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step III. Preparing Azure Functions.
&lt;/h2&gt;

&lt;p&gt;Hope you opened Azure Portal in new tab coz it’s gonna get schwifty here — &lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a function app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose a HTTP trigger function, name it invoke&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create another HTTP trigger function and name it HeyJumblr&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But you’ll be like hey What’s Azure function?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Azure&lt;/strong&gt; &lt;strong&gt;Functions&lt;/strong&gt; is an event driven, compute-on-demand experience that extends the existing &lt;strong&gt;Azure&lt;/strong&gt; application platform with capabilities to implement code triggered by events occurring in virtually. &lt;/p&gt;

&lt;p&gt;So what’s going in Function I (invoke)— &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;function I&lt;/strong&gt;

&lt;p&gt;Dialogflow invokes our Azure function (function app 1) with the JSON request below — &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--roE-v_ba--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/4096/1%2AKxVQ3Mi-ZHedtPLn1HMf-g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--roE-v_ba--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/4096/1%2AKxVQ3Mi-ZHedtPLn1HMf-g.png" alt="Dialogflow request JSON"&gt;&lt;/a&gt;&lt;em&gt;Dialogflow request JSON&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the first function we just split the whole session string and get it replaced by the just the session id, reduce clutter maybe.&lt;br&gt;
And then we pass the request to our heyjumblr (second az func) with the same session ID.&lt;/p&gt;

&lt;p&gt;Notice what the &lt;em&gt;queryResult.action&lt;/em&gt; have for us, it’s *“input.welcome”.&lt;br&gt;
*That’s how we will recognise what intent called our function, whether someone said hi, or tried to guess a word.&lt;/p&gt;

&lt;p&gt;But why do we need session ID?&lt;/p&gt;

&lt;p&gt;Look here in the next function heyjumblr, this does the real work.&lt;br&gt;
His work involves- &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Getting a word from Dictionary ( I used “random-word” npm module)&lt;/li&gt;
&lt;li&gt;Jumbling the word &lt;/li&gt;
&lt;li&gt;Sending the word to dialogflow back&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But here remains a more crucial step, when someone attempts to solve the word ( when we get “input.unknown” ) how do we know what word we gave the human to solve?&lt;/p&gt;

&lt;p&gt;The solution here is pretty simple, storing the sessionID along with the word in a database so that we can recall which word was here in context.&lt;/p&gt;

&lt;p&gt;Let’s have a attempt at that — &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;em&gt;function II - heyjumblr&lt;/em&gt;

&lt;p&gt;Our main function starts line no. 23 &lt;em&gt;module.exports&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In line no. 26 we handle if the request contains action “&lt;em&gt;input.welcome&lt;/em&gt;”,so that we now know someone said hi to our app, to handle it we will grab a word which we got in line 27.&lt;/p&gt;

&lt;p&gt;function on line no. 14 shuffleword() jumbles the word when passed to it as a parameter.&lt;/p&gt;

&lt;p&gt;in line no. 29 We parsed the data exactly like how dialogflow can read it. &lt;br&gt;
We need to pass our word in fulfillment text in json so that Dialogflow can understand the text we send and read it aloud in the speaker.&lt;/p&gt;

&lt;p&gt;you can read more about &lt;a href="https://dialogflow.com/docs/fulfillment/how-it-works"&gt;dialogflow fulfillment response here&lt;/a&gt;.&lt;br&gt;
Because you can send many responses like cards which looks good on devices with Screen.&lt;/p&gt;

&lt;p&gt;so our two steps in azure function is done.&lt;/p&gt;

&lt;p&gt;For the third step we need to store the sessionID and Word somewhere.&lt;br&gt;
I chose &lt;a href="https://azure.microsoft.com/en-in/services/storage/tables/?&amp;amp;OCID=AID719810_SEM_eB3ulA7e&amp;amp;lnkd=Bing_Azure_Brand&amp;amp;msclkid=efcf0eae56d71a07513253a3568b4a9e&amp;amp;dclid=CjkKEQjwgLLoBRD9gLmF0MCgyoYBEiQAx7a83vz_FaIUQI5dLdkFyA8BSP2H2CJRPWwCqrw5ZbpFEkfw_wcB"&gt;&lt;strong&gt;azure table storage&lt;/strong&gt;&lt;/a&gt; which is more likely to help us as a tabular database — &lt;/p&gt;

&lt;p&gt;but we need a connection string to access permissions — &lt;br&gt;
Our friends at &lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string"&gt;Microsoft Docs&lt;/a&gt; can help with that.&lt;/p&gt;

&lt;p&gt;In line no. 35–50 we stored a JSON object into the Table Storage.&lt;/p&gt;

&lt;p&gt;Now let’s handle &lt;strong&gt;&lt;em&gt;fallback intent.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;in line no.53 we handle if the object has a queryAction which is “&lt;em&gt;input.unknown&lt;/em&gt;”&lt;br&gt;
We know what to do now, Check in the table if same sessionID has a word stored with it and compare the word returned by user with our word.&lt;/p&gt;

&lt;p&gt;“&lt;em&gt;queryResult.queryText&lt;/em&gt;” has the text sent to us by the user. &lt;br&gt;
We compare it with the word we got, just like we did in line no. 54.&lt;/p&gt;

&lt;p&gt;If the word is right we send the response, &lt;br&gt;
if the word is wrong we send the response.&lt;/p&gt;

&lt;p&gt;Awesome here we are finished with our &lt;em&gt;third step&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Now we need to return back to where we left in Step II and fill the webhook url as the invoke one.&lt;/p&gt;

&lt;p&gt;Voila, Now you can test your app in dialogflow or in Action Console.&lt;/p&gt;

&lt;p&gt;Points to be noted (Production app),&lt;/p&gt;

&lt;p&gt;Please have at &lt;a href="https://www.interaction-design.org/literature/article/how-to-design-voice-user-interfaces"&gt;How to Design Voice User Interfaces&lt;/a&gt;, when building an App like this for production.&lt;/p&gt;

&lt;p&gt;Also note cold-start might get in your way as google assistant only waits for 10s to get a response from webhook. &lt;strong&gt;Cold start&lt;/strong&gt; is a term used to describe the phenomenon that applications which haven’t been used a while take longer to start up.&lt;/p&gt;

&lt;p&gt;To get around with cold start use &lt;strong&gt;Premium Plan&lt;/strong&gt; or a &lt;strong&gt;App Service plan&lt;/strong&gt; to host Azure function.&lt;/p&gt;

&lt;p&gt;Serverless is the most suitable compute systems for these type of projects, which needs just a backend and a task to perform based on an event or an invocation.&lt;/p&gt;

&lt;p&gt;Thanks for reading this blog. &lt;br&gt;
Follow me for more awesome blogs.&lt;/p&gt;

&lt;p&gt;The pics used in blogs were from Unsplash.&lt;br&gt;
And I would thank editors to refine some words.&lt;/p&gt;

&lt;p&gt;I would recommend you to stay hydrated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/ju17XSnfYNrEb0BXbe/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/ju17XSnfYNrEb0BXbe/giphy.gif" alt="gif"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>azure</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>node</category>
    </item>
    <item>
      <title>qrfn : QR codes and Azure functions</title>
      <dc:creator>Ayush</dc:creator>
      <pubDate>Thu, 09 May 2019 22:48:15 +0000</pubDate>
      <link>https://dev.to/heyayush/qrfn-qr-codes-and-azure-functions-i6e</link>
      <guid>https://dev.to/heyayush/qrfn-qr-codes-and-azure-functions-i6e</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;qrfn : QR codes and Azure functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;generate&lt;a href="https://en.wikipedia.org/wiki/QR_code" rel="noopener noreferrer"&gt;&lt;strong&gt;QR codes&lt;/strong&gt;&lt;/a&gt; by just passing a text in &lt;a href="https://en.wikipedia.org/wiki/Query_string" rel="noopener noreferrer"&gt;&lt;em&gt;Query Parameters.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2A3EQRtUmQCcOvzkwG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2A3EQRtUmQCcOvzkwG"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@aka_opex?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Mitya Ivanov&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blog post we will see how I used QR Codes till now.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learn how &lt;a href="http://functions.azure.com" rel="noopener noreferrer"&gt;&lt;strong&gt;Azure Functions&lt;/strong&gt;&lt;/a&gt;can be a lego piece in your Architecture and Business.&lt;/li&gt;
&lt;li&gt;No spoilers of Game of Thrones, feel free to read every part ;p&lt;/li&gt;
&lt;li&gt;Enable images pls.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;tl;dr&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;QR code.js — Quick Response Codes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;RasteriseHTML — Downloadable Image&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read text from Query Parameter, and send QR code in Response.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Didn’t understand? Fallthrough the blog.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  QR code?
&lt;/h3&gt;

&lt;p&gt;I think QR code as a gateway to from the “real world” to the “internet”.&lt;br&gt;&lt;br&gt;
We see QR Codes being used in many ways, in movie/event tickets, in Payments, WIFI network login etc.&lt;/p&gt;

&lt;p&gt;But what’s a blog on QR without it’s full form right?&lt;br&gt;&lt;br&gt;
It’s known as Quick Response Code.&lt;/p&gt;

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

&lt;p&gt;We made &lt;strong&gt;QChain&lt;/strong&gt; in an Experiment which was &lt;strong&gt;startup for a Week&lt;/strong&gt;. We thought of an idea in &lt;strong&gt;12 Hours&lt;/strong&gt; and Executed it whole &lt;strong&gt;week long&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Qchain gives you hope of finding lost key by just having a QR with the useful information of the owner.&lt;/p&gt;

&lt;p&gt;To gather customers we generated funds by &lt;strong&gt;Crowdfunding&lt;/strong&gt; and started Delivering their Product after a Week.&lt;/p&gt;

&lt;p&gt;We used to &lt;strong&gt;3D print&lt;/strong&gt; the case and Print the QR code on a Sticker Page, cut it and Paste it on the Case. We couldn’t Automate the hardware, but the Software, ofcourse I had &lt;strong&gt;Azure functions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In form where people used to Pay us and Submit their information, I sent the submission to QRFn to generate their QR’s on the event(awesome r8).&lt;/p&gt;

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

&lt;p&gt;Moreover when I Built &lt;a href="https://cliniq.ml" rel="noopener noreferrer"&gt;&lt;strong&gt;Cliniq&lt;/strong&gt;&lt;/a&gt; ** ,** I used QRfn while building the service for patients to book appointments. The idea behind Cliniq was to skip long waiting queues to see the doctor.&lt;/p&gt;

&lt;p&gt;Patient portal can generate QR code with a Primary Key used in our database and can have an appointment book with a scheduled time.&lt;/p&gt;

&lt;p&gt;Doctors can Scan the QR and write Symptoms, notes and Prescription in the fields. Doctor portal justs inserts the data using primary key in the QChain.&lt;/p&gt;

&lt;p&gt;Similarly the Chemists can Scan the QR and retrieve Precription and provide medicines, using the primary key.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;QRfn&lt;/strong&gt; was found essential and delivering.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Azure Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Azure Functions is a &lt;a href="https://azure.microsoft.com/solutions/serverless/" rel="noopener noreferrer"&gt;serverless&lt;/a&gt; compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure. We can Use Azure Functions to run a script or piece of code in response to a variety of events.&lt;/p&gt;

&lt;p&gt;Azure function is easy to imagine as a Lego, a piece which helps build a building or a ship with the elephants. It can serve as crucial API to all your Stack needs when there isn’t any existing API for the same.&lt;/p&gt;

&lt;p&gt;Also this Lego piece can be a Ship alone, Performative and you don’t need to pay till you use it (pay per execution model).&lt;/p&gt;
&lt;h3&gt;
  
  
  Ohkay now, Let’s get Started for QRfn
&lt;/h3&gt;

&lt;p&gt;You can also use and copy paste the code from github repo as images won’t let you ;p &lt;a href="https://github.com/heyayushh/qrfn" rel="noopener noreferrer"&gt;&lt;em&gt;https://github.com/heyayushh/qrfn&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Write HTML to Respond with a Template
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Requiring Stuff in &lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;QRCode.js — To make QR code&lt;/li&gt;
&lt;li&gt;rasterizeHTML — To make a Image out of HTML
&lt;a href="https://medium.com/media/08638f4f37ed6e9422f9bc72b1ed61d6/href" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/08638f4f37ed6e9422f9bc72b1ed61d6/href" rel="noopener noreferrer"&gt;https://medium.com/media/08638f4f37ed6e9422f9bc72b1ed61d6/href&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt; of the HTML&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The div placeholder will be holding the king of the throne( QR code here ). Screen is just a container for placeholder. Also I added A download button which executes a script named download() on click, which will download the file.&lt;/p&gt;

&lt;a href="https://medium.com/media/d1dc26b9d223af040a1570ec8dad6b5e/href" rel="noopener noreferrer"&gt;https://medium.com/media/d1dc26b9d223af040a1570ec8dad6b5e/href&lt;/a&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Scripts&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://davidshimjs.github.io/qrcodejs/" rel="noopener noreferrer"&gt;&lt;strong&gt;QRcode.js&lt;/strong&gt;&lt;/a&gt;
&lt;a href="https://medium.com/media/2833fa2f9b5d064f32d1ee210b47d2fe/href" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/2833fa2f9b5d064f32d1ee210b47d2fe/href" rel="noopener noreferrer"&gt;https://medium.com/media/2833fa2f9b5d064f32d1ee210b47d2fe/href&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This generates a QR Code in the HTML tag.&lt;br&gt;&lt;br&gt;
You can read more about &lt;a href="https://davidshimjs.github.io/qrcodejs/" rel="noopener noreferrer"&gt;QRCode.js &lt;em&gt;here&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;As we are sending client a HTML page from JS we should convert it. As the html content contains lots of ‘,”,&amp;lt; , the js will give errors of parsing, and either we have to use escape characters or use this code.&lt;/p&gt;

&lt;p&gt;Mention the path and filename correctly.&lt;/p&gt;

&lt;p&gt;In mac OS/ Linux run the command in the directory same as the HTML Page. or you can also copy-paste the console output too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node convertHtmlToString.js | cat &amp;gt;&amp;gt; var.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, Save the content of var.txt/output for later use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Azure Functions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Requirements&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Azure Portal&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  1. Create a Function App
&lt;/h4&gt;

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

&lt;h4&gt;
  
  
  2. Use in-portal development
&lt;/h4&gt;

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

&lt;h4&gt;
  
  
  3. Create a HTTP trigger/ Webhook / API function
&lt;/h4&gt;

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

&lt;h4&gt;
  
  
  4. It’s the showtime.
&lt;/h4&gt;

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

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

&lt;p&gt;The code has so much to say, merely 10 lines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;qrSite&lt;/em&gt;&lt;/strong&gt; is the variable with the html code we saved earlier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;genQr(text)&lt;/em&gt;&lt;/strong&gt; function returns a QR of the text passed earlier as an argument(same like my girlfriend).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;context.res&lt;/em&gt;&lt;/strong&gt; is the response body(json) for azure function of a successful request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Save&lt;/strong&gt; and &lt;strong&gt;run&lt;/strong&gt; the &lt;em&gt;code&lt;/em&gt; either in test section or &lt;strong&gt;postman&lt;/strong&gt; adding the text as mentioned below:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;https://&amp;lt;&lt;/em&gt; &lt;strong&gt;&lt;em&gt;yourFunctionApp&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;&amp;gt;.azurewebsites.net/api/&amp;lt;&lt;/em&gt; &lt;strong&gt;&lt;em&gt;yourFunctionName&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;&amp;gt;?&lt;/em&gt; &lt;strong&gt;&lt;em&gt;text&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;=thanku4ReadingMyBlogLolplsclap&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;and it will respond with a &lt;strong&gt;HTML&lt;/strong&gt;  &lt;strong&gt;&lt;em&gt;website&lt;/em&gt;&lt;/strong&gt; with a &lt;em&gt;QRcode generator&lt;/em&gt;.&lt;/p&gt;

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

&lt;p&gt;There we go, we have king of seven kingdoms, protector of the WiFi password, &lt;strong&gt;QRfn&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Learn more about :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://functions.azure.com" rel="noopener noreferrer"&gt;https://functions.azure.com&lt;/a&gt;/&lt;/p&gt;

&lt;p&gt;&lt;a href="https://imaginecup.microsoft.com/en-us/Events?id=0" rel="noopener noreferrer"&gt;https://imaginecup.microsoft.com/en-us/Events?id=0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;this is the code to &lt;a href="https://github.com/heyAyushh/qrfn" rel="noopener noreferrer"&gt;QRfn&lt;/a&gt;, May the 4th be with you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/d4c80c9c56f3a23d8d290ce9c7fc71b7/href" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/d4c80c9c56f3a23d8d290ce9c7fc71b7/href" rel="noopener noreferrer"&gt;https://medium.com/media/d4c80c9c56f3a23d8d290ce9c7fc71b7/href&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cloudcomputing</category>
      <category>qrcode</category>
      <category>serverlessarchitect</category>
      <category>azure</category>
    </item>
  </channel>
</rss>
