<?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>UBOS Community: vova</title>
    <description>The latest articles on UBOS Community by vova (@blue_skies).</description>
    <link>https://community.ubos.tech/blue_skies</link>
    <image>
      <url>https://community.ubos.tech/uploads/user/profile_image/5/c0688b8c-300c-4a49-8625-ee315bcbd775.jpg</url>
      <title>UBOS Community: vova</title>
      <link>https://community.ubos.tech/blue_skies</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://community.ubos.tech/feed/blue_skies"/>
    <language>en</language>
    <item>
      <title>How to publish a template?</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Tue, 27 Jun 2023 09:23:04 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/how-to-publish-a-template-4ied</link>
      <guid>https://community.ubos.tech/blue_skies/how-to-publish-a-template-4ied</guid>
      <description>&lt;p&gt;UBOS offers a solution that allows you to create your own templates with ease and speed. In this article, we will consider the process of creating your own template on UBOS, which will consist of a &lt;strong&gt;frontend&lt;/strong&gt; and a &lt;strong&gt;backend&lt;/strong&gt; part&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1. Publishing the project on GIT
&lt;/h2&gt;

&lt;p&gt;Our template consists of UI and Node Red. These are two different services that need to be &lt;a href="https://community.ubos.tech/anastasiia/how-to-connect-ui-editor-and-node-red-to-git-120f"&gt;connected to GIT&lt;/a&gt;.&lt;br&gt;
Templates developed by our team are stored on &lt;a href="https://github.com/UBOS-tech#templates"&gt;GitHub&lt;/a&gt; but you can also use GitLab&lt;br&gt;
namespace: &lt;code&gt;ubos-template-AI-task-manager-UI / ubos-template-AI-task-manager-NR&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2. Publication of the template on the UBOS platform
&lt;/h2&gt;

&lt;p&gt;You need to open the &lt;strong&gt;Template Manager&lt;/strong&gt; tab. Where you can fill in all the information about the template&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;This is the main template creation screen&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/-REECrh60wKjExLhbk3y9CZ8-pA6rcIWL-exQC0r-P8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdm11/ZHBqcG01NXR5czQ3/bnFjNGoucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/-REECrh60wKjExLhbk3y9CZ8-pA6rcIWL-exQC0r-P8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdm11/ZHBqcG01NXR5czQ3/bnFjNGoucG5n" alt="Image description" width="880" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you select Status &lt;strong&gt;private&lt;/strong&gt;, another field will appear in which you need to write the mail of the user to whom this template will be available. The number of users is not limited.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/CjrIE47bffclcL8eODVAzCFGYfCEwQd4aLcXeWSW4Cs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdm01/bm16NWV4Z3c0Ympy/NmtxZm4ucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/CjrIE47bffclcL8eODVAzCFGYfCEwQd4aLcXeWSW4Cs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdm01/bm16NWV4Z3c0Ympy/NmtxZm4ucG5n" alt="Image description" width="880" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Photo&lt;/strong&gt; button opens a modal window where you can upload screenshots of the template.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Various information will be displayed on the template details page. If the Demo URL field is filled in, an iframe with this link will be displayed, and if screenshots are loaded, the gallery will be displayed&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;strong&gt;Service&lt;/strong&gt; button opens a modal window where you need to fill in information about the service that will be in the template. Each service must be described and added separately&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/oosdQNcm9pndQLnLuHoZCShIIqOrO71lnXzAgmBNU-k/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMXU0/ZHA0bHl1bzN5MWth/Y3prY3UucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/oosdQNcm9pndQLnLuHoZCShIIqOrO71lnXzAgmBNU-k/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMXU0/ZHA0bHl1bzN5MWth/Y3prY3UucG5n" alt="Image description" width="880" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we indicate the link to the GIT service that we connected at the beginning of the article, the type and size of the service.&lt;/p&gt;

&lt;p&gt;Each service can contain an ENV (optional). Here you can write api keys, constants and refer to another service that will be in this template.&lt;br&gt;
For example, the template consists of two services &lt;strong&gt;UI&lt;/strong&gt; (frontend) and &lt;strong&gt;NodeRED&lt;/strong&gt; (backend). The &lt;strong&gt;UI&lt;/strong&gt; service has an &lt;strong&gt;API&lt;/strong&gt; that sends requests to &lt;strong&gt;NodeRED&lt;/strong&gt;. In order not to manually add a link to the backend to each &lt;strong&gt;API&lt;/strong&gt;, you can add a link that will be generated when the template is loaded to &lt;strong&gt;ENV&lt;/strong&gt;. How to do it?&lt;br&gt;
ENV consists of a key and a value. &lt;strong&gt;Service unique name&lt;/strong&gt; should be specified in the value, which should start with &lt;strong&gt;$&lt;/strong&gt; &lt;code&gt;$pineconeAIBotNR&lt;/code&gt;. Before downloading, a link to the service is created, and if a service with that name exists, a link to it is written there&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Integration&lt;/strong&gt; button opens a modal window where you need to add icons with which services the template interacts with&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/TqNpzb7ILYlCOF_gwWFAH6h2mnCfhMVWb6ObqgmgaxA/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMveGN4/bzh6aGNqb2EwN3Vs/enY1eWwucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/TqNpzb7ILYlCOF_gwWFAH6h2mnCfhMVWb6ObqgmgaxA/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMveGN4/bzh6aGNqb2EwN3Vs/enY1eWwucG5n" alt="Image description" width="880" height="934"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After filling in the information about the template, you need to press the &lt;strong&gt;Create new template&lt;/strong&gt; button&lt;/p&gt;

&lt;p&gt;The template will appear on the &lt;strong&gt;My templates&lt;/strong&gt; page. There you can view, edit, delete and publish it&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/J7zFJX4wBe_lq2drj108O865zln7PZmt5rg05lOczKo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGxp/ZjFiZzE0bnZ0eHVl/djF4MHAucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/J7zFJX4wBe_lq2drj108O865zln7PZmt5rg05lOczKo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGxp/ZjFiZzE0bnZ0eHVl/djF4MHAucG5n" alt="Image description" width="880" height="502"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Dear users,&lt;/p&gt;

&lt;p&gt;We are not responsible for the templates you create on UBOS. Please keep in mind that we provide tools for creating templates, but we do not control their content and functionality.&lt;/p&gt;

&lt;p&gt;You are solely responsible for the selection, development and use of templates on UBOS. We recommend that you review and test the templates you create before using them to ensure they are safe and fit your needs.&lt;/p&gt;

&lt;p&gt;We do our best to ensure the security and reliability of the UBOS platform, but we cannot guarantee that the templates you create will be error-free or meet your needs. Use them at your own risk.&lt;/p&gt;

&lt;p&gt;Sincerely,&lt;br&gt;
The UBOS team&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>How to download a template?</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Tue, 27 Jun 2023 08:19:01 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/how-to-download-a-template-384b</link>
      <guid>https://community.ubos.tech/blue_skies/how-to-download-a-template-384b</guid>
      <description>&lt;p&gt;Low code platforms are becoming increasingly popular among software developers who are looking for fast and efficient ways to create applications with less coding. UBOS is one such platform that offers an easy way to download ready-made templates. In this article, we will look at the process of uploading templates to UBOS and provide examples to better understand this technology.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1. Choosing a template
&lt;/h2&gt;

&lt;p&gt;Choose the appropriate template for your project. UBOS provides a collection of ready-made &lt;a href="https://ubos.tech/templates" rel="noopener noreferrer"&gt;templates&lt;/a&gt; that cover a variety of areas, including AI, bots, e-commerce, and more.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2. Choice of workspace and download type
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/j2vojm6ivxowtjf4xo7k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/j2vojm6ivxowtjf4xo7k.png" alt="Image description" width="1306" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Fork Template&lt;/strong&gt; button allows you to download a template in one click without additional settings&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Advanced Mode&lt;/strong&gt; button allows you to make additional settings for template services. This is editing the name of services and ENV&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/nvdey2iwaj43zbqxaa9b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/nvdey2iwaj43zbqxaa9b.png" alt="Image description" width="2880" height="1642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3. Download process
&lt;/h2&gt;

&lt;p&gt;If you used &lt;strong&gt;Advanced Mode&lt;/strong&gt;, you need to press the &lt;strong&gt;Fork template&lt;/strong&gt; button. After that, a page with the status of the template services will appear&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;When all services are loaded, the status will change. The download process is complete.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/os4a1osztdsixnsszdjh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/os4a1osztdsixnsszdjh.png" alt="Image description" width="2880" height="1800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can view information about the service, change the ENV, stop or delete the service&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Dear users,&lt;/p&gt;

&lt;p&gt;You are solely responsible for the selection, development and use of templates on UBOS. We recommend that you review and test the templates you create before using them to ensure they are safe and fit your needs.&lt;/p&gt;

&lt;p&gt;We do our best to ensure the security and reliability of the UBOS platform, but we cannot guarantee that the templates you create will be error-free or meet your needs. Use them at your own risk.&lt;/p&gt;

&lt;p&gt;Sincerely,&lt;br&gt;
The UBOS team&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>Creating a MongoDB Database</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Wed, 21 Jun 2023 21:16:36 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/creating-a-mongodb-database-5go</link>
      <guid>https://community.ubos.tech/blue_skies/creating-a-mongodb-database-5go</guid>
      <description>&lt;p&gt;Most programs require data storage. On the UBOS platform, you can use an external database or configure your own. To create a new database, you need to open Services by clicking the "+" button, choose the desired database, and configure it. &lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/ygp2pnigzb906jg1byvz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/ygp2pnigzb906jg1byvz.png" alt="Image description" width="1822" height="691"&gt;&lt;/a&gt;&lt;br&gt;
Once a green indicator appears in the left sidebar next to the created database, open the modal window where you can configure the new database.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/1xlq2nfsschs4ksoy01i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/1xlq2nfsschs4ksoy01i.png" alt="Image description" width="1852" height="883"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use the MongoDB database in the Node-RED environment, you need to add nodes for working with MongoDB. Follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the Node-RED interface or editor.&lt;/li&gt;
&lt;li&gt;Click on the menu icon (usually represented by three horizontal lines) to expand the menu options.&lt;/li&gt;
&lt;li&gt;Select "&lt;em&gt;Manage Palette&lt;/em&gt;" from the menu.&lt;/li&gt;
&lt;li&gt;In the Manage Palette window, click on the "&lt;em&gt;Install&lt;/em&gt;" tab.&lt;/li&gt;
&lt;li&gt;Search for "&lt;strong&gt;&lt;a href="https://flows.nodered.org/node/node-red-node-mongodb" rel="noopener noreferrer"&gt;node-red-node-mongodb&lt;/a&gt;&lt;/strong&gt;" in the search bar.&lt;/li&gt;
&lt;li&gt;Once you find the "&lt;strong&gt;&lt;a href="https://flows.nodered.org/node/node-red-node-mongodb" rel="noopener noreferrer"&gt;node-red-node-mongodb&lt;/a&gt;&lt;/strong&gt;" package, click the "&lt;em&gt;Install&lt;/em&gt;" button next to it.&lt;/li&gt;
&lt;li&gt;Wait for the installation process to complete.&lt;/li&gt;
&lt;li&gt;After the installation is finished, you can start using the MongoDB nodes in your Node-RED flows.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By installing the "node-red-node-mongodb" package, you will have access to the necessary nodes for working with MongoDB within the Node-RED environment.&lt;/p&gt;

&lt;p&gt;After the installation, the downloaded nodes will appear in the list of available nodes.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/fejlememwoeizxcnq79a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/fejlememwoeizxcnq79a.png" alt="Image description" width="168" height="273"&gt;&lt;/a&gt;&lt;br&gt;
Next, you need to enter the data of the created database into the node.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mongodb in - find, cound, aggregate&lt;/li&gt;
&lt;li&gt;mongodb out - save, insert, update, remove
 
 
 
 

