<?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: Roman Akhromieiev</title>
    <description>The latest articles on DEV Community by Roman Akhromieiev (@akhromieiev).</description>
    <link>https://dev.to/akhromieiev</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%2F431379%2F1fd7dc9e-67ef-4b64-bbfa-2b0ea62fb789.png</url>
      <title>DEV Community: Roman Akhromieiev</title>
      <link>https://dev.to/akhromieiev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akhromieiev"/>
    <language>en</language>
    <item>
      <title>Angular UI Kits</title>
      <dc:creator>Roman Akhromieiev</dc:creator>
      <pubDate>Fri, 15 Oct 2021 10:37:48 +0000</pubDate>
      <link>https://dev.to/akhromieiev/angular-ui-kits-2h63</link>
      <guid>https://dev.to/akhromieiev/angular-ui-kits-2h63</guid>
      <description>&lt;p&gt;I created a table of UI kits for an Angular framework. There is no specific order, I have put them in the order I found.&lt;/p&gt;

&lt;p&gt;The full table:&lt;br&gt;
&lt;a href="https://akhromieiev.github.io/angular-ui-kits/"&gt;https://akhromieiev.github.io/angular-ui-kits/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to edit this table:&lt;br&gt;
&lt;a href="https://github.com/akhromieiev/angular-ui-kits/edit/main/docs/index.md"&gt;https://github.com/akhromieiev/angular-ui-kits/edit/main/docs/index.md&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>uikit</category>
      <category>library</category>
      <category>ui</category>
    </item>
    <item>
      <title>Building a Telegram Bot with Azure Functions and Node.js</title>
      <dc:creator>Roman Akhromieiev</dc:creator>
      <pubDate>Tue, 14 Jul 2020 06:34:12 +0000</pubDate>
      <link>https://dev.to/akhromieiev/building-a-telegram-bot-with-azure-functions-and-node-js-28b</link>
      <guid>https://dev.to/akhromieiev/building-a-telegram-bot-with-azure-functions-and-node-js-28b</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we will create an Azure Function with a simple Telegram Bot (Echo Bot). We will test it locally and then deploy it to Azure Portal. It means our bot will work only at the moment when someone is using it. So the function will be triggered only when someone is sending a message to a bot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flow Review
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; The user sends any message to Telegram Bot&lt;/li&gt;
&lt;li&gt; Telegram sends requests via Webhook to our Azure Function&lt;/li&gt;
&lt;li&gt; Azure Function replies to Webhook with a copied message&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  node.js - v10.16.2&lt;/li&gt;
&lt;li&gt;  npm - v6.14.5&lt;/li&gt;
&lt;li&gt;  telegraf - v3.38.0&lt;/li&gt;
&lt;li&gt;  ngrok - v2.3.35&lt;/li&gt;
&lt;li&gt;  Azure subscribtion&lt;/li&gt;
&lt;li&gt;  you need to install &lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions"&gt;Azure Functions extension&lt;/a&gt; to Visual Studio Code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create an Azure function in Visual Studio Code
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; click on Azure Icon in Visual Studio Code:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8r7BMVsF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.48.39-1024x885.png" alt="Azure Icon in VSC"&gt;
&lt;/li&gt;
&lt;li&gt; login under your Azure subscription&lt;/li&gt;
&lt;li&gt; click on "Create Function Icon":&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QGNtW0l6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.51.16.png" alt="Create Function Icon"&gt;
&lt;/li&gt;
&lt;li&gt; you will be asked to use an existing project or create a new. Let's create a new:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jbURq9pK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.54.40-1024x281.png" alt="Create a new project"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HJNf1_QJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.55.13-1024x589.png" alt="Create new project folder"&gt;
&lt;/li&gt;
&lt;li&gt; select the function template. We will use &lt;strong&gt;HTTP trigger&lt;/strong&gt;:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mM4dIaDH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.55.36-1024x607.png" alt="Choose a Function Template"&gt; &lt;/li&gt;
&lt;li&gt; provide a function name and select Enter:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P3baHqXY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.56.16-1024x213.png" alt="Enter the name of the function"&gt;
&lt;/li&gt;
&lt;li&gt; please provide a &lt;strong&gt;Function&lt;/strong&gt; key for a &lt;strong&gt;Function authorization&lt;/strong&gt;:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rn0moHMv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.56.27-1024x280.png" alt="Function Authorization level"&gt;
&lt;/li&gt;
&lt;li&gt; penultimate step. Select how you would like to open a project. We will use the current window:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4wgZLF0c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.56.39-1024x291.png" alt="How to open a function project in Visual Studio Code"&gt;
&lt;/li&gt;
&lt;li&gt; you will be redirected to the &lt;strong&gt;default HTTP trigger function with Javascript code&lt;/strong&gt;:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rUHHk2f3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-10.57.02-1024x618.png" alt="The default function Code"&gt;
&lt;/li&gt;
&lt;li&gt;now this function will appear in Azure Functions section:
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yK6KrsiF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-11.23.30-1024x340.png" alt="Newly created function"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Folder structure
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--78SoYWCS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-11.29.34-300x256.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--78SoYWCS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-11.29.34-300x256.png" alt="Function Folder Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;package.json&lt;/strong&gt; - metadata relevant to the Node.js project&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;proxies.json&lt;/strong&gt; - you can modify requests and responses from function&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;host.json&lt;/strong&gt; - metadata file relevant to the Azure project. It's a global configuration for all functions in an application&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;azure-bot-cloud-function&lt;/strong&gt; - it's our function folder. Each function has a separate folder with code file (.js in our case) and function.json. Function.json it's a &lt;a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-expressions-patterns"&gt;binding configuration file&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Run function locally
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; Select "Run" -&amp;gt; "Start Debugging" in Visual Studio Code menu&lt;/li&gt;
&lt;li&gt; If you have no Azure Functions Core Tools locally, you need to install them on this step. The instruction can be found in &lt;a href="https://github.com/Azure/azure-functions-core-tools#installing"&gt;Azure repo:&lt;/a&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AeBCB5dy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-20.48.48-1024x127.png" alt="Install Azure Function Core Tools"&gt;
&lt;/li&gt;
&lt;li&gt; You should see how the NPM tasks will executing and finally get a link to the working function:&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u_09gcEX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-21.08.28-1024x601.png" alt="Link to the local Azure function"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Let's open our function in the browser:&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2BQrOXeq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-21.20.46-1024x274.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2BQrOXeq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-07-at-21.20.46-1024x274.png" alt="Azure Function is working locally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you see, the function responds to us with the behavior by default. Also, you can simply run the function using the &lt;strong&gt;func start&lt;/strong&gt; command.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Implement the bot
&lt;/h2&gt;

