<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Daniel de Freitas Gonçalves on Medium]]></title>
        <description><![CDATA[Stories by Daniel de Freitas Gonçalves on Medium]]></description>
        <link>https://medium.com/@daniielf.13?source=rss-ec1796090f5e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mlJu20FdpFcRbMG_.jpg</url>
            <title>Stories by Daniel de Freitas Gonçalves on Medium</title>
            <link>https://medium.com/@daniielf.13?source=rss-ec1796090f5e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 18:54:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@daniielf.13/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Enhancing Mobile Applications performance and development efficiency]]></title>
            <link>https://medium.com/@daniielf.13/enhancing-mobile-applications-performance-and-development-efficiency-b62a4c21a15c?source=rss-ec1796090f5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b62a4c21a15c</guid>
            <category><![CDATA[improvement]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Daniel de Freitas Gonçalves]]></dc:creator>
            <pubDate>Wed, 28 Feb 2024 21:00:15 GMT</pubDate>
            <atom:updated>2024-02-28T21:40:33.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*muvE-Qf5_Kbdq4_ohT3jsA.png" /></figure><p>I have been developing mobile applications for over seven years, traversing both Native and hybrid development. Here, I share key aspects of mobile projects that I have worked on during these years, which might be beneficial for any software product.</p><p>I will categorize these insights into two sections: <strong>Product Experience</strong> and <strong>Development Experience.</strong></p><h3><strong>Product Experience</strong></h3><h4><strong>Strategic API requests</strong></h4><p>Understanding what is essential for the frontend when communicating with an API is crucial. Try to use specific requests for the purpose you want. For instance, avoid executing a request that fetches unnecessary data which will not be used in the screen/component it’s going to be presented.</p><p>While <strong>batching </strong>is a nice practice for executing several requests at once, it is also essential to understand what may be the priority of the requests. The batching practice might slow down a critical request, while the superfluous/lesser-important requests could be done in parallel.</p><h4>Caching control</h4><p>Retrieving data, especially with heavy content, slows down user’s experience when using your App. It’s extremely important to start using caching practices. Images that might be presented several times to the users, most accessed contents, latest accessed contents, etc.</p><p>This can be implemented manually or with third-party libraries. Each developing platform might offer different resources to achieve that.</p><h4>Keep dependencies up-to-date</h4><p>It’s common to have a large list of dependencies in our applications, so keeping them up-to-date it’s essential to avoid bugs, improving performance and fixing vulnerabilities.</p><p>That can be a tough task to do manually, but there are some tools around there that help us with doing so, like Dependabot.</p><h4>Mobile focused experience</h4><p>This is even more important to consider when your mobile application is built after a web application. It’s a common error to try to mimic the same UI and UX from the web pages. Mobile devices have unique characteristics that can make the experience of your application much better.</p><ul><li>Define the best virtual keyboard options for your input fields;</li><li>Make use of device capabilities: camera, geolocation, gyroscope, etc. Whatever makes sense to include in your product;</li><li>Implement <strong>Deep Link</strong> / <strong>Universal Links</strong> /<strong> Android App Links</strong> for handling navigations to your app;</li><li>Align the UI/UX to best fit the device capabilities. Use gestures efficiently to enable you to avoid unnecessary components on the device screen, like: using <strong>Swipe back gesture </strong>or<strong> Hardware back button</strong>, using the <strong>Pull to Refresh</strong> gesture, etc.</li></ul><h3>Development Experience</h3><h4>Code Consistency</h4><p>Consistent and well-organized code reduces the likelihood of bugs and improves maintainability. Using tools such as Linting, Testing and Spell checking, highly improves the development experience and minimizes the chances of bugs to appear through the project.</p><p>I can’t stress enough how tests can be important to ensure the consistency of an application. I will leave this for the other several articles that exist around there regarding this specific topic.</p><h4>Reusable Code</h4><p>In large projects, tracking duplicated constants, methods, and components might be challenging, however it is crucial for saving developers’ time, facilitating refactoring, and ensuring code uniformity.</p><h4>Maintain Documentation</h4><p>Probably this is the most forgotten topic of developers. A well-organized and up-to-date documentation can avoid a lot of frustration and waste of time. A project and its work environment suffers a lot of changes with time. Keeping an out-dated documentation can lead to mistakes and wrong assumptions for whoever tries to read it.</p><p>This is especially helpful for people that are onboarding into a project. If you ever had the experience of depending on bad documentation, you probably understand how this can be frustrating.</p><h4>Automation Scripts</h4><p>It’s quite usual to have processes and routines that you have to run several times a day. Or even boring things that you/your team have to do from time to time. I strongly recommend taking a look at those routines and understanding how many of those (or at least parts of it) could be automated by scripts.</p><p>I have some examples of automations scripts I built that were useful for myself or to other team members:</p><ul><li>Creating Files accordingly to a template;</li><li>Preparing project environment and its dependencies; <br><em>(specially good for Onboardings and new machines)</em></li><li>Fetching latest environment files;</li><li>Cleaning working environment caches;</li><li>Check-up on working environment;</li></ul><h4>Leveraging CI &amp; CD</h4><p>This is definitely something that is worth a lot to spend some time improving as much as you can. <strong>Continuous Integration</strong> and <strong>Continuous Delivery</strong> brings a lot of consistency and velocity in a working environment — particularly for mobile development.</p><p>There are several well-known tools that provide that, like: Jenkins, CircleCI, or GitHub Actions. However, it is crucial to select the one that fits the best to your project’s necessities. A good decision might <strong>save costs</strong> and<strong> increase the performance</strong> of your integrations.</p><p>Beyond the tool/provider that you pick, you must also be aware of which machines are running on the backstage of the chosen provider.</p><p>In a particular case in my career, defining the proper machines to run our CI/CDs brought to us a fantastic improvement. We could<strong> increase the speed of some of our processes up to seven times</strong> and <strong>reduce our costs by five</strong>. <em>A Win-Win decision</em>.</p><h4>Configure builds correctly</h4><p>Using the appropriate build configurations for development and release builds ensures that unnecessary development tools and debugging information are not included in the production build.</p><p>Doing that reduces the size of the application and also speeds up your processes.</p><h4>Use Observability tools</h4><p>Making the best use of Observability tools enables you (and stakeholders) to spot and understand flaws and points of improvements of your application. Important to notice that having the tools is just not enough if you don’t know what to look for.</p><ul><li>Define which metrics are important for your team;</li><li>Make the most important data to be always on sight;</li><li>Learn what the tools you are using are capable of and how to use them with most efficiency.</li></ul><h4>Code Push</h4><p>Code Pushing is a fantastic feature for mobile applications, however is only applicable for projects built in some hybrid frameworks. This feature allows publishing changes to versions of the App that are already published in Google Play / Apple’s App Store.</p><p>A regular release of a mobile application version might take some days, because we depend on the publisher’s review. However, through Code Push it’s possible to skip that and publish changes in a few minutes. Of course, it has some limitations: code push cannot overwrite core Native code. That’s why it is a feature only available for hybrid frameworks. However, even with its limitations, it is still extremely useful for <strong>hotfixes</strong>.</p><h3>Final Thoughts</h3><p>There are several other aspects that could be extremely relevant to approach and analyze. I decided to stick to the things I have worked on lately and which I could see the improvement being consolidated. There will always be a new technology or trend that might change everything. <br>(<em>Have you heard about AIs?</em>)</p><p>Improving your project is a never ending work. There’s always a next step. Maybe not today, but definitely in the near future.</p><p>So, my final tip is:<br>Make the mentality of continuous improvement a constant in your work environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b62a4c21a15c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using ChatGPT to leverage my React-Native project]]></title>
            <link>https://medium.com/@daniielf.13/using-chatgpt-to-leverage-my-react-native-project-49604a619812?source=rss-ec1796090f5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/49604a619812</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pareto-principle]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Daniel de Freitas Gonçalves]]></dc:creator>
            <pubDate>Sat, 16 Dec 2023 14:47:46 GMT</pubDate>
            <atom:updated>2023-12-16T14:47:46.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*mDVnukeJ9qHKtCBU8QWutg.png" /></figure><p>Few weeks ago I had this idea of a simple mobile game based on riddles which I am really a fan of. However, instead of simply opening my coding IDE and start it, I decided to use some help from <strong>ChatGTP</strong> to leverage it.</p><p>Utilizing ChatGPT for leveraging React-Native mobile applications can be really handy in the development process by employing it as a code writer and a rapid source of documentation. Starting a project from scratch can be really boring, repetitive and consume a good portion of our coding time. Installing the fundamental dependencies, writing the skeleton of the screens, defining reusable constants, etc. In adhering to the <strong>Pareto Principle (or the 80/20 rule)</strong> using ChatGPT allowed me speed up the crucial 20% of their codebase that contributes to 80% of the application’s functionality.</p><p>By integrating ChatGPT into the coding workflow, I generated code snippets quickly and efficiently. This is particularly beneficial for routine or boilerplate code, saving time and effort that can be redirected to more intricate aspects of the application.</p><p>With a descriptive prompt of what I wanted, ChatGPT delivered all the starting code base and the steps for installing the required dependencies to achieve the basic functionalities of the game.</p><p>This was the prompt I used for the first layout of the app.</p><blockquote>Write a React-Native code which describes a screen named RiddleScreen. It should contain a picture that occupies 35% of the screen height. Below the picture should contain a Text with a light color. On the bottom of the screen should contain a Text Input and a Button horizontally centralized, which both should have the same height of 60px and occupy 70% of the screen width. The button must contain the text “Submit” with the same color as the Text component.<br>All the styles should be in a separated file.<br>The screen must have a dark background. The Input and Button should contain handler methods. <br>Write another screen named HomeScreen with the same background color. This screen should have a centralized button called “Start” with the same style of RiddleScreen button and it must navigate to the RiddleScreen when tapped. Use a stack structure and use HomeScreen as root.<br>Create a separate file for exporting an enum with the used Colors and Font sizes. <br>The buttons must have a large font size and round borders.</blockquote><p>As a result of this prompt, ChatGPT delivered to me the basic structures that I desired for each screen and the list of dependencies that I should install. I did some few interactions to adjust things that did not come out as expected and added the logic part of the game.</p><p>With the layout ready, I also retrieved from ChatGPT some other structures required for my application, like: a controller for <strong>Async Storage</strong>, a <strong>device orientation</strong> hook, a <strong>Firebase Analytics</strong> service, a controller for <strong>In App Review</strong>, and a few more. Along with the implementation code, the AI also described a list of dependencies and the steps for the installation of each.</p><p><em>(I used the same process to leverage a Node API hosted in </em><a href="https://fly.io/"><strong><em>Fly.io</em></strong></a><strong><em>.</em></strong><em> I won’t enter in too many details in this post, but worth to mention that the outcome of the prompt required even less effort from me to adjust)</em></p><p>Once the basic structure was concluded, I finished implementing the business logic of the game and connected to its API. With few adjustments the App was already in its <strong>MVP</strong> state. After the main capabilities were ready and validated, I spent the rest of my time (the other 80%) refining and optimizing what was necessary, like styling, flavoring and adding secondary features.</p><h3>Conclusion</h3><p>In summary, incorporating ChatGPT as a code writer and documentation source in React-Native mobile applications follows the <strong>Pareto Principle</strong> by optimizing the development process. Yet, the collaboration between ChatGPT’s capabilities and your own knowledge is crucial for validating, adapting, and refining the code and documentation to meet the specific needs of your application.</p><h3>Outcome</h3><p>Currently my game is in its version 1.3 and available at <a href="https://apps.apple.com/us/app/riddl-the-game/id6468613455"><strong><em>App Store</em></strong></a> and <a href="https://play.google.com/store/apps/details?id=com.daniielfdev.riddl"><strong><em>Google Play</em></strong></a><strong><em>.</em></strong> Take a look on it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49604a619812" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building and hosting my first Telegram Bot in Fly.io.]]></title>
            <link>https://medium.com/@daniielf.13/building-and-hosting-my-first-telegram-bot-in-fly-io-93d98064de6f?source=rss-ec1796090f5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/93d98064de6f</guid>
            <category><![CDATA[telegram-bot]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[flyio]]></category>
            <category><![CDATA[ideas]]></category>
            <dc:creator><![CDATA[Daniel de Freitas Gonçalves]]></dc:creator>
            <pubDate>Tue, 21 Mar 2023 22:35:15 GMT</pubDate>
            <atom:updated>2023-03-21T22:35:15.452Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4g6L7P94ytP6Eds56YJwvg.png" /></figure><p>The reason why I’m writing this article came after a pratical need. I believe that there are several developers and engineers that may faced some similar situation. My particular challenge was quite simple: I wanted an easy-to-use tool to add and deleting items from a list — basically, a shopping list — that could be edited by multiple users simultaneously. And of course, made by myself.</p><p>As a mobile developer, my first thought was to make my own app for that, obviously. I ended doing it, although I wasn’t completely satisfied with the practical part of it. Having this app in my and other people’s device for such a small purpose wasn’t really aligned with the “easy-to-use” requirement I was looking for.</p><p>Time went on and I had no idea of how I could replace my app with something more simple. Until some weeks ago.</p><p>In a conversation with a friend, he mentioned that he was moving some projects hosted in GCP to Fly.io — including his Telegram bots. At the time, I wasn’t aware of how handy those bots could be for building so many different types of features. After checking some of his projects I finally had some insight of how I could achieve the tool I wanted.</p><h4><strong>Hands-on</strong></h4><p>Okay, from there, I knew the tools I needed to use on my task. The next question was: “How can I do that?”. I had a total of zero experience of building Telegram bots and no clue how to use this Fly.io platform. But that’s the fun part, right? Let’s learn something new.</p><p>Initially, I expected to spend a couple of days reading the documentations for each tool and slowly making progress building my bot. (Spoiler alert: I was very wrong). The first decision I had to make was which programming language to use for building my bot. Since I expected to spend a significant amount of time reading Telegram’s and Fly.io’s documentation, I decided to use Node.js, as I was already comfortable programming with it.</p><h4><strong>Starting the Bot project</strong></h4><p>I started a Node project with some dependencies to work with Typescript and Yarn. (If you want to follow my steps but are not familiar with any of those, you can get started by reading these docs: <a href="https://nodesource.com/blog/an-absolute-beginners-guide-to-using-npm/">Npm</a>, <a href="https://www.typescriptlang.org/docs/handbook/typescript-tooling-in-5-minutes.html">Typescript</a> and <a href="https://classic.yarnpkg.com/en/docs/getting-started">Yarn</a>).</p><p>On my setup, I had my <strong>package.json </strong>and <strong>tsconfig.json</strong> like this:</p><pre>{<br>  &quot;name&quot;: &quot;chat-notes-bot&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;Telegram Chat Notes bot&quot;,<br>  &quot;main&quot;: &quot;dist/index.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;yarn tsc &amp;&amp; node dist/index.js&quot;<br>  },<br>  &quot;keywords&quot;: [],<br>  &quot;author&quot;: &quot;Daniel de Freitas Gonçalves&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;,<br>  &quot;dependencies&quot;: {<br>    &quot;ts-node&quot;: &quot;^10.9.1&quot;<br>  },<br>  &quot;devDependencies&quot;: {<br>    &quot;@types/node&quot;: &quot;^18.15.0&quot;,<br>    &quot;typescript&quot;: &quot;^4.9.5&quot;<br>  }<br>}</pre><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;outDir&quot;: &quot;./dist&quot;,<br>    &quot;target&quot;: &quot;es2016&quot;,                       <br>    &quot;module&quot;: &quot;commonjs&quot;,                     <br>    &quot;esModuleInterop&quot;: true,                  <br>    &quot;forceConsistentCasingInFileNames&quot;: true, <br>    &quot;strict&quot;: true,                           <br>    &quot;skipLibCheck&quot;: true                      <br>  },<br>  &quot;include&quot;: [&quot;src/**/*.ts&quot;],<br>  &quot;exclude&quot;: [&quot;node_modules&quot;, &quot;**/*.spec.ts&quot;],<br>}</pre><p>With this setup concluded, I was ready to start building the Telegram bot communication. So, let’s get to know <strong>Telegram’s BotFather</strong>.</p><h4><strong>Creating a Telegram Bot</strong></h4><p>For creating a Telegram bot, we can use the assistance of BotFather. This is a bot that helps us build and configure our own bots. Starting a conversation with BotFather and creating a bot is just simple like the I’ve done in the picture below:</p><figure><img alt="BotFather" src="https://cdn-images-1.medium.com/max/1024/0*NBK9-PWKssLydvnV" /><figcaption>Creating a bot with BotFather</figcaption></figure><p>And that ‘s it. <br>We can give extra customization to our bot using commands like <strong><em>/setcommands</em></strong> or <strong><em>/setuserpic</em></strong>, but all we need is the token that BotFather provided for accessing Telegram’s API.</p><h4><strong>Configuring my bot</strong></h4><p>The next step was configuring the behaviors of the <strong>ChatNotesBot</strong>.<strong> </strong>There are several Node (and other programming languages) libraries that allow us to do that.</p><p>Following the suggestion of my friend, I decided to use the <a href="https://grammy.dev/guide/getting-started.html#getting-started-on-node-js">grammY</a> lib. This lib has a feature that was pretty handy for me later on. Configuring the commands and running the bot with grammY was simple as creating the bot.</p><p>I had to add two more dependencies to the project:</p><ul><li><strong>grammY: </strong>the module for configuring and running the bot.</li><li><strong>dotenv: </strong>so I could store my secret token in a `.env` file (this was not actually a necessity, it was just a tool for running it locally).</li></ul><p>So for installing them, you can just run in the terminal inside the project:</p><pre>yarn add grammy dotenv</pre><p>Then I created a <strong>.env</strong> and <strong>index.ts</strong> files:</p><pre>// .env<br>TELEGRAM_BOT_TOKEN=&lt;&lt;BOT_TOKEN&gt;&gt;</pre><pre>// index.ts<br>import { Bot } from &quot;grammy&quot;;<br>import * as dotenv from &quot;dotenv&quot;;<br><br>dotenv.config();<br><br>const getToken = () =&gt; process.env.TELEGRAM_BOT_TOKEN ?? &#39;&#39;;<br><br>const bot = new Bot(getToken());<br><br>bot.on(&quot;message&quot;, (ctx) =&gt; ctx.reply(&quot;I&#39;m alive!&quot;));<br>bot.start();</pre><p>This is just enough to make the bot ready to listen to interactions in the Telegram chat.</p><p>The next step for me was adding the bot capabilities to make the shopping list features.<br>So, before moving on, I needed to define how I should persist the list data. That’s where <strong>grammY</strong> get’s really handy.</p><p>One of its features is to be able to easily persist data using this additional module called <strong>@grammyjs/storage-file. </strong>With this lib we can automatically persist any data we want in our sessions.</p><p>To do so, I needed to create some Types and include one middleware to the bot. So I changed my index.ts a little bit:</p><pre>// index.ts<br>- import { Bot } from &quot;grammy&quot;;<br>+ import { Bot, session } from &quot;grammy&quot;;<br>+ import { FileAdapter } from &quot;@grammyjs/storage-file&quot;;<br>import * as dotenv from &quot;dotenv&quot;;<br><br>+ import { GRAMMY_STORAGE_FOLDER, getToken } from &quot;./constants&quot;;<br>+ import { StoreContext } from &quot;./types&quot;;<br><br>dotenv.config();<br><br>+ const buildBot = (): Bot&lt;StoreContext&gt; =&gt; {<br>+ const bot = new Bot&lt;StoreContext&gt;(getToken());<br>  <br>+  bot.use(session({<br>+    initial: () =&gt; ({ items: [] }),<br>+    storage: new FileAdapter({<br>+      dirName: GRAMMY_STORAGE_FOLDER<br>+    }),<br>+  }));<br><br>  return bot;<br>}<br><br>- bot.on(&quot;message&quot;, (ctx) =&gt; ctx.reply(&quot;I&#39;m alive!&quot;));<br>+ const bot = buildBot();<br>bot.start();</pre><pre>// types.ts<br>import { Context, SessionsFlavor} from &quot;grammy&quot;;<br><br>export type ChannelStore = { items: Array&lt;string&gt; };<br>export type StoreContext = Context &amp; SessionFlavor&lt;ChannelStore&gt;;</pre><pre>// constants.ts<br>export const getToken = () =&gt; process.env.TELEGRAM_BOT_TOKEN ?? &#39;&#39;;<br>export const GRAMMY_STORAGE_FOLDER = &quot;storage&quot;;</pre><p>Now, every change on “<strong>session.items</strong>” would be automatically updated in a JSON file of each session inside my designed folder.</p><h4><strong>Creating my bot commands</strong></h4><p>My bot was ready to persist the data of my items list, so I just needed to define the commands to manipulate the list.</p><p>Starting with the “add” command, I defined some types and structures to make it easier to replicate for other commands, and then I got it like:</p><pre>// addCommand.ts<br>import { CommandContext } from &quot;grammy&quot;;<br>import { BotCommand, StoreContext } from &quot;./types&quot;;<br><br>const ADD_ITEM_COMMAND = &quot;add&quot;;<br>const addItem = (context: CommandContext&lt;StoreContext&gt;) =&gt; {<br>  const itemName = context.match; <br>  if (!itemName) {<br>    context.reply(`Define the item name. Ex: &#39;/add Apple&#39;`);<br>    return<br>  };<br>  context.reply(`Item added: &#39;${itemName}&#39;`);<br>  context.session.items.push(itemName);<br>};<br><br>const AddItemCommand: BotCommand = {<br>  name: ADD_ITEM_COMMAND,<br>  action: addItem,<br>}<br><br>export {AddItemCommand};</pre><pre>// types.ts<br>import { Context, SessionsFlavor} from &quot;grammy&quot;;<br><br>export type ChannelStore = { items: Array&lt;string&gt; };<br>export type StoreContext = Context &amp; SessionFlavor&lt;ChannelStore&gt;;<br><br>+ export interface BotCommand {<br>+ name: string,<br>+   action: (context: CommandContext&lt;StoreContext&gt;) =&gt; void;<br>+ }</pre><p>And then, including the command behavior to the bot in the <strong>index.ts</strong>:</p><pre>// index.ts<br><br>[...]<br><br>- import { StoreContext } from &quot;./types&quot;;<br>+ import { BotCommand, StoreContext } from &quot;./types&quot;;<br>+ import { AddItemCommand } from &quot;./addCommand&quot;;<br><br>[...]<br><br>+ const addBotCommand = (bot: Bot&lt;StoreContext&gt;, command: BotCommand) =&gt; bot.command(command.name, command.action))<br><br>const bot = buildBot();<br><br>+ // Defining commands<br>+ addBotCommand(bot, AddItemCommand);<br><br>bot.start();</pre><p>Doing the same for the other bot capabilities (Delete, List and Clear), the bot features were concluded. I could test it by running the Node project locally and starting a conversation with my bot in Telegram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*xpPSEuBFQs1L2aJUgnCgPg.png" /></figure><h4><strong>Hosting the bot in Fly.io</strong></h4><p>Running locally worked fine, but I didn’t want to keep the Node application running on my own laptop, of course.</p><p>To get started with Fly.io, it was quite simple, I just needed to: <strong>Sign-up</strong>, <strong>Install Fly.io CLI </strong>and <strong>Sign-in locally.</strong> You can follow their <a href="https://fly.io/docs/hands-on/install-flyctl/">guide</a> to do so.</p><p>With those three steps concluded it’s just necessary to set up your project configuration.</p><h4><strong>Setup Fly.io in my project</strong></h4><p>Inside the project folder, just running the following will start the Fly.io setup:</p><pre>fly launch</pre><p>The setup will run like:</p><p><a href="https://asciinema.org/a/UVaBO8lGfoVbhDecCisuS8wAM">untitled</a></p><p>Before deploying it, I had two things to deal with yet: Manage how to keep my persisted data saved even if my Fly.io instances dies and how my I could make the project read the bot Token without regarding on the ‘<strong>.env</strong>‘ (because of safety reasons, this file should not be deployed with the project, so I added it to .dockerignore file generated by Fly.io).</p><pre>// .dockerignore<br><br>fly.toml<br>Dockerfile<br>.dockerignore<br>node_modules<br>.git<br>+ .env</pre><p>Fortunately, Fly.io CLI gives us two commands that would resolve both of the concerns above.</p><p>For reading the Environment variables inside our project, we can declare some secrets running the following in the terminal:</p><pre>fly secrets set TELEGRAM_BOT_TOKEN=&lt;&lt;BOT_TOKEN&gt;&gt;</pre><p>For persisting some data independently of our Fly.io instances, they provide what is called “volumes”. Those volumes will keep the data stored even if the applications crashes or are killed for some reason.</p><p>Configuring that was quite simple and straightforward. In the terminal running:</p><pre>fly volumes create BotChatListStorage --region ams</pre><p>And then including the configuration lines in <strong>fly.toml</strong> file:</p><pre>app = &quot;chat-notes-telegram-bot&quot;<br>kill_signal = &quot;SIGINT&quot;<br>kill_timeout = 5<br>processes = []<br><br>[env]<br>  PORT = &quot;8080&quot;<br><br>[experimental]<br>  auto_rollback = true<br><br>+[mounts]<br>+  destination = storage # Same path declared to store grammY sessions<br>+  source = &quot;BotChatListStorage&quot;<br><br>[[services]]<br>...</pre><p>By doing that, Fly.io will backup every file we store in the defined <strong>destination</strong> into the volume declared in <strong>source</strong>.</p><p>Then finally, everything was ready to be deployed:</p><pre>fly deploy</pre><h4><strong>Conclusion</strong></h4><p>My intentions with this particular project were not to build the most incredible and well structured project. Nor that this is the most brilliant solution to deal with the tool I wanted to create in the beginning. Many people that read this could think of several other solutions, more efficient code, a different platform to host the project, etc.</p><p>My only intention with this article is to share this quick demonstration of how those two tools are quite interesting and simple to use. I was really amazed after concluding all this feature in no longer than two hours. In contrast to the app I made from scratch, that took me more than a week to finish. There are countless tools and technologies around there that allow us to achieve great things. We just need to find the right ones for the things we need.</p><p>I hope that this small story of mine and this pseudo-tutorial can also spark ideas and the will of learning something new to anyone that reads this. In the same way it happened to me after listening to my friend’s story.</p><p>A special thanks to my friend @<a href="https://armand1m.dev/">Armando Magalhães</a> for giving me the insight and all the support that I needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93d98064de6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>