&lt;img src="https://community.ubos.tech/uploads/articles/zq4bp7pvtcpqldv79aj3.png" alt="Image description" width="685" height="733"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After filling in the data, you need to click on the "Update" button, followed by "Done" and then click on "Deploy". If the data has been entered correctly, the text "connected" will appear below the node, indicating a successful connection.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/al5nxwj0w18ipdif0whb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/al5nxwj0w18ipdif0whb.png" alt="Image description" width="189" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Additional Information:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://community.ubos.tech/vika/crud-operations-on-the-ubos-platform-for-beginners-part-1-4kp6"&gt;How to add items to the database?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://community.ubos.tech/vika/crud-operations-on-the-ubos-platform-for-beginners-part-2get-4bef"&gt;How to retrieve added items?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Introduction and familiarization with the UI Editor environment</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Wed, 21 Jun 2023 20:18:31 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/introduction-and-familiarization-with-the-ui-editor-environment-ank</link>
      <guid>https://community.ubos.tech/blue_skies/introduction-and-familiarization-with-the-ui-editor-environment-ank</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;
    UI Editor Layout
  &lt;/li&gt;
  &lt;li&gt;
    Widgets Pane
  &lt;/li&gt;
  &lt;li&gt;
    Adding UI Widgets
  &lt;/li&gt;
  &lt;li&gt;
    Widget Settings
  &lt;/li&gt;
  &lt;li&gt;
    Deploying UI
  &lt;/li&gt;
  &lt;li&gt;
    Working with API
  &lt;/li&gt;
  &lt;li&gt;
    API Panel
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;UI Editor Layout &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let's start with learning about the first tool in the UBOS ecosystem that will help us create dashboards, admin panels, CRUD applications, and other types of web applications quickly and almost without programming.&lt;/p&gt;

&lt;p&gt;To open the visual editor, you need to click "+", open the page &lt;strong&gt;Services&lt;/strong&gt;. &lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/dptmpamo9w6ynyeigace.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/dptmpamo9w6ynyeigace.png" alt="Image description" width="1906" height="743"&gt;&lt;/a&gt;&lt;br&gt;
On the creation page of UI EDditor select the desired package and change the name of your service.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/ua89k39v2lztxoqls74t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/ua89k39v2lztxoqls74t.png" alt="Image description" width="1600" height="885"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next you have to wait when opposite the name of your service in the side panel will appear a green sign and open it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/r9p72xwo4libtwvlw260.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/r9p72xwo4libtwvlw260.png" alt="Image description" width="624" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking on &lt;b&gt;UI Editor&lt;/b&gt;, it will open in the main workspace.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/m9jzv1cefr107en3rjz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/m9jzv1cefr107en3rjz4.png" alt="Image description" width="1912" height="891"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The UI editor has its own layout, which consists of 3 main windows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Sidebar - Helps create and organize pages, user interface widgets, and APIs for working with data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Page Editor - This is the canvas where you can drag and drop user interface widgets from the widget panel and design how your page will look. Each page has its own canvas.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Widget Settings - Displays the properties of the selected user interface widget on the canvas.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Widgets Pane &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The widget panel can be opened by clicking the "+" button on the current page. After opening the panel, you will see all the available widgets that can be dragged onto the page canvas to create the design of your page.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h3&gt;Adding UI Widgets &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Each widget from the widget panel can be dragged onto the page canvas to create the user interface. After placing a widget on the page canvas, you can customize it to align with the design of your page and the data you want to display.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h3&gt;Widget Settings &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt; 

&lt;p&gt;Each widget has a list of properties that can be customized in the &lt;strong&gt;WIDGET SETTINGS&lt;/strong&gt; window located on the right side of the UI editor. To open the widget settings window, simply click on the icon at the top of the widget. The widget properties can be used to modify the style, data, or behavior of the widget.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h3&gt;Deploying UI &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let's create a sample page consisting of 3 button widgets and 1 table widget. Try configuring the widgets on the page according to the example below:&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/fofceaa26ibwqv636neg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/fofceaa26ibwqv636neg.png" alt="Image description" width="963" height="291"&gt;&lt;/a&gt;&lt;br&gt;
Once the page is ready, it needs to be deployed to view it from an end-user perspective. To do this, click the &lt;b&gt;DEPLOY&lt;/b&gt; button on the top panel. In the modal window that appears, click &lt;b&gt;View Application&lt;/b&gt;, and a new tab will open in your browser with the URL for previewing your application.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h3&gt;Working with API &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To make your program dynamic, you will need specific data, which you can obtain by creating an API. You can visualize any data retrieved from the API call using the available widgets.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/51h0x844dcaftdwdbewp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/51h0x844dcaftdwdbewp.png" alt="Image description" width="855" height="193"&gt;&lt;/a&gt;&lt;br&gt;
You can create a new API by clicking the "+" button in the side menu on the current page. After clicking, you should see the API panel where you can edit the API properties.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h3&gt;API Panel &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Here you can modify your API using the REST interface. The API supports all REST HTTP methods: GET, POST, PUT, DELETE, PATCH. You can configure header values, body fields, and parameters.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/emnnxfxo2t9973bnsa04.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/emnnxfxo2t9973bnsa04.png" alt="Image description" width="1918" height="972"&gt;&lt;/a&gt;&lt;br&gt;
You can obtain values for the REST API from widgets by entering &lt;code&gt;{{ widgetName.propertyName }}&lt;/code&gt; in the field.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to use the "function" node?</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Wed, 21 Jun 2023 13:43:11 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/how-to-use-the-function-node-5589</link>
      <guid>https://community.ubos.tech/blue_skies/how-to-use-the-function-node-5589</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;
    Writing Functions
    &lt;ul&gt;
      &lt;li&gt;Example of how it should be done&lt;/li&gt;
      &lt;li&gt;Example of how it should not be done&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Multiple Outputs&lt;/li&gt;
  &lt;li&gt;Event Registration&lt;/li&gt;
  &lt;li&gt;Error Handling&lt;/li&gt;
  &lt;li&gt;Manage Palette&lt;/li&gt;
  &lt;li&gt;NPM Package&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;strong&gt;function&lt;/strong&gt; node allows you to execute JavaScript code for messages that are passed through it. The message is passed as an object named &lt;code&gt;msg&lt;/code&gt;, and by default, it will have a &lt;code&gt;msg.payload&lt;/code&gt; property that contains the body of the message.&lt;/p&gt;

&lt;p&gt;Other nodes can add their own properties to the message. They should be documented in their respective documentation.&lt;/p&gt;

&lt;h3&gt;Writing Functions &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The code entered in the &lt;em&gt;function&lt;/em&gt; node represents the body of the function. The simplest function returns the message as it is.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If a function returns &lt;code&gt;null&lt;/code&gt;, the message is not passed, and the flow terminates.&lt;/p&gt;

&lt;p&gt;The function must always return an &lt;code&gt;msg&lt;/code&gt; object. Returning a number or a string will result in an error.&lt;/p&gt;

&lt;p&gt;The returned message object does not necessarily have to be the same object that was passed. The function can construct a new object before returning it. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/jVsALVrSTNsxGXOativOZW5BGlpCEgdxAYxJh0xQRIM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOWw4/azRzb2Y0ZzZtb2pk/cWo4ZXIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/jVsALVrSTNsxGXOativOZW5BGlpCEgdxAYxJh0xQRIM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOWw4/azRzb2Y0ZzZtb2pk/cWo4ZXIucG5n" alt="Image description" width="880" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Creating a new message object will result in the loss of any properties from the received message. This can break certain flows, such as the HTTP In/Response flow, which requires the mandatory preservation of the &lt;code&gt;msg.req&lt;/code&gt; and &lt;code&gt;msg.res&lt;/code&gt; properties. In general, function nodes should return the message object they received after making any desired changes to its properties.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Example of how it should be done &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let's create a flow that returns the value of the request body. We'll use the &lt;strong&gt;http in&lt;/strong&gt; and &lt;strong&gt;http response&lt;/strong&gt; nodes (more details about them here).&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/bFp73AdkPxAFp_r6dD06SMtgDbniohsYbgp8pNEe-lk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMveGRn/aGp2ejliZTVvOHZ0/eXF3em0ucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/bFp73AdkPxAFp_r6dD06SMtgDbniohsYbgp8pNEe-lk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMveGRn/aGp2ejliZTVvOHZ0/eXF3em0ucG5n" alt="Image description" width="880" height="236"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;http in&lt;/strong&gt; node sends a message to the &lt;strong&gt;function&lt;/strong&gt; node with properties like &lt;code&gt;payload&lt;/code&gt;, &lt;code&gt;req&lt;/code&gt;, and &lt;code&gt;res&lt;/code&gt;. In the body of the function, we only need to update the specific value we want in &lt;code&gt;msg.payload&lt;/code&gt; without replacing the entire &lt;code&gt;msg&lt;/code&gt; object. Then the &lt;em&gt;http response&lt;/em&gt; node will understand that it needs to return the response to our request.&lt;/p&gt;

&lt;p&gt;Let's make a request using Postman.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/IfyZ5c8OkTyQcI-p9YIUhrNo-7ywmibRNVwk8fqrkEw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNWI2/bGJ5anprNmp1bGJx/cHc5eGYucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/IfyZ5c8OkTyQcI-p9YIUhrNo-7ywmibRNVwk8fqrkEw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNWI2/bGJ5anprNmp1bGJx/cHc5eGYucG5n" alt="Image description" width="880" height="274"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;We received the text that was passed in the request body as the response.&lt;/p&gt;

&lt;h3&gt;Example of how it should not be done &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let's modify the body of the function in the above-described flow to:&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/rUha7VCKJNhuf9XSupmdh8oCTkqZ3oevRBTOc1FTB1Y/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdXVh/ZGo2OWk0MzVnYzhy/cWx6NXgucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/rUha7VCKJNhuf9XSupmdh8oCTkqZ3oevRBTOc1FTB1Y/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdXVh/ZGo2OWk0MzVnYzhy/cWx6NXgucG5n" alt="Image description" width="880" height="255"&gt;&lt;/a&gt;&lt;br&gt;
In the console, we will receive the message &lt;strong&gt;"No response object"&lt;/strong&gt;. This happens because we created a new message object, and the &lt;em&gt;http response&lt;/em&gt; node doesn't know that it needs to return the response.&lt;/p&gt;

&lt;p&gt;Therefore, if you need to create new properties, you should assign them to &lt;code&gt;msg&lt;/code&gt; without creating a new object.&lt;/p&gt;

&lt;h3&gt;Multiple Outputs &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In the function node's editor, there is an option to change the number of outputs and the name of the function.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/H-mUpDItiM1gLY_amTbkUfWyW3jwVDihuO5W61wRrLs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdmtz/cjgzbXpzOWhvZzFm/c3prN2cucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/H-mUpDItiM1gLY_amTbkUfWyW3jwVDihuO5W61wRrLs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdmtz/cjgzbXpzOWhvZzFm/c3prN2cucG5n" alt="Image description" width="648" height="266"&gt;&lt;/a&gt;&lt;br&gt;
Let's add two outputs and change the name of the function.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/B52f0ltiWjfmR_0jsy7tA1qhyXdp0hupSUp90HbGVe4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcjdw/NWxydDNqcHUwaTBs/aWZhZGIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/B52f0ltiWjfmR_0jsy7tA1qhyXdp0hupSUp90HbGVe4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcjdw/NWxydDNqcHUwaTBs/aWZhZGIucG5n" alt="Image description" width="509" height="132"&gt;&lt;/a&gt;&lt;br&gt;
Now the function node has two outputs. The question arises: how do we control them? We need to use an &lt;code&gt;if&lt;/code&gt; statement and return an array of messages in its body. The number of messages in the array depends on the number of outputs, which are numbered from top to bottom.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (msg.payload.length &amp;gt; 0) {
    msg.payload = `array length: ${msg.payload.length}`;

    return [ null, msg ]
}