&lt;p&gt;For work with Telegram API, we will use the most popular library for Node.js - &lt;a href="https://github.com/telegraf/telegraf"&gt;Telegraf.js&lt;/a&gt;. We need to install it in the project folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;telegraf &lt;span class="nt"&gt;--save&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Please make sure the &lt;code&gt;package.json&lt;/code&gt; has Telegraf after the running previous command.&lt;/p&gt;

&lt;p&gt;Because Telegram will send webhook requests to our bot, we need to make an external HTTPS URL. For this purpose we can use &lt;a href="https://ngrok.com/"&gt;ngrok library&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;ngrok &lt;span class="nt"&gt;-g&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If all is good, we can go to &lt;code&gt;&amp;lt;function-folder&amp;gt;/index.js&lt;/code&gt; and create a simple Echo-bot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Telegraf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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;telegraf&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TELEGRAM_BOT_TOKEN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;WEBHOOK_ADDRESS&lt;/span&gt; &lt;span class="p"&gt;}&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bot&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;Telegraf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;TELEGRAM_BOT_TOKEN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;telegram&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;webhookReply&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nx"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;telegram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setWebhook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;WEBHOOK_ADDRESS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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;message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&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;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;telegram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sendCopy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;chat&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="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="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="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleUpdate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;res&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;You can take &lt;code&gt;TELEGRAM_BOT_TOKEN&lt;/code&gt; value from &lt;a href="https://telegram.me/BotFather"&gt;BotFather bot&lt;/a&gt;. The &lt;code&gt;WEBHOOK_ADDRESS&lt;/code&gt; will contain a link to the Azure Function. We will talk about this variable later.&lt;br&gt;
Our bot will work in Webhook mode - it's a more preferable way to run Telegram bot. The Telegram will automatically inform our bot about all updates. In the polling mechanism, our bot needs to frequently ask Telegram about updates, so it requires non-stop work for our bot (most cases).&lt;/p&gt;
&lt;h2&gt;
  
  
  Running bot locally