msg.payload = "Empty"
return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, let's consider that we have two outputs: &lt;code&gt;return [null, msg]&lt;/code&gt;. In the first output, we return &lt;code&gt;null&lt;/code&gt;, indicating that the function doesn't return anything on that output in this case. In the second output, we pass &lt;code&gt;msg&lt;/code&gt;. Therefore, if an array with multiple elements is passed to the function, the second output will return a string representing the length of the array. Otherwise, we return &lt;code&gt;return msg&lt;/code&gt; on the first output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/8cJjrgMzaGyqVM3Oa3PhF2cSi3HIoq-nJMa6VA40YmM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMHls/NjAxMjVyMW83M3Y0/M3BrdW8ucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/8cJjrgMzaGyqVM3Oa3PhF2cSi3HIoq-nJMa6VA40YmM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMHls/NjAxMjVyMW83M3Y0/M3BrdW8ucG5n" alt="Image description" width="649" height="114"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add another function node called "&lt;em&gt;data&lt;/em&gt;" that returns an array of objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msg.payload = [
    { name: "banana" },
    { name: "potato" }
];

return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/images/nqKFDIyUJvV2C8FuvQwEik7-c9EEM35nTM2tyTGnrkQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMva2J0/aTF6MDJxbDg3MnB0/YmE0cTkucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/nqKFDIyUJvV2C8FuvQwEik7-c9EEM35nTM2tyTGnrkQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMva2J0/aTF6MDJxbDg3MnB0/YmE0cTkucG5n" alt="Image description" width="880" height="195"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;We received true, so the message was sent to the second output. If we pass an empty array to the "data" function, the condition will not be met, and the message will be sent to the first output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msg.payload = [];
return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/images/DuhA8jHIhYTjT9gY-jBmGqz6uDdvjudWImeYPGr9MTw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcW51/dmEzc2lleG9kaHUx/ZnRwOWYucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/DuhA8jHIhYTjT9gY-jBmGqz6uDdvjudWImeYPGr9MTw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcW51/dmEzc2lleG9kaHUx/ZnRwOWYucG5n" alt="Image description" width="880" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Event Logging &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To effectively debug your code, it is important to understand what data is coming in and how it changes. For this purpose, you can use the following functions to log messages to the console (similar to &lt;code&gt;console.log()&lt;/code&gt; in JavaScript).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node.warn("Something happened");
node.error("Something bad happened");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's modify the example we discussed earlier. We'll add a loop that iterates over an array and prints its elements to the console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (msg.payload.length &amp;gt; 0) {
    node.warn("start if");

    for (const element of msg.payload) {
        node.warn(element);
    }

    return [ null, msg ]
}

msg.payload = "Empty"
return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/images/6P889GKwvpqdsNh01vkA_iVZrMTrmDGR7ZH-WBI7o9s/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZG1z/b2pjcGY3NjAyeGN0/ZHc5ajkucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/6P889GKwvpqdsNh01vkA_iVZrMTrmDGR7ZH-WBI7o9s/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZG1z/b2pjcGY3NjAyeGN0/ZHc5ajkucG5n" alt="Image description" width="716" height="373"&gt;&lt;/a&gt; &lt;br&gt;
You can see 3 &lt;code&gt;node.warn&lt;/code&gt; events in the console.&lt;/p&gt;

&lt;h3&gt;Error Handling &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If a function encounters an error and needs to terminate the execution flow, it should not return anything. To trigger a catch at a specific node, the function should call &lt;code&gt;node.error("error", msg)&lt;/code&gt;, passing the error message as the first argument and &lt;code&gt;msg&lt;/code&gt; as the second argument.&lt;/p&gt;

&lt;p&gt;Let's modify the previous example by adding an error to the &lt;code&gt;_data_&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msg.payload = [
    { name: "banana" },
    { name: "potato" }
];

node.error("Еrror", msg);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/images/5VPi7vmqDbx5O69MjJGxxLcT0BYGl5rSfk0mEFieh30/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMnAy/c3czcnRtbnRvb3Jm/dmhhbzIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/5VPi7vmqDbx5O69MjJGxxLcT0BYGl5rSfk0mEFieh30/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMnAy/c3czcnRtbnRvb3Jm/dmhhbzIucG5n" alt="Image description" width="880" height="255"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;_data_&lt;/code&gt; function returned an error, so the node stopped working.&lt;/p&gt;

&lt;h3&gt;Manage Palette &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To add additional Node-RED nodes to your project, you need to open the menu on the right and select the "Manage Palette" tab.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/MX8A62YzI6fNUJxh4cwsyzbjfAbNeb3J0W_4b20-EUc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMveHow/NXNhNGYwcWp4Z3Fk/ZGM3ZXcucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/MX8A62YzI6fNUJxh4cwsyzbjfAbNeb3J0W_4b20-EUc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMveHow/NXNhNGYwcWp4Z3Fk/ZGM3ZXcucG5n" alt="Image description" width="273" height="583"&gt;&lt;/a&gt; The "Nodes" tab contains the libraries that are already loaded, and in the "Install" tab, you need to enter the name of the library and install it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Before installing a library, it is advisable to familiarize yourself with its documentation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/2FZcLGXuc425ZIIgBqT1yH_jBHoGFZYBoS-9Ui9x9QU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvaDV4/dTc2NWxyMmxvcG91/bnU3ZTYucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/2FZcLGXuc425ZIIgBqT1yH_jBHoGFZYBoS-9Ui9x9QU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvaDV4/dTc2NWxyMmxvcG91/bnU3ZTYucG5n" alt="Image description" width="712" height="310"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;After installation, the newly installed nodes will appear in the list of all nodes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/A-0qUOuk5drWvrMxW_V0AJyrRh3KOC6I0AkubKlUYZo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvemQw/emd5YjdvdGI2YjV0/b2hjZGgucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/A-0qUOuk5drWvrMxW_V0AJyrRh3KOC6I0AkubKlUYZo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvemQw/emd5YjdvdGI2YjV0/b2hjZGgucG5n" alt="Image description" width="166" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;NPM package &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Node-RED allows you to fetch additional modules from the Node Package Manager (NPM). To do this, select the "function" node where you want to use the additional module and go to the "Setup" tab. In this tab, click the "add" button and enter the module you want to use. If such a module exists on the NPM platform, we can use it.&lt;/p&gt;

&lt;p&gt;Let's create a flow that takes an image, optimizes it, and flips it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Image] -&amp;gt; [Optimization Module] -&amp;gt; [Flip Module]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this flow, the "Image" node represents the input image, the "Optimization Module" performs image optimization, and the "Flip Module" flips the optimized image.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/_a7bizivbP8J-HpUdjE2ApmhkDQ7ouVXTEII0KTMQY8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZ2ht/ZTlyYWp4c3R5aG9w/d2E1aGYucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/_a7bizivbP8J-HpUdjE2ApmhkDQ7ouVXTEII0KTMQY8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZ2ht/ZTlyYWp4c3R5aG9w/d2E1aGYucG5n" alt="Image description" width="542" height="148"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Let's use the new "viewer" node that we previously installed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: To work with images, it is recommended to use the POST method and enable image uploads.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/kSXmzoAkWI_Ll6F4pvw_PaRzjSSYqyGENBexoMucCnc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvd3Nj/NGNjZDdkYnJ6Nmpx/MXpjNjYucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/kSXmzoAkWI_Ll6F4pvw_PaRzjSSYqyGENBexoMucCnc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvd3Nj/NGNjZDdkYnJ6Nmpx/MXpjNjYucG5n" alt="Image description" width="512" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's add the &lt;em&gt;sharp&lt;/em&gt; module for working with images.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/AYmsjUuDCMCCeNYSEAKKhyk1Xq1Ehwh67II0CyRKVPU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvanZq/eDdwcjBieGhpdmls/cGExcmkucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/AYmsjUuDCMCCeNYSEAKKhyk1Xq1Ehwh67II0CyRKVPU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvanZq/eDdwcjBieGhpdmls/cGExcmkucG5n" alt="Image description" width="648" height="819"&gt;&lt;/a&gt; У тіло функції додаємо логіку роботи з зображенням.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const optimized = await sharp(msg.req.files[0].buffer)
    .toFormat("jpeg", { quality: 60 })
    .flip()
    .toBuffer();

msg.payload = optimized;

return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will send the image using &lt;a href="https://www.postman.com/"&gt;Postman&lt;/a&gt;. The request body will be of type form-data. For the image, select the file type.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/lmEUviA7NtFkHjJjx-QECZA_cKP06CUYNuhj2kCbEQ8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOTJk/bmhwYTNpdTBidXd5/dmxzeTIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/lmEUviA7NtFkHjJjx-QECZA_cKP06CUYNuhj2kCbEQ8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOTJk/bmhwYTNpdTBidXd5/dmxzeTIucG5n" alt="Image description" width="848" height="349"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The result of the execution&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/T2PJHrZTHmA373wVufyebI-_IdvE_j_U_1NVsIIaIIc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvbGFm/YjYxZDdxMTFyM2U5/YzYxaTgucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/T2PJHrZTHmA373wVufyebI-_IdvE_j_U_1NVsIIaIIc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvbGFm/YjYxZDdxMTFyM2U5/YzYxaTgucG5n" alt="Image description" width="544" height="262"&gt;&lt;/a&gt; &lt;br&gt;
The request sends an image buffer stored at the following path: &lt;code&gt;msg.req.files[0].buffer&lt;/code&gt;. The weight of the sent image is &lt;code&gt;size: 414164&lt;/code&gt; (404 KB).&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/7VEcyMNfQK6UgksLAQmisZV5gv5pXUiqf_9zyXBYTco/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZzFj/Y2FmZTF3bG9pcWhx/dm1tbG0ucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/7VEcyMNfQK6UgksLAQmisZV5gv5pXUiqf_9zyXBYTco/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZzFj/Y2FmZTF3bG9pcWhx/dm1tbG0ucG5n" alt="Image description" width="248" height="203"&gt;&lt;/a&gt; The converted image weighs 292563 (285 KB).&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/TWIYPmVFoYh5JiAEoGk9SLfDLmpXV1GgzhZ4oova-Ig/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNXpm/NmU5YTViY3BkMHgx/aDczNWsucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/TWIYPmVFoYh5JiAEoGk9SLfDLmpXV1GgzhZ4oova-Ig/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNXpm/NmU5YTViY3BkMHgx/aDczNWsucG5n" alt="Image description" width="222" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>howtouse</category>
      <category>function</category>
      <category>npm</category>
      <category>managepalette</category>
    </item>
    <item>
      <title>Basic nodes in Node-RED</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Wed, 21 Jun 2023 13:14:00 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/basic-nodes-in-node-red-4co2</link>
      <guid>https://community.ubos.tech/blue_skies/basic-nodes-in-node-red-4co2</guid>
      <description>&lt;p&gt;To create flows in Node-RED, it is useful to understand how basic nodes work. In this article, you will learn about them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;inject&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;debug&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;function&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;http in&lt;/strong&gt; and &lt;strong&gt;http response&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;strong&gt;inject&lt;/strong&gt; node is used to manually trigger a flow by clicking the button on the left. It can also be set to automatically trigger at specific time intervals.&lt;/p&gt;

&lt;p&gt;The default &lt;strong&gt;inject&lt;/strong&gt; node has properties such as 'payload' and 'topic'. They accept various data types, such as object, buffer, global, string, number, boolean, and others.&lt;br&gt;
Double-clicking on the node opens its settings. Let's write the string "&lt;em&gt;Hello dev&lt;/em&gt;" in the payload. After any interaction with the node, remember to save the changes by clicking the &lt;strong&gt;Done&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/i0MfLRSi-vBQ-gbts8Ok_8XmFlaMM9LbwD_P3R3U2yU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMzB2/YWl6MmsyOTdpZXoz/Ymp3c3EucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/i0MfLRSi-vBQ-gbts8Ok_8XmFlaMM9LbwD_P3R3U2yU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMzB2/YWl6MmsyOTdpZXoz/Ymp3c3EucG5n" alt="Image description" width="880" height="589"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/yu2u2n98nnz0ngonf0ts.gif"&gt;https://community.ubos.tech/uploads/articles/yu2u2n98nnz0ngonf0ts.gif&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;The &lt;strong&gt;debug&lt;/strong&gt; node is used to display messages on the sidebar panel of the editor.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/h1MV6h-DaxuGXXcoYz8IGLtQnxq8SY29_GBIO4uZxTs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGVq/cmppcW9sN3B4NmZr/dzZwNTAucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/h1MV6h-DaxuGXXcoYz8IGLtQnxq8SY29_GBIO4uZxTs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGVq/cmppcW9sN3B4NmZr/dzZwNTAucG5n" alt="Image description" width="156" height="45"&gt;&lt;/a&gt;&lt;br&gt;
In the description of the &lt;strong&gt;inject&lt;/strong&gt; node, we used &lt;strong&gt;debug&lt;/strong&gt; to see the message sent by the node.&lt;br&gt;
The &lt;strong&gt;debug&lt;/strong&gt; node has the 'output' property:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;complete msg object - displays the entire object that is received&lt;/li&gt;
&lt;li&gt;msg allows you to display specific fields, for example, msg.payload
&lt;img src="https://community.ubos.tech/images/HptgCOoyzhYuMAWfuAHU3aQ-oy0XynZ0jGuVCWgxoUU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZmM1/OXdpZ3dvNHExb2l5/bjdjdzgucG5n" alt="Image description" width="830" height="326"&gt;
In the following examples, we will interact with other nodes and see more detailed usage of 'debug'.
---
The &lt;strong&gt;function&lt;/strong&gt; node allows you to run JavaScript code to process the data that is passed to the node.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/pwCpgMNzCyLJ-NQAzEDJT0UZCIvONmbBenNGKbP6nQ8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvandk/aGl3Njg5dnV4aHJr/MTRib2sucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/pwCpgMNzCyLJ-NQAzEDJT0UZCIvONmbBenNGKbP6nQ8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvandk/aGl3Njg5dnV4aHJr/MTRib2sucG5n" alt="Image description" width="144" height="44"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;The &lt;strong&gt;http in&lt;/strong&gt; and &lt;strong&gt;http response&lt;/strong&gt; nodes are used for handling incoming requests and sending responses in HTTP-based flows.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/3qxfgt6QnJSABwmB6oz7DO0CInDPeuc8uJB4-tSuiNY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMjdw/dHYyMWF3Y2s2NTZw/NnU3ZmwucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/3qxfgt6QnJSABwmB6oz7DO0CInDPeuc8uJB4-tSuiNY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMjdw/dHYyMWF3Y2s2NTZw/NnU3ZmwucG5n" alt="Image description" width="145" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;http in&lt;/strong&gt; node receives incoming requests. In this node, you need to select the method and specify the URL. In our example, the method is &lt;em&gt;GET&lt;/em&gt;, and the URL is &lt;em&gt;/total&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/aWHNMvHDzzAKFcY2dEvsoXqLAwlvwY39F1nhjFEW-Kk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdDc0/Y3lpcXY4dHowaTN2/d2I1NjUucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/aWHNMvHDzzAKFcY2dEvsoXqLAwlvwY39F1nhjFEW-Kk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdDc0/Y3lpcXY4dHowaTN2/d2I1NjUucG5n" alt="Image description" width="510" height="271"&gt;&lt;/a&gt;&lt;br&gt;
The &lt;strong&gt;http response&lt;/strong&gt; node is used to send a response. This node should always receive a &lt;code&gt;payload&lt;/code&gt; property in order to return information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/HhQFxPkFB-7vG_wnGBrMmSKHrL_K2X-MHfFK3ez0W-k/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcm5j/a2IxdmQxY3RzNzBx/dHdiY3QucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/HhQFxPkFB-7vG_wnGBrMmSKHrL_K2X-MHfFK3ez0W-k/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcm5j/a2IxdmQxY3RzNzBx/dHdiY3QucG5n" alt="Image description" width="531" height="826"&gt;&lt;/a&gt; &lt;br&gt;
Any flow that starts with an &lt;strong&gt;http in&lt;/strong&gt; node should end with an &lt;strong&gt;http response&lt;/strong&gt; node. Otherwise, it won't return a response to the request.&lt;/p&gt;

&lt;p&gt;Let's create a flow that takes two values and returns their sum.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/tRiZnQsXx6lczcm9LGjv0SnHKjk5zOGqiiv8IM5ULRU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMzZj/dXZ1czY3a3dkMHpp/YXY2OXcucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/tRiZnQsXx6lczcm9LGjv0SnHKjk5zOGqiiv8IM5ULRU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMzZj/dXZ1czY3a3dkMHpp/YXY2OXcucG5n" alt="Image description" width="560" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function&lt;/strong&gt; node.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const body = msg.req.body;
const total = body.banana + body.tomato;

msg.statusCode = 200;
msg.payload = {
    "total": total
};

return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy the link to your Node-RED where the flow is saved and append the URL &lt;em&gt;/total&lt;/em&gt; to it.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/Sy3Os07ZGLrLyecTtaxtqTltvtw5sbsXXLWq-j5AEx8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcW81/ZHd1aTNvaDJtNjB0/dnpkbjIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/Sy3Os07ZGLrLyecTtaxtqTltvtw5sbsXXLWq-j5AEx8/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcW81/ZHd1aTNvaDJtNjB0/dnpkbjIucG5n" alt="Image description" width="339" height="181"&gt;&lt;/a&gt;&lt;br&gt;
To make a request, we will use Postman. In the body, pass the data that will be sent in our request and click the Send button.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/fRUjqAL44qwcLmZ1xzTn3xKGh8-iTUbz3mwdeZJJCH0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNzR1/ZnJ2czB1NWJ1a3N0/eWxtamUucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/fRUjqAL44qwcLmZ1xzTn3xKGh8-iTUbz3mwdeZJJCH0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNzR1/ZnJ2czB1NWJ1a3N0/eWxtamUucG5n" alt="Image description" width="880" height="267"&gt;&lt;/a&gt;&lt;br&gt;
In the &lt;strong&gt;http in&lt;/strong&gt; node, an object is received which has the property &lt;code&gt;req&lt;/code&gt; (this is the request object that contains information about the request).&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/0NxSoseSUft0HIOy4sgehJ_OTMQBk1qZJjsNyQst8yM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZGl0/b2Z4eHFsMmpvNDdn/ZzJ1MDMucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/0NxSoseSUft0HIOy4sgehJ_OTMQBk1qZJjsNyQst8yM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvZGl0/b2Z4eHFsMmpvNDdn/ZzJ1MDMucG5n" alt="Image description" width="880" height="381"&gt;&lt;/a&gt; Using the debug node, you can see what is being received in other nodes.&lt;/p&gt;

</description>
      <category>debug</category>
      <category>http</category>
      <category>function</category>
      <category>inject</category>
    </item>
    <item>
      <title>Introduction and familiarization with the Node-RED environment</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Wed, 21 Jun 2023 12:39:49 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/introduction-and-familiarization-with-the-node-red-environment-2hio</link>
      <guid>https://community.ubos.tech/blue_skies/introduction-and-familiarization-with-the-node-red-environment-2hio</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;
    Creating new Flow service
  &lt;/li&gt;
  &lt;li&gt;
    Flow Builder Layout
  &lt;/li&gt;
  &lt;li&gt;
    Creating first HTTP Endpoint
  &lt;/li&gt;
  &lt;li&gt;
    Connecting API to HTTP Endpoint
  &lt;/li&gt;
  &lt;li&gt;
    Displaying data on UI
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flow Builder allows you to create powerful workflows that can integrate with a wide range of external systems and implement complex logic for your application. Within a single workspace, you can have multiple instances of Flow Builder that can be combined or created as separate microservices.&lt;/p&gt;

&lt;p&gt;Flow Builder is based on the open-source Node-RED system. Node-RED is a visual tool developed by IBM Emerging Technology and the open-source community for API development, Internet of Things (IoT) devices, and various online services. You can create intricate flows using a wide array of nodes and modules (3100+) and expand the functionality of your flow using any of the Node.js packages available in the public repository (225,000+), or create your own custom nodes.&lt;/p&gt;

&lt;h3&gt;Creating a New Flow Service &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;On the UBOS platform, to create a new Flow Builder service. , you need to open Services by clicking the "+" button, choose the section "Node Red", and configure it.&lt;/p&gt;

&lt;p&gt;Once you have selected "&lt;em&gt;service plan&lt;/em&gt;" and filled "&lt;em&gt;name&lt;/em&gt;" field, click the &lt;b&gt;Create Service&lt;/b&gt; button, and the UBOS platform will start the installation process for your new service. On average, this process may take 1-2 minutess. Until the service becomes available to you, it will be in a pending state, and you can find it in the dropdown list of NodeRed in the service manager.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/QL5VnnjW4js9VT3VSbkBKhiiF8AmhnD303e6uL9K_Hk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvb3J2/bGtzYzZoc2M2bmpo/NXF1MHgucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/QL5VnnjW4js9VT3VSbkBKhiiF8AmhnD303e6uL9K_Hk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvb3J2/bGtzYzZoc2M2bmpo/NXF1MHgucG5n" alt="Image description" width="880" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the new service becomes available, to open it, you need to click on the name of the service, and it will open in the Main Workspace.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/cFNCRyUqz65fWhnaRd9bGC2RrnDfE1zVW1OTUs7BOfk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGhj/OGltcXZhYTFkM2Ft/cWdncnoucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/cFNCRyUqz65fWhnaRd9bGC2RrnDfE1zVW1OTUs7BOfk/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGhj/OGltcXZhYTFkM2Ft/cWdncnoucG5n" alt="Image description" width="880" height="445"&gt;&lt;/a&gt;&lt;br&gt;
Upon clicking the name of your environment for the first time, Node-RED will provide you with the option to create a new project or copy an existing one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/rFs2A35uqs4aUwQd21NAYYmTXcCis9pQJQviBR1hw5w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvbjdn/OWIwcnVlZnVpNGo3/cmZzazIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/rFs2A35uqs4aUwQd21NAYYmTXcCis9pQJQviBR1hw5w/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvbjdn/OWIwcnVlZnVpNGo3/cmZzazIucG5n" alt="Image description" width="880" height="501"&gt;&lt;/a&gt; &lt;br&gt;
The scenario of copying an existing project is not being discussed at the moment. To create a new project, you need to click on the field labeled "Create Project". After that, you should fill in the following fields: Username, Email, Project name, description (optional), leave the project Flow file field unchanged, and select Credentials: Disable encryption.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/pRVsu5QxwwsSaQahWYtQ_wBRDy2dcFyKQpwrkIoGQV0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGti/NGh1MDFtdnNkbzhv/dGphbzgucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/pRVsu5QxwwsSaQahWYtQ_wBRDy2dcFyKQpwrkIoGQV0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNGti/NGh1MDFtdnNkbzhv/dGphbzgucG5n" alt="Image description" width="880" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/l-xEOJpbqNUp396bjyGDoXiE7iDlSiD8LqlR-gU2fc4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvamxw/d3B1bjh0dDRqOWxq/dzNkNHIucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/l-xEOJpbqNUp396bjyGDoXiE7iDlSiD8LqlR-gU2fc4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvamxw/d3B1bjh0dDRqOWxq/dzNkNHIucG5n" alt="Image description" width="880" height="501"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/W1LJeFnWuFdO4TEK9cnzicMiu18ZNNSIl-ZjcaEDElQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcm05/eGhkeXJrNml5aDlj/YTg0dTAucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/W1LJeFnWuFdO4TEK9cnzicMiu18ZNNSIl-ZjcaEDElQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvcm05/eGhkeXJrNml5aDlj/YTg0dTAucG5n" alt="Image description" width="880" height="499"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/aVKgv3wLVaBuq2U64y8QkRv0tJvod2ufAA3Y6z7INZ0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOXNi/NDY4cXg1eGs4dG8y/Z2djdnMucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/aVKgv3wLVaBuq2U64y8QkRv0tJvod2ufAA3Y6z7INZ0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOXNi/NDY4cXg1eGs4dG8y/Z2djdnMucG5n" alt="Image description" width="880" height="499"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/xQxKLEg1rnDxaIKfKi2F4F4WoxgdjEbqnYasakXaTEY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvamIz/ZmRvb200bm1nOXc0/djZiaXAucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/xQxKLEg1rnDxaIKfKi2F4F4WoxgdjEbqnYasakXaTEY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvamIz/ZmRvb200bm1nOXc0/djZiaXAucG5n" alt="Image description" width="880" height="500"&gt;&lt;/a&gt; Once you see this message, the Node-RED environment is ready for use.&lt;/p&gt;