&lt;/h2&gt;

&lt;p&gt;To run this bot locally we need to create a public address using &lt;code&gt;ngrok&lt;/code&gt;. By default, the local Azure function is running on port &lt;code&gt;7071&lt;/code&gt;. We can use the following combination in the terminal to create a public URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ngrok http 7071
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the terminal you will get your HTTPS link for testing Webhook:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jmrttio1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.29.42-1024x400.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jmrttio1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.29.42-1024x400.png" alt="HTTPS public URL using ngrok"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the ngrok-created link and add the route to the function. Something similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;telegram&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setWebhook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://&amp;lt;random-value&amp;gt;.ngrok.io/api/azure-bot-cloud-function&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;Also, don't forget to pass a real Telegram token to the Telegraf constructor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bot&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;Telegraf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;some-token-value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;telegram&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;webhookReply&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&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;It's very dirty, but for a quick test it's OK, so please remember to remove all real keys from the code.&lt;/p&gt;

&lt;p&gt;Then you can run a function just using the simple command:&lt;br&gt;
&lt;/p&gt;

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



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zFiVhoJD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.49.14-1024x709.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zFiVhoJD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.49.14-1024x709.png" alt="Azure Functions is running locally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Good job! Now open your bot in Telegram and send any message. Our bot should copy it and resend to you:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hpRmkzuw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.41.16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hpRmkzuw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.41.16.png" alt="Echo-Bot example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploy Azure Function to the portal
&lt;/h2&gt;

&lt;p&gt;To deploy Azure Function we just need to click on this button:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lIbuGXac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.52.40-1024x730.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lIbuGXac--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.52.40-1024x730.png" alt="Deploy Azure Function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then choose your resource and press "Deploy". The process will be started:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kOUg1DVa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.53.55-1024x406.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kOUg1DVa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.53.55-1024x406.png" alt="The process of deploying Azure Function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After successful deployment, we need to go to Azure Portal and update &lt;code&gt;WEBHOOK_ADDRESS&lt;/code&gt; and &lt;code&gt;TELEGRAM_BOT_TOKEN&lt;/code&gt; variables with real values.&lt;/p&gt;

&lt;p&gt;To get a real function URL, go to "Functions", then choose your Azure Function and press "Get Function Url" button:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DvFuIRMm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.05.24-1024x275.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DvFuIRMm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.05.24-1024x275.png" alt="How to get Azure Function URL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to copy this value and paste to "Application Settings" along with Telegram Token:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FnREnKF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.59.12-1024x343.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FnREnKF2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-22.59.12-1024x343.png" alt="Application Settings in Azure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding our secret keys, press "Save" and restart our application:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y2UhCdKk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.09.41-1024x424.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y2UhCdKk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.09.41-1024x424.png" alt="Restart Azure application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all. Our bot should work in the cloud and you can track all function executions in real-time:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RvalySZY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.13.07-1024x325.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RvalySZY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://akhromieiev.com/wp-content/uploads/2020/07/Screenshot-2020-07-13-at-23.13.07-1024x325.png" alt="Azure Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each function execution means that our bot handled 1 single message.&lt;/p&gt;

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

&lt;p&gt;In this tutorial, we have created an Azure Function with a simple Echo-Bot for Telegram. Azure Functions its a cool way to host your bots. You will be chargeable by the simple formula - (Memory size)X(Execution time in ms)X(Executions per month) and also remember that the first 400,000 GB/s of execution and 1,000,000 executions are free. If you need to estimate your pricing costs you can use &lt;a href="https://azure.microsoft.com/en-us/pricing/calculator/"&gt;this pricing calculator&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>telegram</category>
      <category>bot</category>
      <category>node</category>
    </item>
  </channel>
</rss>