&lt;h3&gt;Flow Builder Layout &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/eDnyeeMkZ2oCg632UDYNJsSWGsr5pKfmSqqRYVxCUvI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvbHgy/dTNtaXQzZXRwb3E5/cG1xaXQucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/eDnyeeMkZ2oCg632UDYNJsSWGsr5pKfmSqqRYVxCUvI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvbHgy/dTNtaXQzZXRwb3E5/cG1xaXQucG5n" alt="Image description" width="880" height="449"&gt;&lt;/a&gt;&lt;br&gt;
The basic layout of Flow Builder consists of four main areas:&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Header&lt;/b&gt; - Here you can find various deployment options for your flow and the main Flow Builder menu.&lt;br&gt;
&lt;b&gt;Palette&lt;/b&gt; - It contains all the available nodes that can be used.&lt;br&gt;
&lt;b&gt;Workspace&lt;/b&gt; - This is the area where you create your flows.&lt;br&gt;
&lt;b&gt;Sidebar&lt;/b&gt; - It contains tabs that provide a wide range of useful tools within the editor.&lt;/p&gt;

&lt;h3&gt;Creating first HTTP Endpoint &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Let's create a simple HTTP endpoint that returns the static text "Hello World!". Drag and drop several nodes from the palette onto the workspace.&lt;br&gt;
First, you need to find the &lt;b&gt;HTTP In&lt;/b&gt; node, drag it onto the workspace, and double-click to open the node's settings.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;The HTTP In node will listen for incoming requests. In the settings window, you need to select the method, which will be GET, and specify the endpoint name /hello in the URL field. Then, click the &lt;b&gt;Done&lt;/b&gt; button in the settings window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/zrkm4iCY3Mf8szMX4KfR963tY_MshhlRwHQIVAethxY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMnMy/bHB6b3N1c3l6bmZn/MGowaGcucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/zrkm4iCY3Mf8szMX4KfR963tY_MshhlRwHQIVAethxY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMnMy/bHB6b3N1c3l6bmZn/MGowaGcucG5n" alt="Image description" width="521" height="300"&gt;&lt;/a&gt;&lt;br&gt;
Next, let's find the &lt;strong&gt;function&lt;/strong&gt; node, drag it into the workspace, and connect it to the "HTTP In" node.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;&lt;b&gt;function&lt;/b&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/-WYr4S0WaIqvatllpLnWpmbNlopTPiHW-OzyqaIkzpE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMThi/YXZtbXA3azUybmpo/Zm91M2YucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/-WYr4S0WaIqvatllpLnWpmbNlopTPiHW-OzyqaIkzpE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvMThi/YXZtbXA3azUybmpo/Zm91M2YucG5n" alt="Image description" width="880" height="858"&gt;&lt;/a&gt; &lt;br&gt;
Flow needs to respond to the request with data from the Function node. To achieve this, let's find the &lt;b&gt;HTTP Response&lt;/b&gt; node and connect it to the Template node.&lt;br&gt;
Your flow should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/PQGHXEeSB2WuGTFRvjtwcUhrSTKdnfAZe7pOJopBmw0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOTBl/MGxmcDYyYTE0dGM2/amJxemUucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/PQGHXEeSB2WuGTFRvjtwcUhrSTKdnfAZe7pOJopBmw0/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvOTBl/MGxmcDYyYTE0dGM2/amJxemUucG5n" alt="Image description" width="448" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you need to deploy your flow to make it accessible. To do this, click the &lt;b&gt;Deploy&lt;/b&gt; button in the flow editor's header.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/yOb6oezR4t4eoAeZPj_dPucsEd2goTbNa6HauRAd26c/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNnQ2/bW9kY3JiZndvYWlw/enRjaHkucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/yOb6oezR4t4eoAeZPj_dPucsEd2goTbNa6HauRAd26c/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvNnQ2/bW9kY3JiZndvYWlw/enRjaHkucG5n" alt="Image description" width="374" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Connecting API to HTTP Endpoint &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To connect an API to the HTTP endpoint, switch the editor to the UI Editor. In the UI editor, open the list of available APIs for the current page by clicking on the "APIS" row and selecting "API1" from the list to open the API panel.&lt;/p&gt;

&lt;p&gt;If you don't see "API1" in the list, you can create a new one by clicking the "+" button in the "APIS" row.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;Next, you need to add a link to the endpoint. You should copy the link to Node-RED and add the API name.&lt;/p&gt;

&lt;p&gt;Copy the link to Node-RED, and let's add the API name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/images/BONMR0RGuWtHdHsQdtsQGRkJB77t92XZR9mfrFwKlLY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdHRj/MHhjMXd5ZXRhOWFz/dWdqMjkucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/BONMR0RGuWtHdHsQdtsQGRkJB77t92XZR9mfrFwKlLY/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvdHRj/MHhjMXd5ZXRhOWFz/dWdqMjkucG5n" alt="Image description" width="275" height="260"&gt;&lt;/a&gt;&lt;br&gt;
To test the API, you need to click the &lt;b&gt;Run&lt;/b&gt; button, and you will see the response in the Response field.&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/JPrwac_-TVmkvhKZ3_M5qYdM97Ia_BXcxDUsypySv_k/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvczZy/YTcwcGg4Y3NuOTQ0/aWNidTgucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/JPrwac_-TVmkvhKZ3_M5qYdM97Ia_BXcxDUsypySv_k/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvczZy/YTcwcGg4Y3NuOTQ0/aWNidTgucG5n" alt="Image description" width="880" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To close the API panel, click the &lt;b&gt;Back&lt;/b&gt; button.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Displaying data on the UI &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To display data in the user interface, we need to have two widgets. One widget will be a button widget that triggers API1, and the other will be a text widget that displays the response.&lt;br&gt;
You can add a new "Button" widget to the page editor or use existing ones. Next, open the "SettingsWidget" window for the "Button" widget. At the bottom of the window, you will find the "Action" section and a property called &lt;b&gt;onClick&lt;/b&gt;. Click on this field, and you will see a list of available actions.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;After selecting API1, you will see that the onClick property has changed. So, when you click this button, it will trigger our API1, which will make an HTTP request to our Example.&lt;/p&gt;

&lt;p&gt;Now let's display the response data from API1 in a text widget. To do this, you need to drag a new text input widget from the widget panel into the page editor and open the widget's settings window.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;In the Widget Settings window, locate the default &lt;b&gt;Text&lt;/b&gt; property. In this property, you can enter static text or add dynamic data. We want to add dynamism to display the response data from API1. To do this, you need to enter a command inside the Text property.&lt;/p&gt;

&lt;p&gt;The command should look like this: &lt;code&gt;{{Api1.data}}&lt;/code&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/images/GEaTyWzyiiT0sa_imZTmYkUikq0j29nk_kVbilA_4x4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvM255/NHlsaWhvaWdhdTl3/ZW9zanoucG5n" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/images/GEaTyWzyiiT0sa_imZTmYkUikq0j29nk_kVbilA_4x4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkudWJvcy50/ZWNoL3VwbG9hZHMv/YXJ0aWNsZXMvM255/NHlsaWhvaWdhdTl3/ZW9zanoucG5n" alt="Image description" width="294" height="200"&gt;&lt;/a&gt;&lt;br&gt;
To test the changes, let's deploy the user interface application and check the modifications. Try clicking the button you have configured and observe the data that appears in the input fields intended to display the data.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

</description>
      <category>nodered</category>
      <category>flow</category>
      <category>endpoint</category>
    </item>
    <item>
      <title>Conditional | node-red + mongoDB</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Wed, 17 Aug 2022 10:35:32 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/conditional-node-red-mongodb-4nk4</link>
      <guid>https://community.ubos.tech/blue_skies/conditional-node-red-mongodb-4nk4</guid>
      <description>&lt;p&gt;$cond використовується коли необхідно виконати певний блок коду якщо виконується певна умова.&lt;br&gt;
Умова виконується якщо сама умова &lt;em&gt;if&lt;/em&gt; дорівнює &lt;em&gt;true&lt;/em&gt;, тоді виконується блок &lt;em&gt;then&lt;/em&gt; в іншому випадку виконується блок else бо умова дорівнює &lt;em&gt;false&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Вираз &lt;em&gt;$cond&lt;/em&gt; має один із двох синтаксисів які очікуюсь три аргументи if-then-else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ $cond: { if: &amp;lt;boolean-expression&amp;gt;, then: &amp;lt;true-case&amp;gt;, else: &amp;lt;false-case&amp;gt; } }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Або&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ $cond: [ &amp;lt;boolean-expression&amp;gt;, &amp;lt;true-case&amp;gt;, &amp;lt;false-case&amp;gt; ] }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Приклад
&lt;/h2&gt;

&lt;p&gt;Колекція products містить в собі наступні документи:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    {
        _id: "62cbbabab8fa90001118e138",
        "deleted": false,
        "name": "keyboard",
        "price": 2500
    },
    {
        _id: "62cbbabab8fa90001118e139",
        "deleted": false,
        "name": "monitor",
        "price": 3000
    },
    {
        _id: "62cbbabab8fa90001118e13a",
        "deleted": false,
        "name": "mouse",
        "price": 700
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Операція агрегації використовує &lt;em&gt;$cound&lt;/em&gt; для того щоб зробити знижку на товар. Якщо ціна товару більша за 2000, то у полі newPrice буде ціна із знижкою 10%. Якщо ціна менша за 2000 тоді вона залишається без змін.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msg.collection = "products";
msg.payload = [
    {
        $match: { deleted: false }
    },
    {
        $project: {
            "name": 1,
            "price": 1,
            newPrice: {
                $cond: {
                    if: { $gt: ["$price", 2000] },
                    then: { 
                        $subtract: [
                            "$price", 
                            { $multiply: ["$price", .10] }
                        ] 
                    },
                    else: "$price"
                }
            }
        }
    }
];

return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Крок 1. Перший етап конвеєра фільтрує продукти які не видалені за допомогою операції &lt;em&gt;$match&lt;/em&gt;&lt;br&gt;
Крок 2. Другий етап конвеєра операція &lt;em&gt;$project&lt;/em&gt; яка витягує певні поля з колекції&lt;br&gt;
Крок 3. Нове поле newPrice містить в собі умову &lt;em&gt;$cond&lt;/em&gt;. &lt;br&gt;
Якщо ціна товару більша за 2000 &lt;code&gt;if: { $gt: ["$price", 2000] }&lt;/code&gt; &lt;br&gt;
то виконується умова &lt;br&gt;
&lt;code&gt;then: {$subtract: ["$price", { $multiply: ["$price", .10]}]}&lt;/code&gt; &lt;br&gt;
у противному випадку &lt;code&gt;else: "$price"&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Результат запиту
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/ekoynecu5uo6yhjcfv87.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/ekoynecu5uo6yhjcfv87.png" alt="Image description" width="1027" height="601"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Використані операції
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;$match&lt;/li&gt;
&lt;li&gt;$project&lt;/li&gt;
&lt;li&gt;$gt&lt;/li&gt;
&lt;li&gt;$subtract&lt;/li&gt;
&lt;li&gt;$multiply&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Вузол 'function' в Node-RED</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Wed, 17 Aug 2022 10:34:49 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/node-function-in-node-red-4hj3</link>
      <guid>https://community.ubos.tech/blue_skies/node-function-in-node-red-4hj3</guid>
      <description>&lt;ul&gt;
      &lt;li&gt;
        Написання функцій
        &lt;ul&gt;
          &lt;li&gt;Приклад як потрібно робити&lt;/li&gt;
          &lt;li&gt;Приклад як не потрібно робити&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Декілька виходів&lt;/li&gt;
      &lt;li&gt;Реєстрація подій&lt;/li&gt;
      &lt;li&gt;Обробка помилок&lt;/li&gt;
      &lt;li&gt;Manage palette&lt;/li&gt;
      &lt;li&gt;NPM package&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Вузол &lt;em&gt;function&lt;/em&gt; дозволяє запускати JavaScript код для повідомлень, які через нього передаються. Повідомлення передається як об'єкт під назвою msg. За замовчуванням він матиме msg.payload властивість, що містить тіло повідомлення.&lt;br&gt;
Інші вузли можуть додавати власні властивості до повідомлення. Вони повинні бути описані в їхній документації.&lt;/p&gt;

&lt;h3&gt;Написання функцій &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Код який введений у вузол &lt;em&gt;function&lt;/em&gt;, представляє тіло функції. Найпростіша функція повертає повідомлення таким яким воно є.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Якщо функція повертає &lt;code&gt;null&lt;/code&gt;, повідомлення не передається, і потік завершує свою роботу.&lt;br&gt;
Функція завжди повинна повертати об'єкт msg. Повернення числа або рядка призведе до помилки.&lt;br&gt;
Повернений об'єкт повідомлення не обов'язково має бути таким же об'єктом, як передано. Функція може побудувати новий об'єкт перед тим як повернути його. Наприклад:&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/9l8k4sof4g6mojdqj8er.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/9l8k4sof4g6mojdqj8er.png" alt="Image description" width="1538" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Примітка: створення нового об’єкта повідомлення призведе до втрати будь-яких властивостей повідомлення отриманого повідомлення. Це порушить деякі потоки, наприклад, потік HTTP In/Response вимагає обов'язкового збереження властивостей msg.req і msg.res. Загалом, функціональні вузли повинні повертати об’єкт повідомлення, який вони передали після внесення будь-яких змін до його властивостей.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Приклад як потрібно робити &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Створимо потік який повертає значення body, який ми передаємо у запиті. Використаємо вузли &lt;em&gt;http in&lt;/em&gt; та &lt;em&gt;http response&lt;/em&gt; (детальніше про них тут).&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/xdghjvz9be5o8vtyqwzm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/xdghjvz9be5o8vtyqwzm.png" alt="Image description" width="1538" height="412"&gt;&lt;/a&gt; Вузол &lt;em&gt;http in&lt;/em&gt; відправляє у &lt;em&gt;function&lt;/em&gt; повідомлення з властивостями payload, req, res. У тілі функції нам потрібно тільки записати у msg.payload потрібно нам значення не заміняючи весь об'єкт msg. Тоді вузол &lt;em&gt;http response&lt;/em&gt; зрозуміє, що йому потрібно повернути відповіді від нашого запиту.&lt;br&gt;
Зробимо запит за допомогою Postman.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/5b6lbyjzk6julbqpw9xf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/5b6lbyjzk6julbqpw9xf.png" alt="Image description" width="1065" height="331"&gt;&lt;/a&gt; У відповідь отримали текст який передавали у body. &lt;/p&gt;

&lt;h3&gt;Приклад як не потрібно робити &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Давайте зміним тіло функції вище описаного потоку на:&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/uuadj69i435gc8rqlz5x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/uuadj69i435gc8rqlz5x.png" alt="Image description" width="1538" height="446"&gt;&lt;/a&gt; У консолі отримає повідомлення &lt;strong&gt;"No response object"&lt;/strong&gt;. Через те, що ми створили новий об'єкт повідомлення, вузол &lt;em&gt;http response&lt;/em&gt; не знає, що йому потрібно повертати.&lt;br&gt;
Тому якщо потрібно створити нові властивості їх потрібно записувати у msg не створюючи новий.&lt;/p&gt;

&lt;h3&gt;Декілька виходів &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;У діалоговому вікні функції є можливість змінити кількість виходів та назву функції.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/vksr83mzs9hog1fszk7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/vksr83mzs9hog1fszk7g.png" alt="Image description" width="648" height="266"&gt;&lt;/a&gt; Додамо два виходи і зміним назву функції.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/r7p5lrt3jpu0i0lifadb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/r7p5lrt3jpu0i0lifadb.png" alt="Image description" width="509" height="132"&gt;&lt;/a&gt; Тепер у вузла function є два виходи. Далі постає питання. А як їх контролювати? Потрібно використовувати оператор &lt;em&gt;if&lt;/em&gt; та у його тілі повертати масив повідомлень. Кількість повідомлень у масиві залежить від кількості виходів які нумеруються від верху до низу.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (msg.payload.length &amp;gt; 0) {
    msg.payload = `array length: ${msg.payload.length}`;

    return [ null, msg ]
}

msg.payload = "Empty"
return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Для прикладу у нас є два виходи &lt;code&gt;return [ null, msg ]&lt;/code&gt;. У перший вихід повертаємо &lt;code&gt;null&lt;/code&gt; це означає, що функція у цьому випадку нічого не повертає на перший вихід. У другий вихід передаємо msg. Тому якщо у функцію прийде масив з декількох елементів, то у другий вихід повернеться рядок довжини масиву. В противному випадку повертаєм &lt;code&gt;return msg&lt;/code&gt; у перший виході.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/0yl60125r1o73v43pkuo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/0yl60125r1o73v43pkuo.png" alt="Image description" width="649" height="114"&gt;&lt;/a&gt; Додамо ще одну функцію &lt;em&gt;data&lt;/em&gt; яка повертає масив об'єктів.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msg.payload = [
    { name: "banana" },
    { name: "potato" }
];

return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/kbti1z02ql872ptba4q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/kbti1z02ql872ptba4q9.png" alt="Image description" width="1006" height="223"&gt;&lt;/a&gt; Умова повернула true тому повідомлення відправилось на другий вихід. Якщо у функцію &lt;em&gt;data&lt;/em&gt; записати пустий масив, то умова не виконається і повідомлення відправиться на перший вихід.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msg.payload = [];
return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/qnuva3siexodhu1ftp9f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/qnuva3siexodhu1ftp9f.png" alt="Image description" width="966" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Реєстрація подій &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Для того щоб ефективно проводити debug коду, треба розуміти які дані приходять та змінюються. Для цього потрібно використовувати наступні функції які будуть записувати в консоль повідомлення (аналог console.log() в JavaScript).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node.warn("Something happened");
node.error("Something bad happened");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Змінимо приклад який ми розглядали вище. Додамо цикл який перебирає масив і виводить його елементи у консоль.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (msg.payload.length &amp;gt; 0) {
    node.warn("start if");

    for (const element of msg.payload) {
        node.warn(element);
    }

    return [ null, msg ]
}

msg.payload = "Empty"
return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/dmsojcpf7602xctdw9j9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/dmsojcpf7602xctdw9j9.png" alt="Image description" width="716" height="373"&gt;&lt;/a&gt; У консолі можна побачити 3 події node.warn.&lt;/p&gt;

&lt;h3&gt;Обробка помилок &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Якщо функція знаходить помилку і потрібно завершити виконання потоку то вона не повинна нічого повертати. Щоб викликати Catch у певному вузлі функція повинна викликати &lt;code&gt;node.error("error", msg)&lt;/code&gt; передаючи у перший аргумент текст помилки, а у другий msg.&lt;/p&gt;

&lt;p&gt;Змінимо попередній приклад додавши у функцію &lt;em&gt;data&lt;/em&gt; помилку&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msg.payload = [
    { name: "banana" },
    { name: "potato" }
];

node.error("Еrror", msg);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/2p2sw3rtmntoorfvhao2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/2p2sw3rtmntoorfvhao2.png" alt="Image description" width="1040" height="301"&gt;&lt;/a&gt; Функція &lt;em&gt;data&lt;/em&gt; повернула помилку тому вузол зупинив роботу&lt;/p&gt;

&lt;h3&gt;Manage palette &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Для того, щоб додати додаткові node-red вузли у проект потрібно відкрити меню справа та вибрати вкладку Manage Pallete.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/xz05sa4f0qjxgqddc7ew.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/xz05sa4f0qjxgqddc7ew.png" alt="Image description" width="273" height="583"&gt;&lt;/a&gt; У вкладці Nodes зберігаються бібліотеки які вже завантаженні, а у вкладці Install потрібно ввести назву бібліотеки та завантажити її.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Перед завантаженням бібліотеки варто ознайомитись з її документацією&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/h5xu765lr2lopounu7e6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/h5xu765lr2lopounu7e6.png" alt="Image description" width="712" height="310"&gt;&lt;/a&gt; Після завантаження у списку всіх вузлів з'являться нові завантажені вузли&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/zd0zgyb7otb6b5tohcdh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/zd0zgyb7otb6b5tohcdh.png" alt="Image description" width="166" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;NPM package &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;NODE-Red дозволяє витягувати додаткові модулі з Node Package Manager. Для цього потрібно вибрати вузол &lt;em&gt;function&lt;/em&gt; у який нам потрібно використати додатковий модуль та перейти у вкладку Setup. У цій вкладці натиснути кнопку add та ввести модуль який потрібно використовувати. Якщо такий модуль існує на платформі NPM, то ми зможемо його використовувати.&lt;br&gt;
Створимо потік який приймає зображення яке ми оптимізовуємо та перевертаємо.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/ghme9rajxstyhopwa5hf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/ghme9rajxstyhopwa5hf.png" alt="Image description" width="542" height="148"&gt;&lt;/a&gt; Використаєм новий вузол viewer який раніше ми завантажували.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Зверніть увагу! Для роботи з зображеннями варто використовувати метод POST та дозволити завантаження зображення&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/wsc4ccd7dbrz6jq1zc66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/wsc4ccd7dbrz6jq1zc66.png" alt="Image description" width="512" height="305"&gt;&lt;/a&gt;&lt;br&gt;
Додамо модуль &lt;em&gt;sharp&lt;/em&gt; для роботи з зображеннями.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/jvjx7pr0bxhivilpa1ri.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/jvjx7pr0bxhivilpa1ri.png" alt="Image description" width="648" height="819"&gt;&lt;/a&gt; У тіло функції додаємо логіку роботи з зображенням.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const optimized = await sharp(msg.req.files[0].buffer)
    .toFormat("jpeg", { quality: 60 })
    .flip()
    .toBuffer();

msg.payload = optimized;

return msg;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Через Postman відправимо зображенням. Тіло запиту буде типу form-data. Для зображення потрібно вибрати тип file.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/92dnhpa3iu0buwyvlsy2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/92dnhpa3iu0buwyvlsy2.png" alt="Image description" width="848" height="349"&gt;&lt;/a&gt; Результат виконання&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/lafb61d7q11r3e9c61i8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/lafb61d7q11r3e9c61i8.png" alt="Image description" width="544" height="262"&gt;&lt;/a&gt; &lt;br&gt;
Запит відправляє буфер зображення який зберігається за таким шляхом &lt;code&gt;msg.req.files[0].buffer&lt;/code&gt;. Відправлене зображення важить &lt;code&gt;size: 414164&lt;/code&gt;(404 КБ)&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/g1ccafe1wloiqhqvmmlm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/g1ccafe1wloiqhqvmmlm.png" alt="Image description" width="248" height="203"&gt;&lt;/a&gt; Конвертоване зображення 292563 (285 КБ)&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/5zf6e9a5bcpd0x1h735k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/5zf6e9a5bcpd0x1h735k.png" alt="Image description" width="222" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Модуль деталі про компанію (Company Jobs)</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Mon, 15 Aug 2022 12:45:36 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/modul-dietali-pro-kompaniiu-companyjobs-h74</link>
      <guid>https://community.ubos.tech/blue_skies/modul-dietali-pro-kompaniiu-companyjobs-h74</guid>
      <description>&lt;p&gt;На сторінці Company у таблицю з компаніями потрібно додати кнопку яка буде перенаправляти на сторінку зі списком робіт вибраної компанії&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/aek3et2i3nk9va3s6kuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/aek3et2i3nk9va3s6kuh.png" alt="Image description" width="1387" height="832"&gt;&lt;/a&gt; Потрібно написати flow який візьме з колекції jobs всі вакансії, які належать до вибраної компанії.&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;p&gt;Приклад API яка бере з query params ID вибраної компанії&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/mxl5dk29k4zqzyjj03yf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/mxl5dk29k4zqzyjj03yf.png" alt="Image description" width="1385" height="602"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Підказка! Варто використати операцію &lt;a href="https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/" rel="noopener noreferrer"&gt;aggregate&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>Модуль створення вакансій (Recruit)</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Mon, 15 Aug 2022 12:45:23 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/modul-stvoriennia-vakansii-recruit-39ke</link>
      <guid>https://community.ubos.tech/blue_skies/modul-stvoriennia-vakansii-recruit-39ke</guid>
      <description>&lt;h2&gt;
  
  
  1.UI частина (створення сторінки Recruit)
&lt;/h2&gt;

&lt;p&gt;Для додавання нової сторінки в середовищі UIEditor, потрібно натиснути на символ "+" в розділі SIDEBAR на проти поля PAGES.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/pi5zsfwh9yadb9s6yhco.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/pi5zsfwh9yadb9s6yhco.png" alt="Image description" width="1642" height="935"&gt;&lt;/a&gt; Отже, дана сторінка складається з наступних віджетів:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;b&gt;Table&lt;/b&gt;, в які відображаємо існуючі вакансії (в таблиці є button, при натисканні на який нас переадресовує на сторінку кандидатів до обраної вакансії)&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;3 Buttons&lt;/b&gt; (Create Job, Update, Delete) При натисканні на кнопку Create Job та Edit Job Info відкриваються модальні вікна, на кнопку видалення здійснюється видалення виділеної в таблиці вакансії.
Модальні вікна створення вакансії (Create Job) та оновлення інформації про вакансію  (Edit Job Info) містять в собі 5 inputs, 5 select, 2 buttons
&lt;img src="https://community.ubos.tech/uploads/articles/f4byjukjn33eo6m173n0.png" alt="Image description" width="1095" height="834"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Вибір компанії
&lt;/h2&gt;

&lt;p&gt;Потрібно створити запит у БД який повертає _id i companyName.&lt;br&gt;
Flow складається з вузлів: http in, 2 function, mongodb in, http response&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/nggd8163zxafev9hj145.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/nggd8163zxafev9hj145.png" alt="Image description" width="964" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;шукаєм у БД компанії у який поле deleted: false;
&lt;img src="https://community.ubos.tech/uploads/articles/0anjoyo5ub3jd2csv7sd.png" alt="Image description" width="652" height="341"&gt; - вузол mongodb in &lt;img src="https://community.ubos.tech/uploads/articles/ozdsns2yai9h1hopag2p.png" alt="Image description" width="521" height="343"&gt; - повертаєм тільки _id та companyName &lt;img src="https://community.ubos.tech/uploads/articles/d9fk8x8invw48cdxc2lr.png" alt="Image description" width="653" height="407"&gt; - id потрібно обгорнути у objectid &lt;img src="https://community.ubos.tech/uploads/articles/oqb3nm5s7vjy64kv13lh.png" alt="Image description" width="653" height="861"&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Відображаємо вакансії для вибору
&lt;/h2&gt;

&lt;p&gt;Потрібно створити API&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/pryhfcxqg4l7xy04kjvz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/pryhfcxqg4l7xy04kjvz.png" alt="Image description" width="1389" height="835"&gt;&lt;/a&gt; У віджеті вибору вакансії потрібно добавити у поле Options дані для вибору &lt;a href="https://community.ubos.tech/uploads/articles/2ov3ol77mfrfl9sp3sdz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/2ov3ol77mfrfl9sp3sdz.jpg" alt="Image description" width="880" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Створення вакансії
&lt;/h2&gt;

&lt;p&gt;В середовищі Node Red створюємо flow, який cкладатиметься з 5 вузлів: http in, debug, function, mongodb out, http response&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/hux6vw6gbpzxu15lpm3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/hux6vw6gbpzxu15lpm3g.png" alt="Image description" width="600" height="131"&gt;&lt;/a&gt; Вузол function&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/t11lop6gopgta7efy6n1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/t11lop6gopgta7efy6n1.png" alt="Image description" width="651" height="353"&gt;&lt;/a&gt; Вузол mongodb out (Insert Job):&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/wg1zh31lhadl0krx5gw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/wg1zh31lhadl0krx5gw5.png" alt="Image description" width="510" height="371"&gt;&lt;/a&gt; Для створення компанії, в UI Editori створюємо API call (createJob) в тілі якого передаємо значення з усіх віджетів модального вікна  створення вакансії(Create job).&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/wtdny6ymi0qh0gwprynr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/wtdny6ymi0qh0gwprynr.png" alt="Image description" width="1384" height="602"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Відображення створених вакансій
&lt;/h2&gt;

&lt;p&gt;Для відображення створених  вакансій  в таблиці, потрібно створити в середовищі Node Red flow який складається з 5 вузлів:http in, debug, function, mongodb in, http response&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/9isj7kpkpy8zp88cz3lx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/9isj7kpkpy8zp88cz3lx.png" alt="Image description" width="586" height="68"&gt;&lt;/a&gt; function&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/7ogmxpxg6n51rleh1s4d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/7ogmxpxg6n51rleh1s4d.png" alt="Image description" width="649" height="359"&gt;&lt;/a&gt; Вузол mongodb in( Get Job):&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/hv7ldaodzvvu3bp7qhp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/hv7ldaodzvvu3bp7qhp0.png" alt="Image description" width="522" height="367"&gt;&lt;/a&gt; В середовищі UI Edtior створюємо в API call, з методом GET який здійснить запуск вище створеного потоку в середовищі Node Red.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/wh3g6ewrk7blyu9aq2w8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/wh3g6ewrk7blyu9aq2w8.png" alt="Image description" width="1388" height="763"&gt;&lt;/a&gt; Для відображення отриманих вакансій в таблиці в налаштуваннях віджету Table1 в полі Default Data ми вписуємо в фігурних дужках назву API call, та властивість data. &lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/xqejz9kve52v4w1wxsvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/xqejz9kve52v4w1wxsvq.png" alt="Image description" width="289" height="194"&gt;&lt;/a&gt; Для створення кнопки в таблиці потрібно в налаштування віджету Table1 натиснути на кнопку “Add a new column” та в налаштуваннях вибрати у полі &lt;b&gt;Column Type&lt;/b&gt; вибрати &lt;b&gt;Button&lt;/b&gt;&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Редагування створених вакансій
&lt;/h2&gt;

&lt;p&gt;Для редагування створеної вакансії, спочатку потрібно відобразити інформацію про створену вакансію у віджетах модального вікна (Edit Job info), для цього потрібно в налаштуваннях кожного віджету в поле default text або default options передати відповідну властивість виділеного в таблиці об'єкта:&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/poku4ku4ggmdq85zr5t6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/poku4ku4ggmdq85zr5t6.png" alt="Image description" width="1382" height="868"&gt;&lt;/a&gt; Для оновлення виділеного в таблиці об'єкта (вакансії) потрібно створити потік (flow) в середовищі Node Red, який складається з наступних вузлів: http in, debug, function (схожий як і для оновлення компаній), http response, mongodb out&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/072ylx5j0qc09klpxx5y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/072ylx5j0qc09klpxx5y.png" alt="Image description" width="496" height="139"&gt;&lt;/a&gt; &lt;b&gt;function&lt;/b&gt; &lt;a href="https://community.ubos.tech/uploads/articles/9jhbf6oqlx104v462uld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/9jhbf6oqlx104v462uld.png" alt="Image description" width="659" height="859"&gt;&lt;/a&gt; Створюємо в середовищі UI Editor API call, METHOD: PUT, в тілі запиту передаємо значення з віджетів модального вікна (ModalEditJob), та  поле  “_id” виділеної в таблиці вакансії.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/vxh60sgvw8cuaihcig5v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/vxh60sgvw8cuaihcig5v.png" alt="Image description" width="1386" height="599"&gt;&lt;/a&gt; Модальні вікна: дії на кнопки &lt;b&gt;Create&lt;/b&gt; та &lt;b&gt;Update&lt;/b&gt;&lt;br&gt;
При кліку на вказані кнопки ми повинні виконати 3 дії:&lt;br&gt;
1) Здійснити API call (createJob або updateJob);&lt;br&gt;
2) Здійснити API call (getJobs);&lt;br&gt;
3) Закрити Модальне вікно&lt;br&gt;
Отже в налаштування віджету button ми пишемо:&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/3q13fdbihk3eo8w08g3q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/3q13fdbihk3eo8w08g3q.png" alt="Image description" width="1384" height="869"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Видалення створених вакансій
&lt;/h2&gt;

&lt;p&gt;Для видалення виділеної в таблиці вакансії  створюємо flow(потік) в середовищі NodeRed, який складається з наступних вузлів: http in (method :deleted), function, debug, http response, mongodb out&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/e1xxquw6wyfz6clmta7l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/e1xxquw6wyfz6clmta7l.png" alt="Image description" width="516" height="144"&gt;&lt;/a&gt; &lt;b&gt;Вузол function (query):&lt;/b&gt;&lt;br&gt;
 &lt;a href="https://community.ubos.tech/uploads/articles/nc9lk2ikceaer5w8zba0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/nc9lk2ikceaer5w8zba0.png" alt="Image description" width="660" height="857"&gt;&lt;/a&gt;&lt;a href="https://community.ubos.tech/uploads/articles/hrrimgfm816soadfi5ez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/hrrimgfm816soadfi5ez.png" alt="Image description" width="650" height="861"&gt;&lt;/a&gt;&lt;b&gt;Вузол mongodb out:&lt;/b&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/ntgofbabnm2qhw28duws.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/ntgofbabnm2qhw28duws.png" alt="Image description" width="513" height="427"&gt;&lt;/a&gt; Тобто даний потік, буде здійснювати не безпосереднє видалення об'єкта з бази даних, а оновлюватиме його властивість “deleted”.&lt;br&gt;
В середовищі UI Editor створюємо API Call, method Delete, в тілі якого передаємо лише поле "_id" яке виступає унікальним ідентифікатором обєкта який видаляємо.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/plwnei85cflcx3zmopbo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/plwnei85cflcx3zmopbo.png" alt="Image description" width="1383" height="589"&gt;&lt;/a&gt; На кнопку Delete здійснюємо дві дії:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;виклик API call (deleteJob)&lt;/li&gt;
&lt;li&gt;виклик API call (getJobs)
&lt;img src="https://community.ubos.tech/uploads/articles/ftv7gh3krh1h1ul6wgbu.png" alt="Image description" width="528" height="835"&gt;
 
 
 
 
&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Модуль створення компаній (Company)</title>
      <dc:creator>vova</dc:creator>
      <pubDate>Mon, 15 Aug 2022 12:44:48 +0000</pubDate>
      <link>https://community.ubos.tech/blue_skies/modul-stvoriennia-kompanii-company-1nd3</link>
      <guid>https://community.ubos.tech/blue_skies/modul-stvoriennia-kompanii-company-1nd3</guid>
      <description>&lt;h2&gt;
  
  
  1. UI частина (створення сторінки Company)
&lt;/h2&gt;

&lt;p&gt;На даній сторінці потрібно розмістити наступні віджети:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 &lt;b&gt;CONTAINER&lt;/b&gt;, всередині якого будуть розміщені всі інші віджети;&lt;/li&gt;
&lt;li&gt;7 &lt;b&gt;INPUT&lt;/b&gt;, 6 з яких з Data_type: text, 1 - Number;&lt;/li&gt;
&lt;li&gt;3 &lt;b&gt;SELECT&lt;/b&gt;;&lt;/li&gt;
&lt;li&gt;2 &lt;b&gt;BUTTON&lt;/b&gt;;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Всім віджетам потрібно давати інформативні назви, для того щоб було зручно і зрозуміло використовувати дані. За замовчуванням при додаванні віджета на сторінку автоматично генерується назва, наприклад віджету INPUT генерується назва Input1.&lt;br&gt;
Для зміни назви необхідно у вікні Settings widget вписати нову назву на місці старої і натиснути кнопку Enter.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/oj20dtxpdddt7voel2mx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/oj20dtxpdddt7voel2mx.png" alt="Image description" width="1642" height="934"&gt;&lt;/a&gt; Після того, як будуть розміщені всі віджети з назвами відповідно до прикладу, створення сторінки користувача можна вважати завершеною.&lt;/p&gt;

&lt;h4&gt;
  
  
  Результат виконання
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/00s7kpjmd0ovnhzlwcgb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/00s7kpjmd0ovnhzlwcgb.png" alt="Image description" width="1587" height="536"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Важливо!
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Для подальшої роботи потрібно піднести середовище Node-RED[&lt;a href="https://community.ubos.tech/blue_skies/flow-editor-basic-3g5g"&gt;посилання&lt;/a&gt;] та піднесення бази даних[&lt;a href="https://community.ubos.tech/blue_skies/databases-5f82"&gt;посилання&lt;/a&gt;]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Створення компанії
&lt;/h2&gt;

&lt;p&gt;Під створенням компанії мається на увазі реалізація однієї з операцій CRUD, а саме Create - тобто ми повинні здійснити запис в базі даних (в нашому випадку це буде база даних MongoDB) про компанію. &lt;/p&gt;

&lt;p&gt;Дані для запису в базу даних ми повинні передати з раніше створених віджетів на сторінці Company. &lt;/p&gt;

&lt;p&gt;Отже для цього нам потрібно:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Створити EndPoint в середовищі NodeRed, куди ми будемо передавати дані та здійснюватимемо запис в базу даних.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;1.1. EndPoint в середовищі NodeRed - це вузол “http in”, що прийматиме дані, які ми будемо на нього відправляти. З бокової панелі вузлів пересуваємо вузол “http in”, вибираємо в даному випадку Метод “Post” та вказуємо URL на приклад “/createCompany”. Кожний EndPoint повинен щось повертати, для цього нам потрібно додати вузол “http response” і приєднати його до вузла “http in”. Для того щоб в вікні “debug messages” побачити дані, які ми передаємо на цей EndPoint нам потрібно підключити вузол “debug” до вузла “http in”.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/tcbmmo7eqw1qk0fv2jao.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/tcbmmo7eqw1qk0fv2jao.png" alt="Image description" width="1328" height="382"&gt;&lt;/a&gt; 1.2. Для здійснення безпосередньо самого запису в базу даних, ми використовуватимемо вузол “mongodb out” (детальніше про підключення &lt;a href="https://community.ubos.tech/blue_skies/databases-5f82"&gt;тут&lt;/a&gt;). Підключаємо вузол “mongodb out”  до вузла “function” та у вузлі "function" додаємо нове поле до даних, які приходить з UI. &lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/6wtpbmlvrnw1a9r53y7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/6wtpbmlvrnw1a9r53y7m.png" alt="Image description" width="657" height="335"&gt;&lt;/a&gt; “mongodb out” потрібно вибрати тип операції “insert” (або "save", детальніше &lt;a href="https://www.mongodb.com/docs/v4.4/reference/method/db.collection.save/" rel="noopener noreferrer"&gt;тут&lt;/a&gt;), додати назву колекції, в яку будуть записуватись дані та зробити активним поле “Only store msg.payload object”.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Важливо&lt;/em&gt;! Користувач повинен надати колекції інформативну назву. Також не слід забувати, що оперуючи із даними однієї колекції, в інших запитах (GET, PUT, etc) назви колекції повинні бути одинаковими. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/ln17lfien62saurq7ky2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/ln17lfien62saurq7ky2.png" alt="Image description" width="616" height="131"&gt;&lt;/a&gt; Даний потік(flow) здійснить запис в базу даних, тобто все що буде відправлено на EndPoint (“/createCompany”) буде записано в базу даних.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Передача динамічних даних з середовище UiEditor в середовище NodeRed:&lt;/b&gt;&lt;br&gt;
Для передачі даних з UiEditor в середовище NodeRed, нам потрібно створити API Call (детальніше &lt;a href="https://community.ubos.tech/blue_skies/ui-editor-basic-36fl#chapter-6"&gt;тут&lt;/a&gt;), використовуючи відповідний метод вузла “http in”. Створимо метод POST, якому в body потрібно передати дані з наших віджетів.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/1npzofif1qnhz0bu6ksh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/1npzofif1qnhz0bu6ksh.png" alt="Image description" width="1383" height="598"&gt;&lt;/a&gt; В тілі запиту дані передаються у форматі JSON, тому важливо пам'ятати про базові правила: всі поля мають бути розділеними комами(в останньому рядку кому ставити не потрібно) та обгорнутими в подвійні лапки (наприклад,"name"). Зі скріна вище, “CompanyNameInput” - це назва(об'єкт) віджету (в даному випадку це віджет “INPUT”), “.text” -  це властивість віджету, “companyName” - це назва змінної, яку ми передаємо. &lt;br&gt;
Далі на кнопку створення вакансії потрібно додати виклик API&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
     &lt;br&gt;
   &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Відображення компанії
&lt;/h2&gt;

&lt;p&gt;Для відображення створеної нами компанії, потрібно зробити “EndPoint” в середовищі NodeRed, який витягне з бази даних інформацію про компанію.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/qz216q9lczfwpt02a412.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/qz216q9lczfwpt02a412.png" alt="Image description" width="751" height="62"&gt;&lt;/a&gt; Для цього ми використовуємо 4 вузла: http in, mongodb in, function, http response.&lt;br&gt;
&lt;b&gt;mongo in&lt;/b&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/dihb09dvvzavee6efeb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/dihb09dvvzavee6efeb3.png" alt="Image description" width="519" height="342"&gt;&lt;/a&gt;&lt;br&gt;
&lt;b&gt;function&lt;/b&gt;&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/imh7zlfoasves72i9ds3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/imh7zlfoasves72i9ds3.png" alt="Image description" width="650" height="320"&gt;&lt;/a&gt; Тобто даний потік(flow) здійснить запит в базу даних, отримає всю інформацію з колекції “companies”, за допомогою вузла function присвоїть змінній &lt;code&gt;msg.payload&lt;/code&gt; параметри за якими шукати компанії, і вузол http response повертає відповідь у точку запиту.&lt;/p&gt;

&lt;p&gt;В UiEditor ми створюємо новий API Call, в якому обираємо метод GET, і потрібний нам EndPoint (http in).&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/jeji0aleuxq0vgk0m15c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/jeji0aleuxq0vgk0m15c.png" alt="Image description" width="1383" height="869"&gt;&lt;/a&gt; В розділі Settings цього API Call, потрібно зробити активним поле &lt;code&gt;Run api on Page load&lt;/code&gt;, для того щоб це запит виконувався при загрузці сторінки. Далі нам потрібно відобразити отримані цим запитом дані в створені раніше віджети.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/zr12niexw7ecn5q3yul2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/zr12niexw7ecn5q3yul2.png" alt="Image description" width="1385" height="545"&gt;&lt;/a&gt; Відображення отриманих даних у таблиці:&lt;br&gt;
Для відображення отриманих даних, нам потрібно в налаштуваннях віджету в поле TableData, передати об'єкт запиту.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/d1ecx4f4m290zccru0c2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/d1ecx4f4m290zccru0c2.png" alt="Image description" width="1387" height="874"&gt;&lt;/a&gt;&lt;br&gt;
Відображення дефолтного тексту в віджеті INPUT:&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/9826q1bllfcrnmgup35q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/9826q1bllfcrnmgup35q.png" alt="Image description" width="1569" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Відображення дефолтного тексту в віджеті SELECT:&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/5i88157cq7y7twl04g72.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/5i88157cq7y7twl04g72.png" alt="Image description" width="1552" height="680"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Також потрібно додати до onClick кнопки в метод onSuccess виклик API getCompanyInfo щоб отримати оновлені дані.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/rvtkoa5u2h1tbbx2sd1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/rvtkoa5u2h1tbbx2sd1s.png" alt="Image description" width="324" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Оновлення створеної компанії
&lt;/h2&gt;

&lt;p&gt;Для оновлення даних про компанію, потрібно створити потік (flow) в середовищі NodeRed, який отримує дані, здійснить запит в базу даних “Update”,  та API Call в середовищі UiEditor який передасть дані в середовище NodeRed. &lt;/p&gt;

&lt;p&gt;Даний flow складається з 6 вузлів: http in, function, mongodb out, http response, 2 debug.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/rz7ex7gcbm3jz4bsxlc9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/rz7ex7gcbm3jz4bsxlc9.png" alt="Image description" width="1013" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;updateQuery&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/kgzmo0r8h6854bp7l9yx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/kgzmo0r8h6854bp7l9yx.png" alt="Image description" width="1322" height="934"&gt;&lt;/a&gt; &lt;br&gt;
Оскільки "_id" - унікальний, його потрібно видалити перед оператором оновлення "$set". &lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/249dcvzxj6qmxrtake22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/249dcvzxj6qmxrtake22.png" alt="Image description" width="1264" height="742"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ubos.tech/uploads/articles/op8dn5lj0g8n8mosq80d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/op8dn5lj0g8n8mosq80d.png" alt="Image description" width="1387" height="432"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;В середовищі UiEditor ми створюємо новий API call з методом PUT, в тілі(body) якого передаємо динамічні значення з віджетів. В даному випадку тіло запиту буде практично аналогічним до запиту для створення компанії, окрім нового поля “_id”, по якому ми ідентифікуватимемо об'єкт, що потрібно оновити.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/rpm8rrhjr2205pw25egj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/rpm8rrhjr2205pw25egj.png" alt="Image description" width="1001" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Для зручної навігації в Node-red, варто розділяти запити, які стосуються одного модуля на різні флови. Наприклад, для модуля компанії - існує флов "Company", в якому розміщують всі HTTP запити (також їх називають endponits, ланцюги), пов'язані з ним.&lt;br&gt;
&lt;a href="https://community.ubos.tech/uploads/articles/1bf6xdjc9gsoj2pxmpwt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ubos.tech/uploads/articles/1bf6xdjc9gsoj2pxmpwt.png" alt="Image description" width="884" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

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