<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anton Shevchuk on Medium]]></title>
        <description><![CDATA[Stories by Anton Shevchuk on Medium]]></description>
        <link>https://medium.com/@AntonShevchuk?source=rss-c868a9e7bfdd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XwOnUoz0Y4fJcq66Fa2M4Q.jpeg</url>
            <title>Stories by Anton Shevchuk on Medium</title>
            <link>https://medium.com/@AntonShevchuk?source=rss-c868a9e7bfdd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 10:23:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@AntonShevchuk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PHP — More Alive Than All the Dead]]></title>
            <link>https://medium.com/@AntonShevchuk/php-more-alive-than-all-the-dead-93b259678ccc?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/93b259678ccc</guid>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Thu, 28 May 2026 13:46:31 GMT</pubDate>
            <atom:updated>2026-05-28T13:46:31.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*l3f5LXsD24eMv1nbw9F56A.png" /><figcaption>elephpant</figcaption></figure><p>PHP gets “buried” consistently about once a quarter. The most interesting part is that everyone does it except the developers themselves — we’re usually too busy discussing anything else but the language.</p><p>So I decided to add my two cents to this endless eulogy and suggest we take a look into the future.</p><h3>Code as the New Literacy</h3><p>Let’s get this out of the way: let’s set aside the predictions that soon only neural networks will write code, and we’ll just be growing organic carrots. Let’s assume that programming is still a relevant skill, at least for serving as a conductor for a pack of AI agents. So the task for now is to teach this literacy. What programming language will it be? One of many options is, of course, PHP.</p><p><em>— What other programming languages could be considered for a basic programming skill?<br>— Python, yes, but please, no JavaScript.</em></p><h3>PHP no.1</h3><p>This is a new manifesto. I even suggest making this the official logo for future changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*s3lqpqx_QPfRFR-ODx9G-w.png" /><figcaption>php no.1</figcaption></figure><p><em>— Hey, we’re programmers, counting starts from zero! <br>— Agreed. That’s why we respectfully leave the title “no.0” for “C.”</em></p><p>And changes will be needed, precisely because I wouldn’t want to teach children and students something that looks like searching for a needle in a haystack. But more on that a bit later.</p><h3>Programming for Everyone</h3><p>My main thesis is this: for the development of any programming language, you need new and young developers. So from here on, I’ll try to develop the idea of how to attract new people to programming, and specifically to PHP programming in our case.</p><p>First — we need to move toward selling programming as a basic skill for any engineer, and perhaps not just engineers. This should literally become the goal of this entire education movement.</p><p>Second — we need to pay attention to programming for schools, and comprehensively so, not just some programming at the level of loops and console work. We need to teach from a practical standpoint, developing applied programming — this is what should interest kids. The approach shouldn’t be “here’s PHP, we’ll build this with it,” but rather “want to build a website? Let’s take the most popular programming language for websites.” That’s where HTML, CSS, basic JavaScript, and working with databases come in — and yes, already in school.</p><p><em>Why do I think the approach needs to change and start from interest? I had a negative experience collaborating with universities in Kharkiv, when we tried to develop a PHP curriculum that would include both lectures and practicals. But we ran into conflicts with university professors and wasted our time because “you can’t talk about HTTP — that’s part of the network protocols course,” “we don’t cover databases, that’ll be a separate course,” “of course we’ve already covered HTML and CSS, but you can’t…,” and so on.</em></p><p>What does it take to become the “no.1” programming language in schools?</p><p>The content must be accessible to students:</p><ul><li>Ready-made curricula where the teacher can easily understand and reproduce everything themselves, because implementation is the main barrier to new teaching methods.</li><li>Ready-made solutions that can be downloaded or purchased. For example, a mini-server on a Raspberry Pi with a deployed LAMP stack and access, so you can program right in the browser or easily deploy to the server (SFTP connection right from the IDE).</li><li>It would also be interesting to provide the ability to use PHP on Arduino.</li><li>Some smart home gadgets.</li><li>Some ready-made agents that could interest kids.</li><li>Maybe even a TikTok channel (again, first and foremost it’s about programming, and secondarily that the examples will be in PHP).</li><li>Lessons on GitHub so students can level up their profiles too (though the question is whether they can have their own profile under GitHub’s rules).</li><li>An IDE for students based on PHPStorm, but with everything unnecessary removed (perhaps behind hidden menu items), simplified as much as possible, maybe with built-in access to GitHub lessons. Built-in AI with pre-prompts that explain things at a student level.</li><li>Finally rework that manual so it’s written for people, so that when a child’s parents sit down to figure it out, they can read it and explain everything to their child.</li><li>The manual should have interactive examples.</li><li>Add a learning path to the manual.</li></ul><p>And only after schools can we move on to universities.</p><p><em>I remembered a case from LeetCode where I solved one of the problems in PHP and ended up in the top-1 with my solution. But this isn’t about me and my solution — it’s about the fact that nobody solves problems in PHP on LeetCode :(</em></p><h3>PHP X</h3><p>I’ve already said that to enter schools and universities — PHP needs changes.</p><p>Most likely, there are already approved plans for changes in PHP 9, but I’m looking a bit further ahead.</p><p>This point is complex, but it’s absolutely necessary for the successful implementation of the previous section, so perhaps it needs to be done even earlier.</p><p>PHP X should be a language where there’s no room for $needle and $haystack, asort, strstr, str_replace, and so on. What I mean is — the language must be consistent; all those naming diseases of functions, classes, and methods need to be left in the past. We shouldn’t teach children these “peculiarities” of the language. This mess needs to be cleaned up, and if someone needs a new version of PHP for compatibility — let them install an extension for that; it shouldn’t be there by default.</p><p>In reality, there will be many holy wars. For example, there are things I would change myself:</p><ul><li>String concatenation — using “+” would be logical.</li><li>Array syntax as [ “a” : 42 ].</li><li>There are other syntax questions too.</li></ul><p>So the main thing here is to create PHP X specifically as the no.1 language for education, one that will truly help, even if you later switch to a different programming language.</p><p>It’s possible that PHP 9 and PHP X will coexist simultaneously and evolve together as two parallel branches.</p><h3>Honest About Competitors</h3><p>Before talking about strategy, it’s worth acknowledging the obvious: Python has already won the race for a place in education. And it won not through technical superiority, but through the learning ecosystem — Jupyter Notebooks, Google Colab, interactivity “out of the box,” thousands of free courses. When a student opens Colab, they’re writing code in the browser within 10 seconds. When a student wants to try PHP — they need to set up a server.</p><p>This isn’t a reason to give up; it’s a reason to understand what we’re competing with. PHP has its niche — the web, and this niche is enormous. But to enter education, you need to provide a comparable “zero to result in a minute” experience. Anything less is just a program for the motivated, not for everyone.</p><h3>Strategy and Tactics</h3><p>What to pay attention to:</p><h3>Cloud Presence</h3><p>It would be a significant win if PHP became one of the programming languages available for Lambda on AWS. This is absolutely top-tier — reaching out to Amazon and asking what they need from PHP for this. Perhaps not just Amazon.</p><p>Lambda is only part of the picture. Cloudflare Workers, Vercel, Fly.io — all these platforms are currently shaping the perception of which languages are “modern.” PHP is either absent or on the margins there. Cloud presence overall is a systemic task, not a one-time request to a single vendor.</p><h3>Infrastructure for Education</h3><p>Collaboration with some Linux distribution for a quick laptop setup, ready for the PHP learning stack (perhaps approach DHH with this request — he has Omarchy Linux, which works fine on weak hardware, which is okay for learning).</p><h3>Community and Ambassadors</h3><p>Content and tools are great, but someone has to carry all of this into schools and universities. Python grew in education largely thanks to the PSF Education Initiative — a program where enthusiasts came to schools, ran workshops, organized hackathons. PHP Foundation could launch something similar: an ambassador program, mentors who are willing to spend a few hours a month on live events. One workshop in a school gives more than a hundred banners on websites.</p><h3>Certification and Portfolio</h3><p>For students and schoolchildren, it’s important to have something “tangible” after learning. Badges, certificates, levels — gamification of the language learning path. This ties in well with the point about GitHub lessons but deserves separate attention: a level program like freeCodeCamp, where each stage ends with a micro-project that can be showcased. “I built my first website in PHP” with a badge on the profile — that’s motivation that works.</p><h3>Showcase: “Built with PHP”</h3><p>We need banners saying something was built with PHP, try to promote this wherever possible, ask the authors of relevant sites to add it to their sites, even without links.</p><p>But you can go further — create a separate resource “Built with PHP” with real case studies: from WordPress and Laravel to specific startups and services. Kids and students are motivated not by an abstract language, but by the fact that something they use every day is built with it. “That site you use every day — it’s built with PHP” — this works better than any manifesto.</p><h3>Integration with the AI Ecosystem</h3><p>I mentioned at the beginning the idea of a “conductor for a pack of AI agents” — and this is where PHP is currently losing. There’s no official OpenAI SDK for PHP, and the Anthropic SDK for PHP can’t seem to get out of beta, with only 130+ stars on GitHub. If PHP wants to be the “no.1” language, it needs to lobby for first-class AI SDKs, or at least official integration examples. For education, this is also critical — kids find it more interesting to build their own chatbot or AI agent than yet another CRUD. And if they have to switch to Python for that — they’ll switch and never come back.</p><h3>Growing Markets</h3><p>The Arab and African markets — they’re starting to grow, lagging about 15 years behind, and are now rapidly trying to catch up. So a ready-made curriculum can be brought there to get them hooked on PHP.</p><p>But “bringing a curriculum” isn’t just translating a README. It’s localization of documentation, examples with local context, partnerships with local educational initiatives. And by the way, if we’re already talking about schools in Ukraine — a manual in Ukrainian would be a logical first step. It’s hard to sell PHP as a language “for everyone” if the manual only exists in English.</p><h3>Instead of a Conclusion</h3><p>Of course, I’ve outlined steps for PHP’s development here, but who will take the first step — that question is still open. This isn’t an action plan for a single developer and not a wish list into the void. This is a text for those who make decisions — and first and foremost for the PHP Foundation. It’s they who currently have the resources, authority, and ability to turn this vision into reality, to make PHP no.1.</p><p>But the competition is fierce, and the window of opportunity isn’t infinite. Python isn’t waiting, Rust is entering new niches, and the new generation of developers chooses a language not for the power of its core, but for the first experience — and that experience is being shaped right now. So there’s no time to delay.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93b259678ccc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[jQuery — Textbook for Beginners]]></title>
            <link>https://medium.com/@AntonShevchuk/jquery-textbook-for-beginners-c608a1a66f9c?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/c608a1a66f9c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[jquery]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 12:21:01 GMT</pubDate>
            <atom:updated>2026-04-07T12:21:01.413Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>I Translated a jQuery Textbook in 2026. Yes, Really.</h4><p>Let me set the scene. It’s 2026. The JavaScript ecosystem has had approximately 47 new libraries since you started reading this sentence. AI writes your code, reviews your code, and occasionally argues with itself about your code. And here I am, publishing a jQuery textbook. In three languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BQHXmMp4xynL5Ea1Tb06fg.jpeg" /><figcaption>jQuery — Textbook for Beginners</figcaption></figure><p>I know what you’re thinking. But hear me out.</p><h3>The Elephant in the &lt;div&gt;</h3><p>According to <a href="https://w3techs.com/technologies/details/js-jquery">W3Techs</a>, jQuery is still used on <strong>70% of all websites</strong> on the internet. Not 7%. Not 17%. Seventy percent. Three out of four websites you visit today are shipping jQuery. WordPress, Shopify, Bootstrap* — they all still depend on it. Your bank’s online portal? Almost certainly running jQuery. That government website where you file your taxes? jQuery. The airline booking page that crashed last time you tried to grab a cheap flight? You guessed it.</p><p>So while Twitter (sorry, X… sorry, whatever it’s called this week) developers debate whether LLM are better for writing a code, the rest of the world quietly uses $(&#39;.button&#39;).click() because it still works.</p><h3>The Book That Should Have Been Translated 10 Years Ago</h3><p>I wrote “jQuery for Beginners” back in 2012. In Russian. Over 20,000 downloads, more than 600k views on scribd, a print run, and multiple editions later, the book was still only available in Russian. The English and Ukrainian translations were always “coming soon” — for about a decade.</p><p>Well, it’s no longer “coming soon.” It’s here. Better late than never, right?</p><p>Is it the most timely translation? No. Should it have happened in 2014 when jQuery was at its peak? Absolutely. But I still believe we have to think like programmers — while we still can. LLMs are great at generating code, but understanding <em>why</em> something works the way it does? That’s on us. And a textbook that walks you through the fundamentals, step by step, is still the best way to build that understanding.</p><h3>Who Is This For</h3><p>If you’ve never touched jQuery and need to maintain a project that uses it — this is for you. If you’re a JavaScript developer who skipped the jQuery era and now stares at $(document).ready() in confusion — this is for you. If you&#39;re building an LLM training dataset and need clean, structured content about the library that powers 70% of the web — well, I can&#39;t stop you.</p><p>And let’s be honest about the elephant in the enterprise room. Behind every shiny corporate landing page built with the latest framework, there’s a holy huge amount of bloody enterprise code running on jQuery. Internal dashboards, admin panels, CRM integrations, reporting tools — the stuff that actually keeps businesses running. Nobody rewrites it. Nobody has the budget to rewrite it. Nobody <em>wants</em> to rewrite it. It works, it’s been working for 10 years, and your job is to keep it working for 10 more. So you’d better understand how it ticks.</p><p>You can put whatever you want in your resume. But on your first maintenance project, $(document).ready() will be there, waiting for you. With legacy code older than some frontend frameworks. And sometimes older than some frontend developers.</p><h3>What’s Inside</h3><p>The book takes you from zero to writing your own jQuery plugins across 10 progressive chapters:</p><ul><li><strong>0% — HTML, CSS &amp; JavaScript</strong> — the prerequisites. Semantic markup, CSS selectors, specificity, JavaScript fundamentals. Because you can’t build on a shaky foundation.</li><li><strong>10% — Getting Started</strong> — connecting jQuery, the $() function, selectors, the Sizzle engine, and optimization tips that still matter.</li><li><strong>20% — Attributes &amp; Properties</strong> — CSS manipulation, classes, attr() vs prop() (yes, there&#39;s a difference, and yes, it will bite you), dimensions, positioning, data attributes.</li><li><strong>30% — Events</strong> — handlers, bubbling, namespaces, delegation, touch events. The stuff that makes interactive pages actually interactive.</li><li><strong>40% — Animation</strong> — easing functions, progress callbacks, queues, the animate() method and everything it can do.</li><li><strong>50% — DOM Manipulation</strong> — creating, cloning, wrapping, replacing, removing elements. The bread and butter of jQuery.</li><li><strong>60% — AJAX</strong> — load(), $.ajax(), event handlers, JSONP, prefilters, converters, custom transports. From basics to the deep end.</li><li><strong>70% — Async Patterns</strong> — Deferred, When, Callbacks. jQuery’s answer to asynchronous JavaScript, before Promises were cool.</li><li><strong>80% — Forms</strong> — events, validation, serialization, element manipulation. The unglamorous but essential stuff.</li><li><strong>90% — Writing Plugins</strong> — your first plugin, data registry, extending animation, custom easing, Sizzle pseudo-selectors.</li><li><strong>100% — The Final Chapter</strong> — where I run out of things to teach and send you off into the world.</li></ul><p>Plus an appendix covering jQuery UI, jQWidgets, and migration guides for versions 2.x, 3.x, and 4.x.</p><p>Each chapter comes with interactive code examples you can <a href="https://anton.shevchuk.name/book/code/">play with live</a>.</p><h3>Three Languages, One Repository</h3><p>The book is now available in:</p><ul><li><strong>English</strong> — <a href="https://antonshevchuk.gitbook.io/jquery-for-beginners/en">read on GitBook</a></li><li><strong>Ukrainian</strong> — <a href="https://antonshevchuk.gitbook.io/jquery-for-beginners/uk">читати на GitBook</a></li><li><strong>Russian</strong> — <a href="https://antonshevchuk.gitbook.io/jquery-for-beginners/ru">читать на GitBook</a></li></ul><p>All three versions live in a <a href="https://github.com/AntonShevchuk/jquery-book">single GitHub repository</a> with identical structure. Code examples are shared — only the surrounding text is translated.</p><p><em>jQuery is dead. Long live jQuery.</em></p><p><strong>Links:</strong></p><ul><li>Book: <a href="https://antonshevchuk.gitbook.io/jquery-for-beginners">English</a> | <a href="https://antonshevchuk.gitbook.io/jquery-for-beginners/uk">Ukrainian</a> | <a href="https://antonshevchuk.gitbook.io/jquery-for-beginners/ru">Russian</a> | <a href="https://github.com/AntonShevchuk/jquery-book">GitHub</a></li><li>Code examples: <a href="https://anton.shevchuk.name/book/code/">Live demos</a> | <a href="https://github.com/AntonShevchuk/jquery-for-beginners-code">Source</a></li><li>Author: <a href="https://anton.shevchuk.name/">anton.shevchuk.name</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c608a1a66f9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Talend to Boomi Migration]]></title>
            <link>https://medium.com/@AntonShevchuk/talend-to-boomi-migration-2614409bef46?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2614409bef46</guid>
            <category><![CDATA[enterprise]]></category>
            <category><![CDATA[boomi]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[talend]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 07:00:28 GMT</pubDate>
            <atom:updated>2026-01-13T09:27:07.244Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*puFv5Z9MYN0MhnZg.jpg" /></figure><p>In a <a href="https://medium.com/@AntonShevchuk/enterprise-architecture-and-boomi-a-beginners-guide-30ac49888709">previous article</a>, I already mentioned that I am currently working on migrating ETL processes from Talend to Boomi. So now, I can compare these two systems: what is convenient, what isn’t, and where the specific nuances lie.</p><blockquote>Before I continue, I want to note that all my judgments are subjective and may differ from your experience. I worked with processes that started development in Talend 10 years ago, and today they might seem like the legacy of a “bloody Enterprise,” so don’t be surprised that my experience is rather negative.</blockquote><h3>Developer Environment</h3><p>The first thing a developer encounters is the working environment.</p><p>Talend offers Talend Studio, which is built on Eclipse. It is a universal solution, but I wouldn’t call it convenient. Perhaps it’s just my post-traumatic stress from past experiences with Eclipse, but it didn’t click for me because everything worked, to put it mildly, slowly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G9Bg9xa5FrGFsdPa.png" /></figure><p>Boomi Platform is a modern iPaaS solution. For development, a browser is enough; you don’t need to install anything extra, and you don’t need instructions, licenses, etc. Everything is done well, and I have almost no complaints about the performance of their platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OT5Tp4ARrpsq6m2s.png" /></figure><h3>“Code” Versioning</h3><p>Talend uses Git “under the hood,” and you save all processes in a repository. You have the ability to hand the process over to AI; it will parse it and can subsequently answer questions regarding what that process does and how. This helps a lot, especially when requirements are missing and the migration process turns into a sort of reverse engineering.</p><p>Boomi also has versioning, but it is built into the platform. You can quickly revert to a previous version of a process or even a component, and you can download the XML of your process. This is, of course, convenient, but you do not have access to the repository as you do in Talend. Add to this the lack of process locking during editing, and you potentially have a headache when editing processes simultaneously.</p><blockquote>⚠️ <strong>Note:</strong> Both systems have the ability to create branches, but my advice to you is: do not use this feature without need and stick to a single branch (or create a branch per process). Otherwise, resolving conflicts in these systems is quite a challenge. Stick to a simple rule — only one developer should work on a process at a time. I don’t believe I have written this…</blockquote><h3>Working with Databases</h3><p>In my case, both systems worked with MSSQL, and both used the exact same Microsoft JDBC Driver. For Talend, this capability comes “out of the box,” whereas for Boomi, I had to upload the driver as a JAR file to the Runtime.</p><p>Moving forward, I will discuss the nuances I encountered specifically in Boomi. While I saw the existing implementation in Talend, I don’t know what specific challenges the original developers faced or why they chose certain solutions.</p><p>Boomi currently offers two database connectors.</p><p>The first is <strong>“Database (Legacy).”</strong> It is quite flexible and versatile, but it has one flaw: it operates on documents that use a specific profile format. Effectively, these profiles describe the database query itself rather than the actual document. This is inconvenient when building a process because you then have to create a separate profile for the documents and a mapping to transform from one to the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JLz1B6rETrUUZz_T.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kCO-ImIjk1rvDRXw.png" /></figure><p>This problem is resolved by the <strong>“Database V2”</strong> connector. It operates using a universal JSON document profile, and the database query itself has been moved to the “Operation” component, which feels much more logical:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vSOm68N01et54OOp.png" /></figure><p>However, in my opinion, this connector is not as flexible as the previous version. I might even go so far as to say it feels a bit “raw,” as it suffers from some teething issues regarding query syntax validation.</p><p>Boomi also has limitations when working with temporary tables. Since these tables exist within the scope of a single connection, you can only interact with them within a single process shape. Boomi does not guarantee that two separate shapes making database calls will execute within the exact same connection rather than picking up a different one from the connection pool.</p><p>On the bright side, what was important to me was that the mechanism for handling <strong>transactions</strong> and <strong>try-catch</strong> blocks proved to be clear and familiar — something I had to implement in almost every process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NKvb_oelMmc--P9Z.png" /></figure><p>It looks quite primitive, but nevertheless, it works effectively and is understandable to any developer.</p><h3>Mapping</h3><p>Talend offers multi-mapping capabilities — essentially, this is when we merge several documents into one or transform them into multiple outputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*Q7afdQhZSV1ko9qY.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/0*E7JHO3PkF45uL6B_.png" /></figure><p><em>The screenshots are taken from </em><a href="https://help.qlik.com/talend/en-US/studio-user-guide/8.0-R2024-05/tmap-operation"><em>the official manual</em></a><em> of QlikTech International AB.</em></p><p>In Boomi, merging two documents into one is more difficult. To achieve this, you have to add a mapping function to every field or write a custom script to handle it. On top of that, you might even need to set up an additional cache to make it all work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aKPzaEHTP1645Vcf.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pruWY6OfKDbSBIvz.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5yIOk_QAfQ0Tf1vK.png" /></figure><p>While the Boomi option might seem less flexible, the implementation in Talend has a major drawback: this type of mapping degrades the readability of the process. Add to this the lack of a field search feature, and Talend’s advantage very quickly turns into a massive headache.</p><p>In my opinion, mapping in Boomi is clearer; the use of mapping functions fosters discipline and allows for convenient code reuse (more on this later).</p><p>I would describe my experience with mapping in Talend as traumatic because every time it felt like an encounter with the Demogorgon:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*-kQREtG46WdJH_CU.jpg" /></figure><h3>Dynamic Configuration</h3><p>One thing that is conceptually impossible to do in Boomi is to configure a connection during process execution. You cannot change a database connection string while the process is running, nor can you swap in a different SFTP configuration after launch. These settings, among others, must be established for the process before execution begins.</p><p>On one hand, this is certainly a “hard” limitation, but it is intentional, as it effectively forms the foundation for your billing with Boomi (connector licensing). On the other hand, a well-designed process will know all possible connections in advance, right at the start of its operation.</p><p>Ultimately, the processes that required such an approach were implemented, though it did require additional time for configuration.</p><blockquote>But <a href="https://help.boomi.com/docs/Atomsphere/Integration/Process%20building/int-Creating_dynamic_process_connections_59f6fbfa-231b-4596-8fd2-c21f0a4809df">creating dynamic process connections</a> is still possible for select accounts.</blockquote><h3>“Code” Reusability</h3><p>Both Talend and Boomi allow you to create sub-processes and use them within a main process.</p><p>I must note that calling sub-processes is implemented more conveniently in Talend, as the launch settings are configured directly within the properties of the element triggering the sub-process. In Boomi, you have to use a separate, additional “Set Properties” shape to achieve this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nUEGL_k0jCJSpQXl.png" /></figure><p>It might not seem overly complicated, but I still find the solution offered by Talend to be more logical. Furthermore, the Boomi approach requires extra vigilance when invoking a sub-process multiple times to avoid introducing errors.</p><h3>Custom Code</h3><p>Talend allows you to insert Java code into almost every field. Conceptually, this looks flexible, but my work very often resembled an investigation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*sYQ8SDQwLGY0CsCK.jpg" /></figure><p>Talend also allows you to create and add custom Java libraries for use. Uh-huh, you can call a Java library from almost any field, and here too I…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*ypwHeQL6INTph7b5.jpg" /></figure><p>When working with Boomi, you can also use custom Java libraries, such as iText or jsoup, or write your own. However, you will develop and compile them outside of Boomi, uploading the ready-made JAR files to the platform.</p><p>The use of custom code in Boomi is limited to <strong>Process Scripts</strong> and <strong>Map Scripts</strong>, which are always easy to find among the components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/0*GQgZyffw-2zPq-26.png" /></figure><p>To utilize custom libraries, you will ultimately still be using JavaScript or Groovy. As I noted in my previous article, the only questions I have relate to the versions supported by Boomi: you have to write code as if it were 10 years ago. While it’s not exactly a problem, it is still a bit annoying.</p><h3>Boomi’s Advantages</h3><p>Boomi has one massive plus: the ability to reuse almost all components — actions, profiles, mappings, and scripts — without needing to package them as Java libraries. This makes life significantly easier for developers. The key is to properly organize, document, and share knowledge about these shared components across the team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/0*aoPRIEeRpwkF4eXF.png" /></figure><p>As I mentioned earlier, the implementation of transactions and handling of try-catch blocks is convenient and predictable.</p><p>There were other moments when I appreciated Boomi features that were absent in Talend (or perhaps the developers simply didn’t use them because they were released after the process was created).</p><p>Take PGP Encrypt/Decrypt, for example. In Boomi, you upload the certificate via the interface and use it within the Data Process shape:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/0*3DEtdw2I7zLXk5bg.png" /></figure><p>As you can see, Base64 handling is done via the UI rather than through code; the same applies to Zip archiving.</p><p>The logging is very advanced, allowing you to easily debug processes, analyze performance, and locate bottlenecks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*SURn2TcveJoQjPJb.png" /></figure><p>I should add that Boomi has another major advantage — built-in AI functionality capable of documenting processes (and that is not the only thing it can do).</p><p>I wouldn’t say it does this particularly well, though — I would rate it 3 out of 5 stars. Personally, I find it lacking in its ability to understand and navigate through sub-processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SHSkIxOd3Bn67ulm.png" /></figure><p>I should also highlight the significant progress their AI has made in building processes: it is getting smarter, though in my opinion, it is still too early to let it build processes entirely on its own. Perhaps in six months to a year, this will evolve into a truly useful tool.</p><h3>Boomi’s Disadvantages</h3><p>The main drawback, which I already complained about in the previous article, is that the logging — which I praised earlier — heavily impacts performance. It is impossible to disable it for scheduled processes, and as a result, the difference in execution time between Talend and Boomi for the exact same process is 3–4 times.</p><p>There is a separate issue regarding large volumes of data: when you have a huge number of documents (millions), you should not attempt to count them in Boomi, as this significantly affects performance.</p><p>Do not do this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AV32cwZgQAf1dlE-.png" /></figure><h3>What can be improved in Boomi?</h3><blockquote>This note is primarily for the Boomi developers, and I hope it reaches the right person.</blockquote><p>Working with <strong>Dynamic Process Properties (DPP)</strong> and <strong>Dynamic Document Properties (DDP)</strong> requires you to constantly “remember” the names of these properties. You use them constantly, which forces you to copy-paste names — this is inconvenient and leads to errors. It would be great if the system tracked DPPs and DDPs during development and allowed you to select from previously created ones. Also, during <strong>Test Mode</strong>, I would like to see what is happening inside those properties without having to check them using separate elements.</p><p>Working with <strong>Document Profiles</strong> could also be improved. When the first element of a process returns a specific profile and we add a subsequent element, such as a Map, it would be convenient if it automatically understood the context and selected the appropriate profile. Currently, the system doesn’t suggest which profile to choose, leading to errors that happen quite often during development (although they are easily diagnosed).</p><h3>What do you need to know? Or why Low-Code doesn’t mean No-Knowledge</h3><p>If you think working with Boomi is just about dragging and dropping icons, I have to disappoint you. To build serious solutions, you will need a comprehensive technical background. Here is why:</p><ul><li><strong>Programming:</strong> Yes, Boomi allows you to do a lot visually, but as soon as the logic becomes non-standard, you will have to write scripts. JavaScript rules here, but there is a nuance: it’s the good old <strong>ECMAScript 5</strong>, so forget about the trendy features of modern JS. And since the platform runs on a Java Virtual Machine, knowledge of <strong>Java</strong> or <strong>Groovy</strong> becomes your secret ace for solving tasks that ordinary JS can’t handle. And, of course, understanding data structures and writing unit tests is still mandatory.</li><li><strong>Data Handling:</strong> Integration is essentially moving data from one pocket to another. You need to be comfortable with databases, and we aren’t talking about simple SELECT queries. Real cases require working with <strong>Stored Procedures</strong> and transactions, especially in MSSQL. Furthermore, <strong>JSON</strong> and <strong>XML</strong> will become your constant companions. While JSON is the modern standard, XML — and the ability to write <strong>XSLT transformations</strong> for it — is the harsh reality of Enterprise systems that you just have to accept.</li><li><strong>Connectivity:</strong> You need to be a polyglot here. <strong>REST API</strong> is your base: you must understand how HTTP methods and authorization work. But an Enterprise wouldn’t be an Enterprise without <strong>SOAP services</strong>, so you’ll have to learn to “make friends” with them too. To build modern asynchronous architectures, you will need experience with message queues, specifically <strong>Apache Kafka</strong>, so your systems can exchange data instantly and reliably.</li><li><strong>Infrastructure &amp; Security:</strong> Your process doesn’t exist in a vacuum. You need to understand the cloud environment: what load balancers are, how auto-scaling works, and how to monitor system health. And, of course, security: understanding <strong>OAuth</strong>, <strong>SSL certificates</strong>, and other authentication methods is not an option — it’s a necessity to ensure your integrations don’t become a security breach for the company.</li></ul><h3>Boomi. This is the Way</h3><p>This article doesn’t aim for a clickbait “Boomi VS Talend” headline. My primary goal was to share my experience and highlight one fact: <strong>migration from Talend to Boomi is possible.</strong></p><p>But do you and your company need it? I cannot answer that for you; I only tried to provide you with some arguments should you face such a question. To give a definitive answer, you need to weigh many factors, including the cost of the solution, the cost of migration, and the cost of learning a new system.</p><p>I can give you a hint regarding the latter. In my opinion, to learn how to work with Boomi, you should aim for <strong>1 month of intensive training</strong>.</p><ul><li><strong>The first two weeks</strong> are needed to complete the <a href="https://train.boomi.com/path/integration-developer"><em>Integration Developer Path</em></a> and several <a href="https://community.boomi.com/s/developer-techniques">related topics</a>. After this, you can start picking up the first simple integration processes.</li><li><strong>The next two weeks</strong> involve diving into implementation examples, manuals, and developing best practices. Depending on your requirements, you might also need to take the <a href="https://train.boomi.com/associate-event-streams"><em>Associate Event Streams</em></a> and <a href="https://train.boomi.com/professional-api-design"><em>Professional API Design</em></a> courses.</li></ul><p>In general, retraining to become a System Integration Engineer in a month is possible, provided you already have the base knowledge.</p><h3>P.S.</h3><p>If you have also walked this migration path or have your own “workarounds” and life hacks for Boomi — please share them in the comments, I’d be interested to hear about your experience. I would be especially grateful if someone could suggest an elegant way to get around the issue with log performance. Because right now, it looks like a choice without a choice, and it’s really eating at me.</p><h3>P.P.S.</h3><p>No Talend developers were harmed during the migration…</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/architecture/migration-from-talend-to-boomi/"><em>https://anton.shevchuk.name</em></a><em> on January 12, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2614409bef46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enterprise Architecture and Boomi: A Beginner’s Guide]]></title>
            <link>https://medium.com/@AntonShevchuk/enterprise-architecture-and-boomi-a-beginners-guide-30ac49888709?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/30ac49888709</guid>
            <category><![CDATA[dell-boomi]]></category>
            <category><![CDATA[boomi]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 07:01:37 GMT</pubDate>
            <atom:updated>2026-01-06T09:02:34.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*NpZNYlJrWZVUPUlQ.jpg" /></figure><p>My journey with the Boomi platform began in February 2025. But what is it, why was it created, and can this tool actually be useful to you? I will attempt to answer these questions in this “brief” overview article.</p><p>However, before diving directly into the story of Boomi, I would like to start with the prerequisites that led to the emergence of such a system. Perhaps this context will immediately put everything in its place, making the concepts clear without the need for further explanation.</p><blockquote>This article is written for Tech Leads, Architects, and Managers of Enterprise projects. It contains many simplifications, but I believe this will aid in understanding the material. In any case, I would be glad to hear feedback from everyone.</blockquote><h3>Prequel “Enterprise”</h3><p>Sooner or later, most IT professionals encounter the development of various Enterprise systems. This could be internal product development for a company or a project for a client. Once you enter this space, you won’t be the same. You might enjoy working in this environment, or you might not, but over time, you certainly won’t regret the experience.</p><p><em>What is an Enterprise, and how does it emerge?</em></p><p>An Enterprise is a complex system that supports business-critical processes spanning various company departments and integrating many separate subsystems.</p><p><em>So, if you have a small outsourcing company of 10 people simultaneously using CRM, HRM, Jira, GitHub, etc., does that count as an Enterprise?</em></p><p>Yes and no.</p><p>The key difference lies in the approach to processes:</p><ul><li>If your processes are not automated and mostly resemble manual checklists for humans, it seems your processes are not yet mature and need to “ripen.”</li><li>If a company event (e.g., the onboarding of a new employee) automatically triggers several parallel processes and orchestrates the interaction between people and systems — that is a hallmark of an Enterprise.</li></ul><p>Enterprise systems largely consist of exactly these types of processes — lots of them.</p><p>How many processes are needed to confidently say, “Now <em>this</em> is an Enterprise”? No one can give an exact answer — perhaps 100, perhaps 1000. But sooner or later, a growing company will cross this threshold and face new challenges.</p><p>How will this happen? There are several paths:</p><ol><li><strong>Evolutionary</strong></li><li><strong>Revolutionary</strong></li><li><strong>Or a mix of both in varying proportions</strong></li></ol><h3>Enterprise Evolution</h3><p>This is the classic story of a successful startup or small company. Changes happen gradually, driven by the pressure of new requirements when old solutions no longer suffice.</p><p>Let’s look at a few examples.</p><h4>Stage I. The Prolonged MVP</h4><p>The company has one or several key services around which the entire business revolves. There may be other services (e.g., subscription-based tools), but they are barely connected to one another.</p><p>Interaction primarily occurs through people communicating between different systems — acting as <strong>“Human middleware.”</strong></p><p>Over time, as the business grows, coordination consumes too much time. The company is forced to hire staff whose sole purpose is effectively just to maintain these manual processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*jiLL-17SQU7E1cV-.png" /></figure><h4>Stage II. Service Zoo and Point-to-Point</h4><p>The company grows, and someone responsible for infrastructure emerges. They try to assemble a team from various departments but run into the eternal problem: everyone has “no time.”</p><p>There are countless scenarios for how this develops: from breaking down monoliths into microservices and purchasing SaaS solutions (Salesforce, Zendesk) to complete chaos, where all of this is implemented simultaneously and uncontrollably.</p><p>The result of such chaos is <strong>Point-to-Point</strong> integration. The system turns into a tangled web of connections: services are <strong>tightly coupled</strong> and know too much about each other. As a consequence, maintenance becomes difficult, and the cost of any changes increases exponentially.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*pH2t21Pr5bozIqmM.png" /></figure><h4>Stage III. Middleware Maturity</h4><p>Over time, it becomes evident that a single person is physically unable to keep pace with the system’s evolution. Consequently, the company forms a dedicated department to handle infrastructure.</p><p>Someone from this new team assumes the role of Enterprise Architect and concludes that further growth and change require the implementation of middleware. Here is what will change:</p><ul><li>Developers will be introduced to the <strong>Enterprise Service Bus (ESB)</strong>.</li><li>The concept of a <strong>Canonical Data Model</strong> (a unified data format for the entire company) will emerge.</li><li>Direct service-to-service calls will be prohibited; all communication will be routed through a <strong>broker/bus</strong>.</li><li>The <strong>Strangler Fig</strong> pattern will be applied: old legacy code will be gradually replaced by new services without taking the system offline.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*2SNQxWWHApgrTLw1.png" /></figure><p>As an alternative or a complement, companies begin considering an <strong>Integration Platform</strong> (one of which is Boomi, but more on that later).</p><blockquote>Evolution is about refactoring and standardization. It involves the gradual introduction of “rules of the game” (API contracts, events) that reduce entropy (chaos).</blockquote><h3>Enterprise Revolution</h3><p>This is a stress test for architecture. It happens when a large company acquires another or when two giants merge (<strong>M&amp;A</strong>). There is no time for slow refactoring here — the business demands results “yesterday.”</p><p>There are no stages here — only challenges that must be solved immediately.</p><p>Imagine the situation: “<em>Bank A acquires Fintech B”.</em> The Enterprise Architect faces a series of tasks:</p><h4>Challenge 1. Functional Duplication</h4><p><strong>The Situation:</strong></p><ul><li>Bank A has its own CRM (“Homegrown, old, but reliable”).</li><li>Fintech B has its own CRM (“Trendy, cloud-based”).</li></ul><p>The CTO makes an executive decision: “Rip and Replace.” Within 6 months, Fintech B is obligated to scrap its system and migrate to the Bank’s CRM (was there really any doubt about who would stay?).</p><p><strong>What happens next?</strong> Do we dive into the hell of migration scripts, field mapping, and data loss? <strong>No.</strong></p><p>This is where <strong>ETL tools (Extract, Transform, Load)</strong> are critically needed to correctly “pump” data from one structure to another.</p><h4>Challenge 2. Data Silos</h4><p><strong>The Situation:</strong> You have customer information residing in two different systems that are disconnected and unsynchronized.</p><p><strong>Consequences:</strong> Data inconsistency, duplicated effort, and inaccurate analytics.</p><p><strong>What to do?</strong> This is where you need to implement <strong>MDM (Master Data Management)</strong>. It encompasses the technology, processes, and policies that allow you to create a <strong>“Golden Record”</strong> and establish a <strong>Single Source of Truth (SSOT)</strong>.</p><h4>Challenge 3. “Federation”</h4><p><strong>The Situation:</strong> Sometimes, merging systems quickly is impossible, yet you must ensure they operate simultaneously <em>right now</em>.</p><p><strong>What happens next?</strong> We build a <strong>“Facade”</strong> — a shared API that accepts a request and decides “under the hood” where to route it: to the Bank’s old system or the Fintech’s new one. To the user, it looks like a single unified system, even though internally it is a “Frankenstein.”</p><blockquote>Revolution is about integration and migration. It involves combining disparate systems, using adapters and data buses, and making tough administrative decisions (“we are shutting down this server on the 1st”).</blockquote><h3>Boomi. Prologue</h3><p>It is time to talk directly about Boomi.</p><p><strong>Boomi is an iPaaS (Integration Platform as a Service).</strong> It is a tool for implementing backend logic without hardcore coding (sad face here).</p><p>Architecturally, Boomi consists of two parts:</p><h4>1. Boomi Platform (The Build)</h4><p>This is essentially a “Visual IDE” in your browser where we develop and configure processes. Instead of writing functions, we drag and drop icons:</p><ul><li>HTTP Client Connector</li><li>Map Shape</li><li>Database Connector</li><li>and others…</li></ul><p>We connect them with arrows into a single flow.</p><p>This is also where administrative actions take place: viewing logs, managing settings, and creating execution schedules.</p><p>All of this runs in the cloud — fast and predictably. The only caveat is that the automatic alignment in complex processes might cause some frustration, but otherwise, everything is quite “smooth”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tF5MLAZf4GCWwQ_Q.png" /></figure><h4>2. The Runtime (The Execution)</h4><p>The second component is the Runtime. Essentially, it is a Java application (JVM) that executes the “code” generated by the platform.</p><p>How it works: When you click “Deploy” on the platform, Boomi compiles your visual process into a package and sends it to the Runtime for execution.</p><p>Important note: There are several types of Runtime:</p><ul><li><strong>Basic Runtime</strong></li><li><strong>Runtime Cluster</strong></li><li><strong>Runtime Cloud</strong> (Private or Public)</li></ul><p>I will explain how they differ and when to choose which a bit later.</p><h3>Boomi. Episode I</h3><p>Moving forward, I will follow the “path” of Enterprise evolution and explain where and how Boomi can be applied, as well as which Runtime is best to choose.</p><p>Let’s start with the first scenario, where we need to connect services that are living their own separate lives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*cy_MWieyDrJd0qRa.png" /></figure><p>Imagine a small company using subscription-based services that simply cannot integrate with one another. Previously, humans maintained these processes: updating a status on a board here, downloading files there, or issuing an invoice to someone.</p><p>In this scenario, <strong>Boomi Runtime Cloud</strong> is the perfect fit. It is a cloud runtime hosted and managed by Boomi itself. It requires minimum additional effort — just develop the process, deploy it, and use it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zQN_x4y6pl5Zvhjc.png" /></figure><p>We don’t need real-time processing here, so we can create a separate schedule for each process. The processes will run Point-to-Point between services.</p><p>Such a scheme can be implemented quite quickly because Boomi supports over 1,000 out-of-the-box connectors — <a href="https://boomi.com/connectors/">https://boomi.com/connectors/</a> (though keep in mind that you will have to pay specifically for the <em>connected</em> connectors):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RMsM405_-sC7lHPO.png" /></figure><p>Essentially, for this fictional scenario, it looks like IFTTT on steroids.</p><p>Let’s consider an alternative company that hosts services on its local network or in a VPC. In this case, Boomi Runtime Cloud won’t be able to access the company’s services.</p><p>The option of configuring the firewall to allow Boomi to reach all internal services seems insecure. So, we will take a different path and deploy our own <strong>Basic Runtime</strong> behind the firewall:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*79YXFCb_sKbY8jVo.png" /></figure><p>From a process development perspective, nothing changes. However, the deployment process does change, and the infrastructure responsibility shifts to the DevOps team. It is now their headache to figure out how to spin up the instance and how to monitor it.</p><p>You can learn more about which instance to select from the training materials, but I will include a table here to give you a general idea of the requirements:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*OJ5a3l_X_ltro8R4DhJlHA@2x.png" /><figcaption>Basic Runtime</figcaption></figure><blockquote>To be honest, it is hard to say exactly what is meant by “transactions per day” in this context. Let’s assume that one “transaction” is a single simple process handling one document under 100KB.</blockquote><h3>Boomi. Episode II</h3><p>Let’s move on. Our next example is an Enterprise dealing with a “Zoo” of Point-to-Point services.</p><p>We are not going to clear away this mess; we are going to tame it.</p><p>In this fictional scenario, we will migrate processes to Boomi. Since there are many processes and they are mission-critical for the company’s operation, we must ensure the system’s uninterrupted operation under constant load.</p><p>For this purpose, Boomi provides the <strong>Runtime Cluster</strong>, which ensures both High Availability and Scalability of the system — at the cost of your DevOps team’s time and by leveraging the capabilities of Cloud providers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8yO8-BYbTa7wb0d-.png" /></figure><p>The Boomi Cluster has a number of specific characteristics.</p><p>The first feature is the use of a Shared File System. All nodes mount a directory responsible for storing configurations, logs, and message queues — everything resides in one central place.</p><blockquote>Please be careful with the Shared File System (NFS/EFS), as it can negatively impact process performance (latency).</blockquote><p>The second feature to keep in mind is that the number of nodes is limited due to Network Chatter (inter-node communication). The recommended limit is 10 nodes. If this is not enough for your needs, you will have to build a new cluster and manually distribute processes across these clusters, which creates additional administrative overhead (“headache”) for everyone.</p><p>Just in case, I did a little Googling for you. Here are a few articles on Cluster setup:</p><blockquote>A note on terminology: Until about six months ago, Boomi used the naming convention <strong>Atom</strong> (for Single Runtime) and <strong>Molecule</strong> (for Cluster). Consequently, you will encounter this terminology in the documentation from time to time.</blockquote><p>Information regarding the recommended cluster size can also be found in the training materials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*0B42lSCsnogI0yPoyLJBrw@2x.png" /><figcaption>Runtime Cluster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*qDBOEOFHYbdzULrW-dUO4A@2x.png" /><figcaption>Runtime Size for Cluster</figcaption></figure><h3>Boomi. Episode III</h3><p>It is time to discuss implementing <strong>EDA (Event-Driven Architecture)</strong> with Boomi.</p><p>When your Enterprise system starts using a message bus for communication, your focus shifts to developing adapters for your services:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*0Wo1Q_eB5UOwfPuC.png" /></figure><p>These adapters are responsible for the business logic that bridges the Event Bus and the Service APIs. And naturally, you can implement these services using Boomi:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4QjhNmXh6n6tQWcd.png" /></figure><p>Now, regarding which bus to choose if you don’t already have one, there are several options.</p><p><strong>Option 1: Use the built-in queue mechanism within the Runtime — Boomi Atom Queue.</strong> It resides on your Runtime or Runtime Cluster. This bus has a significant limitation: it can only be interacted with via Boomi processes. Therefore, no external services can access the queue without Boomi acting as an intermediary.</p><p>Furthermore, relying on the file system (or network file system for a cluster) for storage imposes limits on performance. Reliability becomes your “headache.” Monitoring capabilities for such queues are extremely limited.</p><blockquote>Note: Boomi Atom Queue is already considered “Legacy”, though it will continue to be supported.</blockquote><p><strong>Option 2: Boomi Event Streams.</strong> This is a separate SaaS service provided by Boomi, where Boomi manages the infrastructure. Via API, external systems can publish messages to the queue, but consuming (listening) directly is a no-go — that remains internal to Boomi. There is a dashboard within the Boomi Platform interface for monitoring. In this case, pricing is based on data volume.</p><p><strong>Option 3: Use Kafka, RabbitMQ, or any other third-party message broker.</strong> There are no usage restrictions, but the entire operational responsibility lies with you. Reliability and monitoring are fully within your scope.</p><p>In my experience, Boomi works excellently with Kafka. However, do remember that in this case, the connector to the external system will count towards your Boomi license bill.</p><h3>Boomi. Episode IV</h3><p>Let’s turn to the Enterprise Revolution. How can we utilize Boomi when time is scarce and results are demanded “yesterday”?</p><p>Boomi is designed to accelerate the path from requirements, development, and testing to a production result as much as possible.</p><p>If you need to rapidly build an ETL (Extract, Transform, Load) process, Boomi is an excellent fit, offering numerous built-in tools to orchestrate it. And if those fall short, you can always write custom code for document processing. Boomi supports both JavaScript and Groovy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MLTJiudJ4Ncn5zNS.png" /></figure><p>Did the previous paragraph sound like a marketing brochure? Fair enough, let’s get down to the system specifics.</p><p>Let’s start with the code we can inject into processes.</p><p>The first option is JavaScript, but only ECMAScript 5 is supported. Why? Because it’s not Node.js running the JavaScript; it is executed by the Java Virtual Machine (JVM), which uses its own scripting engine. On the plus side, you can invoke built-in Java classes, and even more — you can upload a JAR file to your Runtime and call it directly.</p><p>The second option is Groovy. We can use version 1.5 or 2.4. I am not a Groovy developer, but something tells me these are quite old versions 🙁.</p><p>It is also worth noting that there aren’t many public code examples available. The side effect is that AI cannot correctly generate most scripts. So there’s that.</p><p>What else? Performance. Here, I can compare Boomi against Talend, as we migrated many processes from one system to the other. I observed that process implementation in Boomi runs slower, and I have a theory why.</p><p>For scheduled processes, Boomi uses the so-called General Process Mode. In this mode, Boomi logs <em>everything</em>: every step, every document, every transformation. All of this consumes a lot of time and storage space.</p><p>Can you choose a different execution mode? Yes, there is Low Latency mode, but it does not work for scheduled processes.</p><p>So, what is the conclusion? If you have chosen Boomi as the iPaaS for your company, its capabilities will likely be sufficient even for building ETL processes that handle gigabytes of data. It might not be as fast as competitor solutions, but I hope the developers will address this issue in the future.</p><h3>Boomi. Episode V</h3><p>To implement <strong>Master Data Management</strong>, Boomi provides a tool called <strong>Boomi DataHub</strong>, which allows you to resolve the issue of Data Silos.</p><p>Well, at least that is what the service description implies, as I have not personally worked with it.</p><p>Well, that turned out to be a short episode…</p><h3>Boomi. Episode VI</h3><p>So, what about Boomi’s capabilities regarding API implementation for our fictional story?</p><p>Boomi offers two tools for this purpose.</p><p>The first is <strong>API Management</strong>. Here, we can configure access, generate keys, and set quotas. Additionally, Swagger is available “out-of-the-box,” along with a Developer Portal if needed.</p><p>The second tool is <strong>Integration</strong> itself. You build processes that trigger via external requests to specific endpoints, and then, based on defined rules, you can route the call to one internal service or another:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z9EJGJ_a3GcSXSnf.png" /></figure><h3>Boomi. Epilogue</h3><p>My story has run a bit long, but I hope I’ve helped you get a better grasp of what Boomi is and determine in which scenarios this tool is the right fit for you.</p><p>I’ll wrap up with a few additional resources:</p><ul><li>First, Boomi offers quite decent <a href="https://train.boomi.com/">training materials</a>. They are available for free. The only condition is that you must use a corporate email address to register on the portal; generic domains like Gmail won’t work. If we are talking about integration development, I recommend following the <a href="https://train.boomi.com/path/integration-developer">Developer Path</a>. Within a couple of weeks, you will already be able to demonstrate the first results of your work.</li><li>You can find many practical articles on the <a href="https://community.boomi.com/s/boomi-blueprint">Boomi Blueprint page</a>.</li><li>Community Articles: There were times when I found answers only there — <a href="https://community.boomi.com/s/">https://community.boomi.com/s/</a></li><li>And, of course, the <a href="https://help.boomi.com/">Official Manual</a>. While not the most informative, it is still quite useful.</li></ul><p>P.S. We have only scratched the surface of what Boomi can do. If you found this guide helpful and want to dive deeper into specific technical details, best practices, or “war stories” from my experience — let me know in the comments (or give this post a like). Your feedback will determine if there will be a “Season 2”!</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/architecture/enterprise-architecture-introduction-to-boomi/"><em>https://anton.shevchuk.name</em></a><em> on January 5, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30ac49888709" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Chat Bot. Publication on Google Workspace Marketplace]]></title>
            <link>https://medium.com/@AntonShevchuk/google-chat-bot-publication-on-google-workspace-marketplace-6f5d58f995ff?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f5d58f995ff</guid>
            <category><![CDATA[chat-bot-development]]></category>
            <category><![CDATA[apps-script]]></category>
            <category><![CDATA[google-workspace]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Wed, 03 Jul 2024 11:00:25 GMT</pubDate>
            <atom:updated>2024-07-09T12:01:25.549Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*0NWKThcicTIdyzJD.png" /></figure><p>It has finally happened! Bot <a href="https://github.com/AntonShevchuk/bender-2.0">Bender 2.0</a> is now available for installation from the <a href="https://workspace.google.com/marketplace/app/bender_20/667012984956">Google Workspace Marketplace</a>. In this post, I will walk you through the steps needed to get to the marketplace.</p><blockquote>I won’t go into detail about the bot’s development in this article, as I assume you already have a working bot. So, the only remaining step is to get it to the marketplace.</blockquote><p>Let’s begin our work. First, we need to connect the <a href="https://console.cloud.google.com/apis/library/appsmarket-component.googleapis.com?pli=1">Google Workspace Marketplace SDK</a> to our project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rKQIHj8bQL_N0ncJ.png" /></figure><p>Next, we need to go to the Google Workspace Marketplace <a href="https://console.cloud.google.com/apis/api/appsmarket-component.googleapis.com/googleapps_sdk">SDK settings</a> and select the necessary options.</p><h3>App Configuration</h3><p>Let’s start with “App Visibility.” The bot will be public, and it will be listed in the search results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-FkgV1mQjY0vyWXc.png" /></figure><p>Anyone who wants to will be able to install it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j0vmK5E_W-z1c93b.png" /></figure><p>And yes, it is just an addition to the chat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-n1sAIg3jfoiZCZ0.png" /></figure><p>Only basic scopes, which do not require additional permissions, will be needed for it to work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*ifUjDmcszE1AXDsO.png" /></figure><p>A bit about yourself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PxPJ8rMxfTu-RdOu.png" /></figure><h3>Store Listing</h3><p>The “Store Listing” section also needs to be filled out carefully. Let’s start with a detailed description. I have written about the bot in both English and Ukrainian, but I believe the English description will be mandatory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WyhC6EcferL92p_j.png" /></figure><p>Prepare the icons and banners:</p><ol><li>Icons in sizes 32×32, 48×48, 96×96, 128×128</li><li>Card banner 220×140</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nIlQ2bWyJrrFIGp6.png" /></figure><p>Beautiful screenshots, just make sure that there is nothing sensitive in them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*BZFxksA8mC40xXKR.png" /></figure><p>And now a very important part, you must prepare the Terms and Privacy pages and add links to these pages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UmO-ZQdpO2HCqjoG.png" /></figure><p>As you can see, all my links point to <a href="https://github.com/AntonShevchuk/bender-2.0">GitHub</a>:</p><ul><li><a href="https://github.com/AntonShevchuk/bender-2.0/blob/main/PRIVACY.md">Privacy Policy</a></li><li><a href="https://github.com/AntonShevchuk/bender-2.0/blob/main/TERMS.md">Terms of Service</a></li><li><a href="https://github.com/AntonShevchuk/bender-2.0/blob/main/SUPPORT.md">Support Page</a></li><li><a href="https://github.com/AntonShevchuk/bender-2.0/wiki">User Manual</a></li></ul><p>After this, you will be able to submit your bot for review to the Google Workspace Marketplace. However, I didn’t pass the review on the first try, nor on the second:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_445YDtay2MhHNZX.png" /></figure><p>As you can see, I received the response “Rejected” three times, each time with the same text:</p><blockquote><strong>1. Links for Privacy Policy, Terms of Service and Support are provided and point to the correct information.</strong><br>You can check additional info about this <a href="https://developers.google.com/workspace/marketplace/create-listing#support_links">requirement here</a>.<br>All provided links work and point to the correct information. For example, a link provided for a privacy policy points to a page describing the privacy policy.</blockquote><blockquote><strong>2. Functionality — There are no obvious bugs and all visible actions are fully functional.</strong><br>You must ensure the Add-on is operational and functions in accordance with the description of the Add-on. You should thoroughly test all the add-ons you create before publishing using the available test options.</blockquote><p>I didn’t know what to do next because the links were there, but it seemed that the moderator didn’t like that the text was hosted on GitHub and simply ignored the links. So, when I received an email from the Google Workspace Marketplace Reviews Team for the fourth time, stating that they had started working on the review, I replied with a detailed explanation of what the app is, why it was created, and why all the links point to GitHub.</p><blockquote>Don’t miss that email; I received it between 12:00 and 3:00 PM Kyiv time, and within 2–3 hours, I received a rejection notice.</blockquote><p>And then there was silence. I used to receive rejected responses throughout the day, but this time the response was delayed. It seemed my request had passed the first level of moderation and moved to another level, where the decision was made to approve it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/0*rCaEmJbDLOq7Vtme.png" /></figure><p>That’s it, my bot Bender 2.0 is now available on the <a href="https://workspace.google.com/marketplace/app/bender_20/667012984956">Google Workspace Marketplace</a>. Install it, test it, and leave your feedback.</p><p>If you have also managed to publish your bot, leave the link in the comments :)</p><p>And yes, here is <a href="https://developers.google.com/workspace/marketplace/how-to-publish">the official documentation</a>, feel free to use it. Keep this article bookmarked so you know who to ask if you have any questions ;)</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/google/google-chat-bot-marketplace/"><em>https://anton.shevchuk.name</em></a><em> on July 3, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f5d58f995ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ukrainian Typographic Keyboard Layout for MacOS]]></title>
            <link>https://medium.com/@AntonShevchuk/ukrainian-typographic-keyboard-layout-for-macos-546509ec9f11?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/546509ec9f11</guid>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[typography]]></category>
            <category><![CDATA[keyboard-layout]]></category>
            <category><![CDATA[keyboard]]></category>
            <category><![CDATA[ukrainian]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Tue, 11 Jun 2024 13:00:28 GMT</pubDate>
            <atom:updated>2024-06-17T08:02:44.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*oRu7umCtokLxWRun.png" /></figure><p>It’s time for a major update of the <a href="https://github.com/AntonShevchuk/ukrainian-typography-keyboard-layout">Ukrainian typographic keyboard layout for MacOS</a>. First, let me tell you about the layout, and then about the changes that have occurred.</p><p>Firstly, what is a typographic layout, where did it come from, and how do you use it?</p><p>The first typographic layout I encountered was Ilya Birman’s, which was originally designed for Russian and English only. However, I needed a layout for the Ukrainian language, so among the possible options, I chose to create my own based on Ilya’s layout.</p><p><em>— Why do we need all these “typographic” layouts?<br>— Precisely to write this dialogue using nothing but the Ukrainian layout…</em></p><p>Typographic layouts are designed specifically to quickly type elements such as quotation marks „, “, and the long dash — rather than hyphens. And that’s not all; let me give you more examples of usage:</p><ul><li>Special symbols: ©, ®, and ™</li><li>Degree symbol: °, see how nice +24°C looks</li><li>Mathematical symbols: 1¹+2²+3³≠30, ¹⁄₂+¹⁄₃+¹⁄₄≈1, and2×2=4, with a real multiplication sign, not the letter x</li><li>Currency symbols: press ⌥ + р to get ₴ (for hryvnia), £, ¥, €, $, and ¢</li><li>Arrows: ←, →, ↑, and ↓</li><li>Checkmarks: ✓ or ×</li></ul><p>In fact, there’s a lot more to explore in terms of symbol variety, and many of these I actually use frequently:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qXTkwWWEylasSyj5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*15LtKgytnBdBlR2J.png" /></figure><p><em>— And what’s with that weird </em><em>Ы in the layout, why is it needed?<br>— It’s there to eliminate the need for the Russian layout altogether. So, even if you need to type those </em><em>Ы and </em><em>Э, you won’t need to switch to another layout or search for these symbols online anymore.</em></p><p>Overall, I aimed to enable typing any <a href="https://en.wikipedia.org/wiki/Cyrillic_script">Cyrillic letters</a> seamlessly:</p><pre>А   Б   В   Г   Ґ   Д   Ѓ<br>Ђ   Е   Ѐ   Є   Ё   Ж   З<br>З́   Ѕ   И   Ѝ   І   Ї   Й<br>Ј   К   Л   Љ   М   Н   Њ<br>О   П   Р   С   С́   Т   Ћ<br>Ќ   У   Ў   Ф   Х   Ц   Ч<br>Џ   Ш   Щ   Ъ   Ы   Ь   Э<br>Ю   Я</pre><p>But it’s not all that simple because for most characters with modifiers like accents (ў), stresses (а́), and umlauts (ä), you should use the so-called “dead keys”. You can see all of them with the Keyboard Viewer, open it and then simultaneously press ⌥ option+ ⇧ shift:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S8SahAj18rgO-G2NA4bHgw.png" /></figure><p>Here are a few examples of usage:</p><p>— simultaneously press ⌥ option+ ⇧ shift+ ˘, and then у to get ў; <br>— simultaneously press ⌥ option+ ⇧ shift+ ¨, and then ж to get ӝ.</p><p>Even some letters are implemented only with the help of the “dead key” ⌥ option + ⇧ shift + к:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzbJynBaZAgb3-Lc4vjdXg.png" /></figure><pre> <br># the list of cyrillic letters <br># hidden by &quot;dead key&quot; ⌥ + ⇧ + к<br>Ђ   Ѕ   Ј   Љ   Њ   Ћ   Џ</pre><p>But let’s go back to the beginning, here’s our layout:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-uK80m6TQSw_RsCO.png" /></figure><p>Here everything is quite familiar to us; for those who have used Windows, the layout is as familiar as possible. As for the specifics, I’ll note:</p><p>— To input the letter ґ, use the combination ⌥ + г.<br>— To input the symbol ₴, use the combination ⌥ + р.</p><p>In the latest update, however, I’ve changed the concept regarding the characters hidden behind ⇧ shift:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cRS9hIPJ2Z0YjQWs.png" /></figure><p>This change is related to the fact that I’ve been using a MacBook exclusively with an English keyboard layout for many years, so I don’t have other symbols readily available on my keyboard ¯\_(ツ)_/¯. Yes, I type in Ukrainian “blindly,” and based on this, I tried to build a layout that would use a maximally compatible appearance with the native English layout:</p><p>— The top row of symbols above the numbers is fully compatible with the English version: ! @ # $ % ^ &amp; * ( ) _ +<br>— Symbols hidden behind option ⌥ option: &lt; &gt; ? : [ ] /<br>— Symbols hidden behind the combination of keys option ⌥ option+ ⇧ shift: «» … ; { } ÷</p><h3>How to install?</h3><p>Go to <a href="https://github.com/AntonShevchuk/ukrainian-typography-keyboard-layout/releases">the project’s page</a> on GitHub and download the ukrainian-typography.dmg file from the latest release. Then double-click the file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/0*TMaHw42x5ivlaYnL.png" /></figure><p>Now, launch the Keyboard Installer (MacOS will warn you that this file was downloaded from the internet), and then drag the ukrainian-typography.bundle file into the installer window:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Lkd6pHOKEHHzPLT-.gif" /></figure><p>Next, choose to install for the current user. That’s it! Now you just need to go to the keyboard settings:</p><p>System Settings &gt; Keyboard &gt; Text Input: Input Sources &gt; Edit, and select 🇺🇦 Ukrainian - Typography</p><p>Enjoy :)</p><h3>Options?</h3><p>Currently, you have the option to choose from several other layouts:</p><ul><li>My <a href="https://github.com/AntonShevchuk/ukrainian-typography-keyboard-layout/releases/tag/1.5.0">previous version 1.5.0</a>, more familiar to users</li><li><a href="https://github.com/denysdovhan/ukrainian-typographic-keyboard">Ukrainian Typographic Keyboard</a> by Denys Dovhan</li><li><a href="https://alexkolodko.com/projects/ua-ru-typography-layout/">Ukrainian-Russian Typographic Layout</a> by Oleksandr Kolodko</li><li><a href="https://github.com/neochief/ukrainian-typographic-layouts">Compatible Ukrainian Typographic Layouts for Windows/Mac/Ubuntu</a> by Oleksandr Shvets</li><li>Version by <a href="https://gagadget.com/another/4076-ukrainskaya-tipografskaya-raskladka-klaviaturyi/">GaGadget</a></li></ul><p>Or even choose your own path and create your own layout using the <a href="https://software.sil.org/ukelele/">Ukelele</a> utility.</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/my-life/ukraine-typography-layout/"><em>https://anton.shevchuk.name</em></a><em> on June 11, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=546509ec9f11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Chat Bot. The project structure and clasp CLI tool]]></title>
            <link>https://medium.com/@AntonShevchuk/google-chat-bot-the-project-structure-and-clasp-cli-tool-fceb468feca0?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/fceb468feca0</guid>
            <category><![CDATA[chat-bot-development]]></category>
            <category><![CDATA[apps-script]]></category>
            <category><![CDATA[google-workspace]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Mon, 03 Jun 2024 08:10:13 GMT</pubDate>
            <atom:updated>2024-06-04T13:02:31.924Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*ldMfWCcwfu9mX4yY.png" /></figure><p>Lately, I’ve been increasingly involved in developing bots for Google Chat, so I’ve already developed some practices for project setup that I want to share with you.</p><p>Let’s start from the beginning, with the code editor. But you know what? Editing code in the browser annoys me a bit, so let’s set up a healthy local development environment on your workstation. For this, we’ll need <em>git</em>, your favorite <em>IDE</em>, and <em>eslint</em> to ensure everything is in order. This all sounds quite familiar, so this is how we’ll develop code locally, check the code style with eslint, and use git for version control with all its capabilities.</p><p>Take a look at the package.json of my project:</p><pre>{<br>  &quot;name&quot;: &quot;bender-2.0&quot;,<br>  &quot;version&quot;: &quot;7.0.0&quot;,<br>  &quot;description&quot;: &quot;The Bender bot for Google Workspace&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;<br>  },<br>  &quot;repository&quot;: {<br>    &quot;type&quot;: &quot;git&quot;,<br>    &quot;url&quot;: &quot;git+https://github.com/AntonShevchuk/bender-2.0.git&quot;<br>  },<br>  &quot;keywords&quot;: [<br>    &quot;Google Workspace&quot;,<br>    &quot;Google Chat API&quot;,<br>    &quot;Apps Script&quot;<br>  ],<br>  &quot;author&quot;: &quot;Anton Shevchuk&quot;,<br>  &quot;license&quot;: &quot;MIT&quot;,<br>  &quot;bugs&quot;: {<br>    &quot;url&quot;: &quot;https://github.com/AntonShevchuk/bender-2.0/issues&quot;<br>  },<br>  &quot;homepage&quot;: &quot;https://github.com/AntonShevchuk/bender-2.0#readme&quot;,<br>  &quot;devDependencies&quot;: {<br>    &quot;@eslint/js&quot;: &quot;^9.2.0&quot;,<br>    &quot;eslint&quot;: &quot;^9.2.0&quot;,<br>    &quot;eslint-plugin-googleappsscript&quot;: &quot;^1.0.5&quot;,<br>    &quot;eslint-plugin-jsdoc&quot;: &quot;^48.2.3&quot;,<br>    &quot;globals&quot;: &quot;^15.1.0&quot;<br>  }<br>}</pre><p>Nothing extra, just run npm install and work with the code…<br>- But our code is on <a href="https://script.google.com/home/start">Apps Script</a>, we don’t need to manually copy it all the time, do we?<br>- No, we don’t. For this, there’s a command-line utility called <a href="https://developers.google.com/apps-script/guides/clasp">clasp</a>, which will help us push the code back and forth.</p><h3>The Apps Script CLI</h3><blockquote>Next, you’ll find a brief overview of the <a href="https://developers.google.com/apps-script/guides/clasp">official documentation</a>. You can follow the manual right away or even complete <a href="https://codelabs.developers.google.com/codelabs/clasp/#0">the corresponding lab</a>. So, the choice is yours :)</blockquote><p>Let’s start with the fact that we’ll need to <a href="https://nodejs.org/en/download/package-manager">install Node.js</a> first, and then install <em>clasp</em> globally:</p><pre>npm i @google/clasp -g</pre><p>If everything is set up correctly, the next command should display a list of available commands:</p><pre>clasp -h</pre><blockquote>I personally can’t seem to get used to the name of this tool either; I keep typing “claps” instead. ¯\_(ツ)_/¯</blockquote><p>Now we need to authorize. Execute the command login:</p><pre>clasp login</pre><p>Next, you’ll need to authorize using your Gmail account and grant access to it. You’ll also need to enable the Google Apps Script API on <a href="https://script.google.com/home/usersettings">the settings page</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*sH_MPijiwWXnlGFX.png" /></figure><p>After that, you’ll be able to view a list of your projects:</p><pre>clasp list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*feVlI-cE5q5Fs_Hr.png" /></figure><p>Now, to fetch the code to your local environment, use the command clasp clone followed by your project ID:</p><pre>clasp clone &lt;scriptID&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*cD6PuueoD1QAAI4o.gif" /></figure><p>Alright, now you have your code locally, but some changes have been made to it:</p><pre># було<br>actions/actionEditCard.gs<br>actions/actionEditNotes.gs<br>commands/slashBender.gs<br>commands/slashWhisky.gs<br><br># стало<br>actions/<br>  |-- actionEditCard.js<br>  `-- actionEditNotes.js<br>commands/<br>  |-- slashBender.js<br>  `-- slashWhisky.js</pre><p>Yes, we have directories now, and honestly, it’s much more convenient with them!</p><p>Now you can make changes to the code, commit them to git, and then push them to script.google.com all in one command:</p><pre>clasp push</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*zCRbr8UAqN2CiB8Z.gif" /></figure><p>And now read very carefully and remember:</p><ul><li>when you use the clasp pull command, all local files will be replaced with files from script.google.com</li><li>when you use the clasp push command, all local files will be sent to script.google.com, overwriting all changes there</li></ul><p>So, the conclusion is that to avoid regrets later, you should edit either locally or directly on the <a href="https://script.google.com/">script.google.com</a> site, but don’t make changes simultaneously here and there, or you might end up losing something.</p><blockquote>And one more thing, only JS files and the appsscript.json file will be uploaded to the script.google.com site, all other files remain your responsibility, so don’t forget to commit them to git.</blockquote><h3>Integrating ESLint</h3><p>To check your code, you need to add a package.json file to the project directory as I provided at the very beginning and then run the npm install command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/0*NFRW8QiJQn9ewAay.png" /></figure><p>Now add the ESLint configuration file itself:</p><pre>import globals from &#39;globals&#39;;<br>import pluginJs from &#39;@eslint/js&#39;;<br>import jsdoc from &#39;eslint-plugin-jsdoc&#39;;<br>import appsScript from &#39;eslint-plugin-googleappsscript&#39;;<br><br>export default [<br>  pluginJs.configs.recommended,<br>  {<br>    files: [&#39;**/*.js&#39;],<br>    plugins: {<br>      jsdoc,<br>      googleappsscript: appsScript,<br>    },<br>    languageOptions: {<br>      globals: {<br>        ...globals.browser,<br>      },<br>    },<br>    rules: {<br>      &#39;comma-dangle&#39;: [&#39;error&#39;, &#39;never&#39;],<br>      &#39;max-len&#39;: [&#39;error&#39;, { code: 120, &#39;ignoreTrailingComments&#39;: true  }],<br>      &#39;camelcase&#39;: [<br>        &#39;error&#39;,<br>        {<br>          ignoreDestructuring: true,<br>          ignoreImports: true,<br>          allow: [&#39;access_type&#39;, &#39;redirect_uris&#39;],<br>        },<br>      ],<br>      &#39;guard-for-in&#39;: &#39;off&#39;,<br>      &#39;no-var&#39;: &#39;off&#39;,<br>      &#39;no-unused-vars&#39;: &#39;off&#39;, // Functions aren&#39;t used.<br>      &#39;no-undef&#39;: &#39;off&#39;, // Ignore undefined errors for global variables<br>    },<br>  }<br>];</pre><p>Now you can run the code style check for your code:</p><pre>npx eslint</pre><p>I hope you won’t see any errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/0*qUREoTu2D53Yg_Hh.png" /></figure><p>On the other hand, this configuration has quite lightweight checks, so if you have the inclination, feel free to send a pull request to <a href="https://github.com/AntonShevchuk/bender-2.0/">my repository</a> ;)</p><h3>Project Structure</h3><p>As I mentioned earlier, I’m working on several projects, so I’m trying to develop a convenient structure for functionality development. Currently, I have the following project structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bWAm58A60QfkqZP2.png" /></figure><p>This structure allows for quickly finding the necessary part of the code. Next, I will provide examples alphabetically with explanations.</p><p>All actions are placed in the corresponding actions directory. This is what happens when you click on buttons on the card, where it is specified as onClick =&gt; action:</p><pre>actions/<br>  |-- actionEditCard.js<br>  |-- ...<br>  `-- actionEditNotes.js</pre><p>We format all cards we send to the chat into separate functions, and all these functions go into a separate directory.</p><pre>cards/<br>  |-- cardHome.js<br>  `-- cardPoll.js</pre><blockquote>Actually, our Bender 2.0 bot has 5 separate cards, but I didn’t separate some of them into individual functions, although perhaps I should have done that.</blockquote><p>Each slash command has its own function, in a separate file within the directory with all the other slash commands:</p><pre>commands/<br>  |-- slashBender.js<br>  |-- ...<br>  `-- slashWhisky.js</pre><p>All sorts of auxiliary classes and functions should also be organized properly, as it’s important to maintain order here too:</p><pre>components/<br>  |-- FormInputHandler.js<br>  |-- ...<br>  `-- Response.js</pre><p>Dialogues for interacting with users should be organized in a way that each dialogue is contained within its own file:</p><pre>dialogs/<br>  |-- dialogCard.js<br>  `-- dialogPoll.js</pre><p>Events, such as onCardClick() and onMessage(), will reside here, containing important functions.</p><pre>events/<br>  |-- onCardClick.js<br>  |-- ...<br>  `-- onMessage.js</pre><p>Helpfer functions:</p><pre>helpers/<br>  `-- htmlEntities.js</pre><p>Widget creation functions.</p><pre>widgets/<br>  |-- widgetDecoratedText.js<br>  |-- ...<br>  `-- widgetTextParagraph.js</pre><p>Of course, after using the clasp push command, all this structure on script.google.com will be transformed into a “flat” folder/file.gs, but that’s not so important anymore, because you’ll hardly be using the browser-based editor much.</p><h3>Source Code</h3><p>The bot’s code is available on <a href="https://github.com/AntonShevchuk/bender-2.0/">GitHub</a>, release 7.0.0 corresponds to the code from this article.</p><p>P.S. The bot’s functionality has intentionally been simplified compared to release 6.0.0, in preparation for publication on the Google Workspace Market.</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/google/google-chat-bot-structure-and-clasp-cli-tool/"><em>https://anton.shevchuk.name</em></a><em> on June 3, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fceb468feca0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Chat Bot. Integrate Jira. Part Two]]></title>
            <link>https://medium.com/@AntonShevchuk/google-chat-bot-integrate-jira-part-two-5141d7aeca4b?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/5141d7aeca4b</guid>
            <category><![CDATA[chat-bot-development]]></category>
            <category><![CDATA[google-workspace]]></category>
            <category><![CDATA[apps-script]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Thu, 02 May 2024 08:00:57 GMT</pubDate>
            <atom:updated>2025-03-24T09:02:50.767Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*uyy5xqOjxH3u3fNS.png" /></figure><p>In <a href="https://medium.com/@AntonShevchuk/google-chat-bot-integrate-jira-part-i-ab0c63b98850">the previous part</a>, we already added integration with Jira to the bot. In this part, we will make changes to that functionality and work on reverse integration — from Jira to Google Apps Script.</p><p>According to my plan, in the case of updating an issue (editing or changing status), we will send the updated data to the thread and update the card. But let’s start from afar, from a distant land: we need to ensure that messages to the chat are sent not on behalf of the user, but from the bot itself, because otherwise, we won’t be able to update the card without user involvement.</p><p>For this, we’ll need to create a service account.</p><h3>Preparing the Service Account</h3><p>To create a service account, you should go to your project’s settings page and then click “Create Service Account”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*6-QYNaYWPn-E_r48.png" /></figure><p>Next, navigate to the settings of this account and create a new JSON key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*2F-KE2ZJ_NRA8-Y7.png" /></figure><p>After this, you will receive the corresponding JSON file, which will look like this:</p><pre>{<br>  &quot;type&quot;: &quot;service_account&quot;,<br>  &quot;project_id&quot;: &quot;bender-20&quot;,<br>  &quot;private_key_id&quot;: &quot;-----&quot;,<br>  &quot;private_key&quot;: &quot;-----BEGIN PRIVATE KEY-----\nAAAAAA\n-----END PRIVATE KEY-----\n&quot;,<br>  &quot;client_email&quot;: &quot;-----@-----.iam.gserviceaccount.com&quot;,<br>  &quot;client_id&quot;: &quot;-----&quot;,<br>  &quot;auth_uri&quot;: &quot;https://accounts.google.com/o/oauth2/auth&quot;,<br>  &quot;token_uri&quot;: &quot;https://oauth2.googleapis.com/token&quot;,<br>  &quot;auth_provider_x509_cert_url&quot;: &quot;https://www.googleapis.com/oauth2/v1/certs&quot;,<br>  &quot;client_x509_cert_url&quot;: &quot;https://www.googleapis.com/robot/v1/metadata/x509/-----%40-----.iam.gserviceaccount.com&quot;,<br>  &quot;universe_domain&quot;: &quot;googleapis.com&quot;<br>}</pre><p>You will need to transfer several fields from the JSON file to the Properties of your bot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IyR7cxkd8tiihVlFyXBTWg.png" /></figure><p>All set, the service account is created and the keys are added. Let’s move on.</p><blockquote>By the way, you can use the created account if you need to grant permission for any resource within Google Docs. Just a heads up for the future.</blockquote><h3>OAuth</h3><p>The next step is to create an <a href="https://console.cloud.google.com/apis/credentials/consent">OAuth Consent Screen</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D-_lTFF4rjYW7vBUrEw6Fw.png" /></figure><blockquote>If you are developing for Google Workspace, you will have the option to choose the <strong>Internal</strong> option, thus limiting the use of your application and making it “restricted to your domain only.”</blockquote><p>Add all the necessary information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G1GusKYlw3XDcGu1VKYViw.png" /></figure><p>At the step of adding scopes, I only added the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nLjVtEE3ZiTK6zNAinLofg.png" /></figure><p>After this, we have a bit more “challenges” ahead. To send a message to the chat, you need to use the following notation to call the Chat.Spaces.Messages.create() method:</p><pre>Chat.Spaces.Messages.create(<br>  {&#39;text&#39;: &#39;Hello world!&#39;},<br>  event.space.name,<br>  {},<br>  {&#39;Authorization&#39;: `Bearer ${serviceToken}`}<br>);</pre><p>However, to obtain that serviceToken, we need to connect the OAuth library to our chat using the identifier:</p><p>1B7FSrk5Zi6L1rSxxTDgDEUsPzlukDsi4KGuTMorsTQHhGBzBkMun4iDF</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*odbPl21eIQigrUUGizU1vQ.png" /></figure><p>Let’s create the function getServiceAccessToken():</p><pre>/**<br> * Get Access Token by service credentials<br> *<br> * Examples of usage:<br> * <br> *  getServiceAccessToken(&#39;messages&#39;, [&#39;https://www.googleapis.com/auth/chat.messages.create&#39;]);<br> *  getServiceAccessToken(&#39;spaces&#39;, [&#39;https://www.googleapis.com/auth/chat.spaces.readonly&#39;]);<br> */<br>function getServiceAccessToken(serviceName = &#39;messages&#39;, scopes = []) {<br>  const scriptProperties = PropertiesService.getScriptProperties()<br><br>  const service = OAuth2.createService(serviceName)<br>    .setTokenUrl(&#39;https://oauth2.googleapis.com/token&#39;)<br>    .setPrivateKey(scriptProperties.getProperty(&#39;PRIVATE_KEY&#39;).replace(/\\n/g, &#39;\n&#39;)) // lifehack ^_^<br>    .setIssuer(scriptProperties.getProperty(&#39;CLIENT_EMAIL&#39;))<br>    .setPropertyStore(scriptProperties)<br>    .setScope(scopes.join(&#39; &#39;));<br><br>  if (!service.hasAccess()) {<br>    Logger.log(&#39;Authentication error: %s&#39;, service.getLastError());<br>    return null;<br>  }<br><br>  return service.getAccessToken();<br>}</pre><p>All right, let’s put it all together:</p><pre>const serviceToken = getServiceAccessToken(&#39;messages&#39;, [&#39;https://www.googleapis.com/auth/chat.messages.create&#39;]);<br><br>Chat.Spaces.Messages.create(<br>  {&#39;text&#39;: &#39;Hello world!&#39;},<br>  event.space.name,<br>  {},<br>  {&#39;Authorization&#39;: `Bearer ${serviceToken}`}<br>);</pre><p>The result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*X2-rw9u2u-H9v9aX.png" /></figure><p>Let’s go back to editing actionNewIssue.gs and replace the creation of the message using the service token:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionNewIssue(event) {<br>  //<br>  // ... the code was cropped<br>  // <br><br>  try {<br>    const card = cardIssue(event, issue)<br>    const serviceToken = getServiceAccessToken(&#39;messages&#39;, [&#39;https://www.googleapis.com/auth/chat.messages&#39;]);<br>    const message = Chat.Spaces.Messages.create(<br>      card, <br>      event.space.name,<br>      {},<br>      {&#39;Authorization&#39;: `Bearer ${serviceToken}`}<br>    );<br><br>    // Extracting the thread name from the response<br>    // Assuming ID is spaces/AAAAAAAA/threads/BBBBBBBB<br>    const [ , spaceId, , threadAndMessageId] = message.thread.name.split(&#39;/&#39;);<br><br>    const threadUrl = `https://chat.google.com/room/${spaceId}/${threadAndMessageId}/${threadAndMessageId}`;<br><br>    Logger.log(`New thread ${threadUrl}`)<br><br>    let updateData = {<br>      &quot;fields&quot;: {}<br>    }<br><br>    updateData.fields[jiraApi.customField] = threadUrl<br><br>    jiraApi.updateIssue(response.key, updateData)<br>  } catch (err) {<br>    Logger.log(&#39;Failed to create message with error %s&#39;, err.message);<br>  }<br><br>  return OK()<br>}</pre><p>In this code, I use jiraApi.customField, but we don’t have it yet. We need to create this custom field in the Jira project as a URL type. After creating it, add a new Property in your bot called JIRA_CUSTOM_FIELD and set its value to the ID of your custom field (in my example, customfield_14033).</p><p>We have completed the work on creating the issue.</p><h3>Web Application</h3><p>Next, we need to add the ability to call our bot from the outside, for which we need to create a new “Deployment”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7z2aWgGav-EsKJO9.png" /></figure><p>After this, you will receive a Web app URL. You can even try to open the link, but you will encounter an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/0*dFbXas6G6wCIapPR.png" /></figure><p>Yes, we have new methods for handling external requests: doGet() and doPost().</p><pre><br>/**<br> * GET request to Web app URL<br> */<br>function doGet(event) {<br>  Logger.log(`WebHook doGet()`)<br><br>  return HtmlService.createHtmlOutput(&quot;GET request processed&quot;);<br>}</pre><pre><br>/**<br> * POST request to Web app URL<br> */<br>function doPost(event) {<br>  Logger.log(`WebHook doPost()`)<br><br>  return HtmlService.createHtmlOutput(&quot;POST request processed&quot;);<br>}</pre><p>Try hitting that Web URL now. You’ll receive a response from your bot. But what we’re interested in is the URL itself. Copy it; we’ll need it.</p><h3>Automation in Jira</h3><p>It’s time to return to Jira and set up automation. To do this, you’ll need admin rights to the project. Go to Automation and create rules that will be executed when working on issues in Jira. I’ve added 3 simple rules:<br>- When someone assigns an issue<br>- When the status changes<br>- When the Summary or Description is edited</p><p>For this, the URL to the Web Application will come in handy, but we’ll modify it slightly according to the purpose of each rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E09eq9G23WtLWHFmEK6-hQ.png" /></figure><p>Yes, we’ve added the “action” parameter to the URL, and now we can build logic based on it.</p><pre>/**<br> * POST request to Web app URL<br> */<br>function doPost(event) {<br>  const action = event.parameter.action ? event.parameter.action : null<br><br>  Logger.log(`WebHook doPost(&quot;${action}&quot;)`)<br><br>  if (!event.postData || !event.postData.contents) {<br>    Logger.log(`POST data is empty`)<br>  }<br><br>  const data = JSON.parse(event.postData.contents);<br><br>  if (!data) {<br>    Logger.log(`POST data is invalid`)<br>  }<br><br>  try {<br>    // You can now call your bot method based on event type<br>    switch (action) {<br>      case &#39;assigned&#39;:<br>        // ...<br>        break;<br>      case &#39;updated&#39;:<br>        // ...<br>        break;<br>      case &#39;transitioned&#39;:<br>        // ...<br>        break;<br>      default:<br>        Logger.log(&quot;Invalid action&quot;)<br>        break;<br>    }<br>  } catch (e) {<br>    return HtmlService.createHtmlOutput(`POST request processed with error: ${e}`);<br>  }<br><br>  return HtmlService.createHtmlOutput(&quot;POST request processed&quot;);<br>}</pre><blockquote>Yes, I also specified the “Webhook body” value as “Issue Data”!</blockquote><h3>Sending a reply in the thread</h3><p>Now the interesting part begins — we need to send a message as a reply to the initial message, the link to which we saved in the “Custom Field”. Of course, let’s start by retrieving that link and getting the identifier of the required thread (I’ll add this code to doPost.gs):</p><pre>const scriptProperties = PropertiesService.getScriptProperties();<br><br>// JIRA threadUrl<br>const threadUrl = data.fields[scriptProperties.getProperty(&#39;JIRA_CUSTOM_FIELD&#39;)]<br><br>const parts = threadUrl.split(&#39;/&#39;); // Split the URL into parts by &#39;/&#39;<br>const spaceId = parts[4]; // The space ID is expected to be the fifth part<br>const threadId = parts[5]; // The thread ID is expected to be the sixth part</pre><p>Let’s create a separate function that will send a message to the thread:</p><pre>/**<br> * @param {String} spaceId the ID of the space<br> * @param {String} threadId the ID of the thread<br> * @param {Object} issue the issue data from JIRA<br> */<br>function hookAssigned(spaceId, threadId, issue) {<br><br>  Logger.log(`Send update message to space &quot;${spaceId}&quot; to thread &quot;${threadId}&quot;`)<br><br>  const space = `spaces/${spaceId}`<br>  const thread = `spaces/${spaceId}/threads/${threadId}`<br><br>  let message = {<br>    &quot;text&quot;: &quot;Assigned&quot;,<br>    &quot;thread&quot;: {<br>      &quot;name&quot;: thread // !!!<br>    }<br>  }<br><br>  const serviceToken = getServiceAccessToken(&#39;messages&#39;, [&#39;https://www.googleapis.com/auth/chat.messages&#39;]);<br><br>  return Chat.Spaces.Messages.create(<br>    message,<br>    space,<br>    { &quot;messageReplyOption&quot;: &quot;REPLY_MESSAGE_OR_FAIL&quot; }, // !!!<br>    { &quot;Authorization&quot;: `Bearer ${serviceToken}` }<br>  );<br>}</pre><p>Please pay attention to line 16, as it specifies which thread to send the response to, and also to line 25, because without this parameter, we won’t be able to access the thread. Let’s add a call to this function in doPost.gs and try to assign the task to ourselves:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*T0B7wvcK9gkdsd4BGb23mQ.png" /></figure><blockquote>In the bot’s code, there will be a more interesting example of a response in the thread, but you can take a look at it yourself.</blockquote><h3>Updating the card</h3><p>Now we need to update the card that we sent to the space. It doesn’t require much — just take the data from Jira, regenerate the updated card, and send it back to the chat:</p><pre>/**<br> * @param {String} spaceId the ID of the space<br> * @param {String} threadId the ID of the thread<br> * @param {Object} issue the issue data from JIRA<br> */<br>function hookUpdated(spaceId, threadId, issue) {<br><br>  Logger.log(`Update the card relative to issue &quot;${issue.key}&quot;`)<br><br>  const serviceToken = getServiceAccessToken(&#39;messages&#39;, [&#39;https://www.googleapis.com/auth/chat.messages&#39;]);<br><br>  const name = `spaces/${spaceId}/messages/${threadId}.${threadId}`<br>  // get the message from the chat<br>  let message = Chat.Spaces.Messages.get(name, {}, { &quot;Authorization&quot;: `Bearer ${serviceToken}` })<br>  // generate a new card<br>  message = Object.assign({}, message, cardIssue(false, issue))<br>  // post a new card to the message<br>  return Chat.Spaces.Messages.update(message, name, { &quot;updateMask&quot;: &quot;cardsV2&quot; }, { &quot;Authorization&quot;: `Bearer ${serviceToken}` })<br>}</pre><p>A brief explanation: in line 14, we retrieve the entire card from the space. In line 16, we generate the updated card based on the new data from Jira. In line 18, we update the card, making sure to specify the necessary updateMask = cardsV2.</p><p>Similarly, you’ll need to do the same for editing and changing the status of the issue. Here’s how my doPost.gs turned out in the end:</p><pre>/**<br> * POST request to Web app URL<br> */<br>function doPost(event) {<br>  const action = event.parameter.action ? event.parameter.action : null<br><br>  Logger.log(`WebHook doPost(&quot;${action}&quot;)`)<br><br>  if (!event.postData || !event.postData.contents) {<br>    Logger.log(`POST data is empty`)<br>  }<br><br>  const data = JSON.parse(event.postData.contents);<br><br>  if (!data) {<br>    Logger.log(`POST data is invalid`)<br>  }<br><br>  const scriptProperties = PropertiesService.getScriptProperties();<br><br>  // JIRA threadUrl<br>  const threadUrl = data.fields[scriptProperties.getProperty(&#39;JIRA_CUSTOM_FIELD&#39;)]<br><br>  if (!threadUrl || threadUrl.length === 0) {<br>    Logger.log(`Invalid thread URL for issue &quot;${data.key}&quot;`)<br>    return HtmlService.createHtmlOutput(`POST request processed: Invalid thread URL`);<br>  }<br><br>  try {<br>    const parts = threadUrl.split(&#39;/&#39;); // Split the URL into parts by &#39;/&#39;<br>    const spaceId = parts[4]; // The space ID is expected to be the fifth part<br>    const threadId = parts[5]; // The thread ID is expected to be the sixth part<br><br>    // You can now call your bot method based on event type<br>    switch (action) {<br>      case &#39;assigned&#39;:<br>        hookUpdated(spaceId, threadId, data)<br>        hookAssigned(spaceId, threadId, data)<br>        break;<br>      case &#39;updated&#39;:<br>        hookUpdated(spaceId, threadId, data)<br>        break;<br>      case &#39;transitioned&#39;:<br>        hookUpdated(spaceId, threadId, data)<br>        hookTransitioned(spaceId, threadId, data)<br>        break;<br>      default:<br>        Logger.log(&quot;Invalid action&quot;)<br>        break;<br>    }<br>  } catch (e) {<br>    return HtmlService.createHtmlOutput(`POST request processed with error: ${e}`);<br>  }<br><br>  return HtmlService.createHtmlOutput(&quot;POST request processed&quot;);<br>}</pre><h3>Sequence Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*4YPCmW8k2ZuXBFRQC0HMTA.png" /></figure><h3>Homework Assignment</h3><p>Figure out how to create a webhook to add comments from Jira to the thread in Google Chat.</p><p>Here’s a hint: for automation, it’s best to use “custom data” with “<a href="https://support.atlassian.com/cloud-automation/docs/smart-values-in-jira-automation/">smart values</a>”.</p><pre>{<br>  &quot;key&quot;: &quot;{{issue.key}}&quot;,<br>  &quot;fields&quot;: {<br>    &quot;summary&quot;: &quot;{{issue.fields.summary.jsonEncode}}&quot;,<br>    &quot;description&quot;: &quot;{{issue.fields.description.jsonEncode}}&quot;,<br>    &quot;customfield_14033&quot;: &quot;{{issue.fields.customfield_14033}}&quot;<br>  },<br>  &quot;comment&quot;: {<br>    &quot;body&quot;: &quot;{{issue.comments.last.body.jsonEncode}}&quot;,<br>    &quot;author&quot;: { &quot;displayName&quot;: &quot;{{issue.comments.last.author.displayName}}&quot;,<br>    &quot;name&quot;: &quot;{{issue.comments.last.author.name}}&quot;<br>  }<br>}</pre><h3>Source Code</h3><p>The bot code is available on <a href="https://github.com/AntonShevchuk/bender-2.0/releases/tag/6.0.0">GitHub</a>, version 5.1.0 corresponds to the code from this article.</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/google/google-chat-bot-jira-integration-part-two/"><em>https://anton.shevchuk.name</em></a><em> on May 2, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5141d7aeca4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Chat Bot. Integrate Jira. Part One]]></title>
            <link>https://medium.com/@AntonShevchuk/google-chat-bot-integrate-jira-part-i-ab0c63b98850?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab0c63b98850</guid>
            <category><![CDATA[google-workspace]]></category>
            <category><![CDATA[apps-script]]></category>
            <category><![CDATA[chat-bot-development]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Tue, 30 Apr 2024 08:01:31 GMT</pubDate>
            <atom:updated>2024-05-09T08:17:47.861Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*DuR9n_cTTiEtxlMh.png" /></figure><p>The articles for beginners have concluded, and now it’s time to develop “advanced” functionality. In this article, we will be adding Jira integration to our bot.</p><p>First, I’ll explain my idea: I want to add the capability to create tasks and report bugs to a selected project in Jira to our bot. All updates from Jira should come back to our chat because users need to see what is happening with the issue in Jira.</p><p>How it will work:<br>– The user of our bot triggers the slash-command /task<br>– Fills out a form for a task in Jira<br>– Data from the form is sent to Jira, where we create the corresponding issue<br>– We send a card to the chat with a link to the Jira issue<br>– Upon receiving the link in the chat thread, we add it to the Jira issue</p><h3>Dialogue</h3><p>Everything starts again with adding a slash-command to our bot. I remind you that for this, we need to go to the <a href="https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat">Google Chat API</a> settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*Zu4CUOncEa7N-q_T.png" /><figcaption>Create new slash command</figcaption></figure><p>We have already created dialogs, so don’t forget to check the box ✅ Opens a dialog.<br>The changes to onMessage() are also not complicated, we just need to catch the new command with ID 12:</p><pre>/**<br> * Responds to a MESSAGE event in Google Chat.<br> *<br> * @param {Object} event the event object from Google Chat<br> */<br>function onMessage(event) {<br>  if (event.message.slashCommand) {<br>    // Checks for the presence of event.message.slashCommand<br>    // The ID for your slash command<br>    switch (event.message.slashCommand.commandId) {<br>      case 1:<br>        return slashHelp(event)<br>      case 10:<br>        return slashBender(event)<br>      case 11:<br>        return slashWhisky(event)<br>      case 12:<br>        return slashTask(event)<br>      case 20:<br>        return slashCard(event)<br>      case 21:<br>        return slashNotes(event)<br>      case 22:<br>        return slashPoll(event)<br>    }<br>  } else {<br>    // If the Chat app doesn&#39;t detect a slash command<br>    // ...<br>  }<br>}</pre><p>Let’s create the function slashTask() in the appropriate file:</p><pre>/**<br> * Opens a dialog in Google Chat.<br> *<br> * @param {Object} event the event object from Chat API.<br> *<br> * @return {object} open a Dialog in Google Chat.<br> */<br>function slashTask(event) {<br>  // nothing for now<br>  return dialogIssue(event)<br>}</pre><p>Here we simply call dialogIssue(), so let’s move on to the corresponding dialogIssue.gs. I will immediately provide the code with error handling, because in the previous part we already detailed how it’s done, and I’d rather not repeat myself:</p><pre>/**<br> * Create a dialog for Google Chat.<br> *<br> * @param {Object} event the event object from Chat API.<br> * @param {Object} request the data from the form or from parameters.<br> * @param {String} type the type of issue<br> * @return {object} open a Dialog in Google Chat.<br> */<br>function dialogIssue(event, request = null, type = &quot;Task&quot;) {<br>  let card = {<br>    &quot;action_response&quot;: {<br>      &quot;type&quot;: RESPONSE_TYPE_DIALOG,<br>      &quot;dialog_action&quot;: {<br>        &quot;dialog&quot;: {<br>          &quot;body&quot;: {<br>            &quot;sections&quot;: [<br>              {<br>                &quot;widgets&quot;: []<br>              }<br>            ],<br>            &quot;name&quot;: `New ${type}`,<br>            &quot;fixedFooter&quot;: {<br>              &quot;primaryButton&quot;: {<br>                &quot;text&quot;: &quot;Create&quot;,<br>                &quot;onClick&quot;: {<br>                  &quot;action&quot;: {<br>                    &quot;function&quot;: &quot;actionNewIssue&quot;,<br>                    &quot;parameters&quot;: [<br>                      {<br>                        &quot;key&quot;: &quot;type&quot;,<br>                        &quot;value&quot;: type<br>                      }<br>                    ]<br>                  }<br>                }<br>              }<br>            }<br>          }<br>        }<br>      }<br>    }<br>  }<br><br>  if (request &amp;&amp; !request.summary) {<br>    card.action_response.dialog_action.dialog.body.sections[0].widgets.push({<br>        &quot;textParagraph&quot;: {<br>          &quot;text&quot;: &quot;&lt;font color=&#39;#c1121f&#39;&gt;The summary is required&lt;/font&gt;&quot;<br>        }<br>      }<br>    )<br>  }<br><br>  card.action_response.dialog_action.dialog.body.sections[0].widgets.push(<br>    {<br>      &quot;textInput&quot;: {<br>        &quot;label&quot;: &quot;Summary*&quot;,<br>        &quot;type&quot;: &quot;SINGLE_LINE&quot;,<br>        &quot;name&quot;: &quot;summary&quot;,<br>        &quot;hintText&quot;: &quot;&quot;,<br>        &quot;value&quot;: request ? request.summary : &quot;&quot;<br>      }<br>    }<br>  )<br><br>  if (request &amp;&amp; !request.description) {<br>    card.action_response.dialog_action.dialog.body.sections[0].widgets.push({<br>        &quot;textParagraph&quot;: {<br>          &quot;text&quot;: &quot;&lt;font color=&#39;#c1121f&#39;&gt;The description is required&lt;/font&gt;&quot;<br>        }<br>      }<br>    )<br>  }<br><br>  card.action_response.dialog_action.dialog.body.sections[0].widgets.push(<br>    {<br>      &quot;textInput&quot;: {<br>        &quot;label&quot;: &quot;Description*&quot;,<br>        &quot;type&quot;: &quot;MULTIPLE_LINE&quot;,<br>        &quot;name&quot;: &quot;description&quot;,<br>        &quot;hintText&quot;: &quot;&quot;,<br>        &quot;value&quot;: request ? request.description : &quot;&quot;<br>      }<br>    }<br>  )<br><br>  card.action_response.dialog_action.dialog.body.sections[0].widgets.push({<br>      &quot;textParagraph&quot;: {<br>        &quot;text&quot;: &quot;&lt;font color=&#39;#c1121f&#39;&gt;*&lt;/font&gt; - all fields are required.&quot;<br>      }<br>    }<br>  )<br><br>  return card<br>}</pre><blockquote>Here, I added an additional argument, type, because we will not only be creating tasks but also reporting bugs.</blockquote><p>After this, you can use the /task command, and you will get the following dialog:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*RSau6Putp_YY_Sik.png" /><figcaption>Dialog for create an issue</figcaption></figure><p>Sending will not work yet; we need to add support for the new action, actionNewIssue, to onCardClick():</p><pre>/**<br> * Responds to a CARD_CLICKED event in Google Chat.<br> *<br> * @param {Object} event the event object from Google Chat<br> */<br>function onCardClick(event) {<br>  switch (event.common.invokedFunction) {<br>    // <br>    // ... the code was cropped<br>    // <br>    // - /task<br>    case &#39;actionNewIssue&#39;:<br>      return actionNewIssue(event)<br>  }<br>}</pre><p>We will examine the functionality of actionNewIssue.gs in parts.</p><p>Part one — data validation:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionNewIssue(event) {<br><br>  const parameters = event.common.parameters<br>  const formHandler = new FormInputHandler(event)<br><br>  const summary = formHandler.getTextValue(&#39;summary&#39;)<br>  const description = formHandler.getTextValue(&#39;description&#39;)<br>  const type = parameters.type<br><br>  // validation<br>  if (!summary.length || !description.length) {<br>    return dialogIssue(event, { summary, description })<br>  }<br><br>  //<br>  // ... the code was cropped<br>  // <br>}</pre><p>Here, we simply check that the fields are not empty, and in case of an error, we return the card from dialogIssue() with the error messages displayed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*rqkfvSOzKhQAmwlx.png" /><figcaption>The validation errors</figcaption></figure><blockquote>You can add more complex checks to the code as you see fit.</blockquote><p>Next, we need to work with Jira, but it’s not ready yet :)</p><h3>Preparing the Jira Project</h3><p>First, we need a JIRA project, and it’s best to have a separate user for our bot, who will need to be granted administrative rights in the project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*CcK9xQ4IraDqAv7T.png" /><figcaption>Account for Google Chat Bot</figcaption></figure><p>Additionally, you need to create a Personal Access Token for your user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/0*I5SZAke8IZgSu7XP.png" /><figcaption>Create Access Token for Google Chat Bot</figcaption></figure><p>The Access Token you receive should be stored in your bot’s Properties. You should also add the link to Jira and the key of your project there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lBjxb4PT3aspd4yF.png" /><figcaption>Properties</figcaption></figure><p>And now, a key point: to store the link to the corresponding message in Google Chat in your issue, you need to add a Custom Field of type URL to the necessary Screens in your project. If you don’t understand what this means, ask your Jira administrator to do this. The Screen of my project in Jira looks as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OILELkicyslIO8Ml.png" /></figure><p>I also add the identifier of the newly created Custom Field to the Properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Keee32N0tJCn4JO.png" /><figcaption>Property for JiraCustom Field</figcaption></figure><h3>Creating an Issue</h3><p>Now that Jira is ready, let’s add a class for interacting with it and create the issue:</p><pre>/**<br> * Class for working with JIRA API v2<br> *<br> * @link https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/<br> */<br>class JiraAPI {<br>  constructor() {<br>    const scriptProperties = PropertiesService.getScriptProperties();<br>    this.baseUrl = scriptProperties.getProperty(&#39;JIRA_URL&#39;);<br>    this.token = scriptProperties.getProperty(&#39;JIRA_TOKEN&#39;);<br>    this.project = scriptProperties.getProperty(&#39;JIRA_PROJECT&#39;);<br>    this.customField = scriptProperties.getProperty(&#39;JIRA_CUSTOM_FIELD&#39;);<br>    this.options = {<br>      headers: {<br>        &quot;Authorization&quot;: &quot;Bearer &quot; + this.token,<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>      },<br>      muteHttpExceptions: true // Set to false to throw exceptions for HTTP errors<br>    }<br>  }<br><br>  /**<br>   * Makes a HTTP request to the JIRA API with error handling.<br>   *<br>   * @param {String} endpoint - The API endpoint.<br>   * @param {Object} options - The options for the fetch call, including method, headers, and payload.<br>   * @return {Object} The JSON response from the JIRA API.<br>   */<br>  fetch(endpoint, options) {<br>    const url = `${this.baseUrl}${endpoint}`;<br><br>    Logger.log(url)<br>    Logger.log(options)<br><br>    try {<br>      const response = UrlFetchApp.fetch(url, Object.assign({}, options, this.options));<br>      const responseCode = response.getResponseCode()<br>      const contentText = response.getContentText()<br>      const contentType = response.getHeaders()[&#39;Content-Type&#39;]<br><br>      Logger.log(`Response code: ${responseCode}`)<br>      Logger.log(`Content type: ${contentType}`)<br><br>      if (responseCode &gt;= 200 &amp;&amp; responseCode &lt; 300) {<br>        // it strange, FIXME<br>        if (contentText.length &amp;&amp; contentType.search(&#39;application/json&#39;) !== -1) {<br>          return JSON.parse(contentText)<br>        } else {<br>          return response.getResponseCode()<br>        }<br>      } else {<br>        console.error(`JIRA API request to ${endpoint} failed with code: ${responseCode}, response: ${contentText}`);<br>        throw new Error(`Request failed with code: ${responseCode}`);<br>      }<br>    } catch (e) {<br>      console.error(`Error making request to JIRA API: ${e}`);<br>      throw e; // Rethrow the error after logging<br>    }<br>  }<br><br>  /**<br>   * Retrieves details of an issue from JIRA.<br>   *<br>   * @param {String} issueIdOrKey - The ID or key of the issue<br>   */<br>  getIssue(issueIdOrKey) {<br>    return this.fetch(`/rest/api/2/issue/${issueIdOrKey}`, {<br>      &quot;method&quot;: &quot;get&quot;<br>    });<br>  }<br><br>  /**<br>   * Creates a new issue in JIRA.<br>   *<br>   * @param {Object} issueData<br>   */<br>  createIssue(issueData) {<br>    return this.fetch(&quot;/rest/api/2/issue&quot;, {<br>      &quot;method&quot;: &quot;post&quot;,<br>      &quot;payload&quot;: JSON.stringify(issueData)<br>    });<br>  }<br><br>  /**<br>   * Updates an issue in JIRA.<br>   *<br>   * @param {String} issueIdOrKey - The ID or key of the issue<br>   * @param {Object} issueData<br>   */<br>  updateIssue(issueIdOrKey, issueData) {<br>    return this.fetch(`/rest/api/2/issue/${issueIdOrKey}`, {<br>      &quot;method&quot;: &quot;put&quot;,<br>      &quot;payload&quot;: JSON.stringify(issueData)<br>    });<br>  }<br>}</pre><p>This class isn’t very complex, but it has everything we need:</p><ul><li>getIssue() - retrieve an issue by its key or identifier</li><li>createIssue() - create a new issue</li><li>updateIssue() - update an existing issue by its key or identifier</li></ul><p>⚠️ Note that after adding this code, your bot will request users’ permission to send requests to external resources:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*PRY7DT9vuIkanWpy.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*ZwZIGJ2J_BXymUF1.png" /></figure><p>Let’s continue working on actionNewIssue.gs. We’ll add the second part to our puzzle — the creation of the issue:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionNewIssue(event) {<br>  //<br>  // ... the code was cropped<br>  // <br><br>  Logger.log(`New Issue: ${summary}`)<br><br>  const jiraApi = new JiraAPI()<br><br>  let issueData = {<br>    &quot;fields&quot;: {<br>      &quot;project&quot;: { &quot;key&quot;: jiraApi.project },<br>      &quot;summary&quot;: summary,<br>      &quot;description&quot;: googleChatToJira(description),<br>      &quot;issuetype&quot;: { &quot;name&quot;: type },<br>      &quot;reporter&quot;: { &quot;name&quot;: event.user.email },<br>      &quot;assignee&quot;: null,<br>    }<br>  };<br><br>  const response = jiraApi.createIssue(issueData);<br><br>  Logger.log(`The Issue Key is &quot;${response.key}&quot;`)<br><br>  const issue = jiraApi.getIssue(response.key)<br><br>  //<br>  // ... the code was cropped<br>  // <br>}</pre><p>When we create an issue using createIssue(), Jira does not return the entire issue in the response. Therefore, to get all the information we need, we make an additional request using getIssue() to the Jira API.</p><h3>Prepare a card</h3><p>Our next step is to form a card and send it to the chat. The function cardIssue() will be responsible for creating the card:</p><pre>/**<br> * Create a card for Google Chat.<br> *<br> * @param {Object} event the event object from Google Chat<br> * @param {Object} issue the JIRA issue<br> *<br> * @return {Object} the card object<br> */<br>function cardIssue(event, issue) {<br><br>  const scriptProperties = PropertiesService.getScriptProperties();<br>  const jiraUrl = scriptProperties.getProperty(&#39;JIRA_URL&#39;)<br>  const jiraIssueUrl = `${jiraUrl}/browse/${issue.key}`<br><br>  Logger.log(`The URL to Issue is ${jiraIssueUrl}`)<br><br>  let card = {<br>    &quot;cardsV2&quot;: [<br>      {<br>        &quot;cardId&quot;: &quot;presale-request&quot;,<br>        &quot;card&quot;: {<br>          &quot;sections&quot;: [<br>            {<br>              &quot;widgets&quot;: [<br>                {<br>                  &quot;decoratedText&quot;: {<br>                    &quot;icon&quot;: {<br>                      // &quot;iconUrl&quot;: issue.fields.issuetype.iconUrl<br>                      &quot;materialIcon&quot;: {<br>                        &quot;name&quot;: issue.fields.issuetype.name === &quot;Task&quot; ? &quot;task&quot; : &quot;bug_report&quot;<br>                      }<br>                    },<br>                    &quot;text&quot;: issue.fields.summary,<br>                  }<br>                },<br>                {<br>                  &quot;textParagraph&quot;: {<br>                    &quot;text&quot;: jiraToGoogleChat(issue.fields.description)<br>                  }<br>                }<br>              ]<br>            },<br>            {<br>              &quot;widgets&quot;: [<br>                {<br>                  &quot;buttonList&quot;: {<br>                    &quot;buttons&quot;: [<br>                      {<br>                        &quot;text&quot;: &quot;JIRA&quot;,<br>                        &quot;color&quot;: {<br>                          &quot;red&quot;: 0.75,<br>                          &quot;green&quot;: 0.85,<br>                          &quot;blue&quot;: 0.95,<br>                          &quot;alpha&quot;: 1<br>                        },<br>                        &quot;icon&quot;: {<br>                          &quot;materialIcon&quot;: {<br>                            &quot;name&quot;: &quot;task&quot;<br>                          }<br>                        },<br>                        &quot;onClick&quot;: {<br>                          &quot;openLink&quot;: {<br>                            &quot;url&quot;: jiraIssueUrl<br>                          }<br>                        }<br>                      }<br>                    ]<br>                  }<br>                }<br>              ]<br>            },<br>            {<br>              &quot;widgets&quot;: [<br>                {<br>                  &quot;columns&quot;: {<br>                    &quot;columnItems&quot;: [<br>                      {<br>                        &quot;widgets&quot;: [<br>                          {<br>                            &quot;decoratedText&quot;: {<br>                              &quot;icon&quot;: {<br>                                &quot;iconUrl&quot;: issue.fields.status.iconUrl<br>                              },<br>                              &quot;topLabel&quot;: &quot;Status&quot;,<br>                              &quot;text&quot;: issue.fields.status.name,<br>                              &quot;bottomLabel&quot;: &quot;&quot;,<br>                            }<br>                          }<br><br>                        ]<br>                      },<br>                      {<br>                        &quot;widgets&quot;: [<br>                          {<br>                            &quot;decoratedText&quot;: {<br>                              &quot;icon&quot;: {<br>                                &quot;knownIcon&quot;: &quot;PERSON&quot;<br>                                // &quot;iconUrl&quot;: issue.fields.assignee.avatarUrls[&quot;48x48&quot;]<br>                              },<br>                              &quot;topLabel&quot;: &quot;Assigned&quot;,<br>                              &quot;text&quot;: issue.fields.assignee ? issue.fields.assignee.displayName : &#39;Unassigned&#39;,<br>                              &quot;bottomLabel&quot;: issue.fields.assignee ? issue.fields.assignee.emailAddress : &#39;&#39;,<br>                            }<br>                          }<br>                        ]<br>                      }<br>                    ]<br>                  }<br>                }<br>              ]<br>            }<br>          ]<br>        }<br>      }<br>    ]<br>  }<br><br>  // we have the event if a user works with chat<br>  if (event) {<br>    card.cardsV2[0].card[&quot;header&quot;] = {<br>      &quot;title&quot;: event.user.displayName,<br>      &quot;subtitle&quot;: event.user.email,<br>      &quot;imageUrl&quot;: event.user.avatarUrl,<br>      &quot;imageType&quot;: &quot;CIRCLE&quot;<br>    }<br><br>    card.cardsV2[0].card[&quot;sections&quot;].push(<br>      {<br>        &quot;widgets&quot;: [<br>          {<br>            &quot;decoratedText&quot;: {<br>              &quot;icon&quot;: {<br>                &quot;knownIcon&quot;: &quot;CLOCK&quot;<br>              },<br>              &quot;text&quot;: new Date().toLocaleString(),<br>            }<br>          }<br>        ]<br>      }<br>    )<br>  }<br><br>  return card<br>}</pre><p>Next, things get a bit more complex. We need to send the prepared card to the chat using the API because this allows us to obtain the message identifier and save it to the issue in Jira (yes, to that custom field). However, this isn’t straightforward to do.</p><h3>Chat API</h3><p>Our next step will be to add the Chats API service to the project. So, return to our code editor and click the “+” next to Services:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/0*cnJTsvx5WlfJZgS5.png" /><figcaption>Add Google Chat Api Service to Apps Script Project</figcaption></figure><p>Select and add the Google Chat API (the API documentation is available at <a href="https://developers.google.com/apps-script/advanced/chat">https://developers.google.com/apps-script/advanced/chat</a>).</p><p>Now we have the ability to send messages to the chat:</p><pre>Chat.Spaces.Messages.create( {&#39;text&#39;: &#39;Hello world!&#39;}, event.space.name );</pre><p>Though, no, you will encounter an error:</p><pre>GoogleJsonResponseException: API call to chat.spaces.messages.create failed with error: Request had insufficient authentication scopes.</pre><p>You will also need to add the corresponding scope to appsscript.json:</p><pre>{ &quot;oauthScopes&quot;: [&quot;https://www.googleapis.com/auth/chat.messages.create&quot;], }</pre><p>Now everything should work. Of course, the bot will ask the user for the necessary permissions to write messages in the chat, but once granted, the result will be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/0*0bFtpPp10N8N79G9.png" /><figcaption>Message from the bot</figcaption></figure><p>In the code, you will receive a response from the API:</p><pre>{<br>  name: &quot;spaces/AAAABBBB/messages/QWERTY.QWERTY&quot;,<br>  argumentText: &quot;Hello world!&quot;,<br>  text: &quot;Hello world!&quot;,<br>  sender: {<br>    type: &quot;HUMAN&quot;,<br>    name: &quot;users/111111234567890000000&quot;<br>  },<br>  createTime: &quot;2024-04-27T21:58:02.427887Z&quot;,<br>  space: {<br>    name: &quot;spaces/AAAABBBB&quot;<br>  },<br>  formattedText: &quot;Hello world!&quot;, <br>    thread: {<br>    name: &quot;spaces/AAAABBBB/threads/QWERTY&quot; <br>  }<br>}</pre><p>So now you can include the link to the thread in Jira. Let’s return to editing actionNewIssue.gs:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionNewIssue(event) {<br>  //<br>  // ... the code was cropped<br>  // <br><br>  try {<br>    const card = cardIssue(event, issue)<br><br>    const message = Chat.Spaces.Messages.create(card, event.space.name);<br><br>    // Extracting the thread name from the response<br>    // Assuming ID is spaces/AAAAAAAA/threads/BBBBBBBB<br>    const [ , spaceId, , threadAndMessageId] = message.thread.name.split(&#39;/&#39;);<br><br>    const threadUrl = `https://chat.google.com/room/${spaceId}/${threadAndMessageId}/${threadAndMessageId}`;<br><br>    Logger.log(`New thread ${threadUrl}`)<br><br>    let updateData = {<br>      &quot;fields&quot;: {}<br>    }<br><br>    updateData.fields[jiraApi.customField] = threadUrl<br><br>    jiraApi.updateIssue(response.key, updateData)<br>  } catch (err) {<br>    Logger.log(&#39;Failed to create message with error %s&#39;, err.message);<br>  }<br><br>  return OK()<br>}</pre><p>Let’s try creating a task using the /task command and see the following card in the chat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*IWG0SkjZrfUapPzL.png" /><figcaption>Google Chat Card for Issue</figcaption></figure><p>A corresponding issue will be created in Jira:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RJNjBzwnpuoq2fqE.png" /><figcaption>Jira Issue</figcaption></figure><p>And that’s already a pretty good result. I like what we’ve accomplished.</p><h3>Sequence diagram</h3><p>Here’s the sequence diagram; it seems to have turned out quite straightforward:</p><figure><img alt="Google Chat Bot. Integrate Jira. Sequence diagram" src="https://cdn-images-1.medium.com/max/533/0*pje1wus45-5qj6sG.png" /><figcaption>Integration Google Chat Bot with Jira. Sequence diagram</figcaption></figure><p>So, I consider this first part complete, but it’s not all the functionality I wanted to implement. However, perhaps it will suffice for you.</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/google/google-chat-bot-jira-integration-part-one/"><em>https://anton.shevchuk.name</em></a><em> on April 30, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab0c63b98850" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Chat Bot. Interaction and Card Updates]]></title>
            <link>https://medium.com/@AntonShevchuk/google-chat-bot-interaction-and-card-updates-e2d5dc995f78?source=rss-c868a9e7bfdd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2d5dc995f78</guid>
            <category><![CDATA[chat-bot-development]]></category>
            <category><![CDATA[google-workspace]]></category>
            <category><![CDATA[apps-script]]></category>
            <dc:creator><![CDATA[Anton Shevchuk]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 06:40:30 GMT</pubDate>
            <atom:updated>2024-04-16T10:36:55.589Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*BzPWhpcBBioh7UwMBqexlg.png" /></figure><p>It’s time to continue developing the bot for Google Chat. This time, we will teach it to create polls, a functionality that is sorely missing in continuous communication in the workspace. To implement this, we will need to figure out how to interact with and update cards in the chat.</p><h3>Dialogue</h3><p>Let’s start again by adding a slash-command to our bot, I remind you that for this we need to go to the <a href="https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat">Google Chat API</a> settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*ByVfsMUA9mbVGXHm.png" /></figure><p>We have already created dialogs, so don’t forget to check the box ✅ Opens a dialog.</p><p>The changes to Code.gs are also not complicated, we just need to catch the new command with ID 22:</p><pre>/**<br> * Responds to a MESSAGE event in Google Chat.<br> *<br> * @param {Object} event the event object from Google Chat<br> */<br>function onMessage(event) {<br>  if (event.message.slashCommand) {<br>    // Checks for the presence of event.message.slashCommand<br>    // The ID for your slash command<br>    switch (event.message.slashCommand.commandId) {<br>      case 1:<br>        return slashHelp(event)<br>      case 10:<br>        return slashBender(event)<br>      case 11:<br>        return slashWhisky(event)<br>      case 20:<br>        return slashCard(event)<br>      case 21:<br>        return slashNotes(event)<br>      case 22:<br>        return slashPoll(event)<br>    }<br>  } else {<br>    // If the Chat app doesn&#39;t detect a slash command<br>    // ...<br>  }<br>}</pre><p>Let’s create the function slashPoll() in the appropriate file:</p><pre>/**<br> * Opens a dialog in Google Chat.<br> *<br> * @param {Object} event the event object from Chat API.<br> *<br> * @return {object} open a Dialog in Google Chat.<br> */<br>function slashPoll(event) {<br>  // nothing for now<br>  return dialogPoll(event)<br>}</pre><p>Here we will only have a call to dialogPoll(), this is done for future functionality expansion. For now, in dialogPoll.gs there will only be the creation of a dialog:</p><pre>/**<br> * Opens a dialog in Google Chat.<br> *<br> * @param {Object} event the event object from Chat API.<br> *<br> * @return {object} open a Dialog in Google Chat.<br> */<br>function dialogPoll(event) {<br>  return {<br>    &quot;action_response&quot;: {<br>      &quot;type&quot;: &quot;DIALOG&quot;,<br>      &quot;dialog_action&quot;: {<br>        &quot;dialog&quot;: {<br>          &quot;body&quot;: {<br>            &quot;sections&quot;: [<br>              {<br>                &quot;header&quot;: &quot;Create New Poll&quot;,<br>                &quot;collapsible&quot;: true,<br>                &quot;uncollapsibleWidgetsCount&quot;: 4,<br>                &quot;widgets&quot;: [<br>                  {<br>                    &quot;textParagraph&quot;: {<br>                      &quot;text&quot;: &quot;Enter the poll topic and up to 10 choices in the poll. Blank options will be omitted.&quot;<br>                    }<br>                  },<br>                  {<br>                    &quot;textInput&quot;: {<br>                      &quot;name&quot;: &quot;question&quot;,<br>                      &quot;label&quot;: &quot;Ask a question*&quot;,<br>                    }<br>                  },<br>                  {<br>                    &quot;textInput&quot;: {<br>                      &quot;name&quot;: &quot;option1&quot;,<br>                      &quot;label&quot;: &quot;1️⃣ Option*&quot;,<br>                    }<br>                  },<br>                  {<br>                    &quot;textInput&quot;: {<br>                      &quot;name&quot;: &quot;option2&quot;,<br>                      &quot;label&quot;: &quot;2️⃣ Option*&quot;,<br>                    }<br>                  },<br>                  /* Options 3, 4, 5 .. 9 */<br>                  {<br>                    &quot;textInput&quot;: {<br>                      &quot;name&quot;: &quot;option10&quot;,<br>                      &quot;label&quot;: &quot; Option&quot;,<br>                    }<br>                  }<br>                ]<br>              },<br>              {<br>                &quot;header&quot;: &quot;Options&quot;,<br>                &quot;collapsible&quot;: false,<br>                &quot;widgets&quot;: [<br>                  {<br>                    &quot;decoratedText&quot;: {<br>                      &quot;text&quot;: &quot;Multiple Answers&quot;,<br>                      &quot;bottomLabel&quot;: &quot;If this checked the voters can choose more than option&quot;,<br>                      &quot;switchControl&quot;: {<br>                        &quot;name&quot;: &quot;multi&quot;,<br>                        &quot;selected&quot;: true,<br>                        &quot;controlType&quot;: &quot;SWITCH&quot;<br>                      }<br>                    }<br>                  }<br>                ]<br>              }<br>            ],<br>            &quot;fixedFooter&quot;: {<br>              &quot;primaryButton&quot;: {<br>                &quot;icon&quot;: {<br>                  &quot;materialIcon&quot;: {<br>                    &quot;name&quot;: &quot;send&quot;<br>                  }<br>                },<br>                &quot;text&quot;: &quot;Send&quot;,<br>                &quot;onClick&quot;: {<br>                  &quot;action&quot;: {<br>                    &quot;function&quot;: &quot;actionNewPoll&quot;<br>                  }<br>                }<br>              }<br>            }<br>          }<br>        }<br>      }<br>    }<br>  }<br>}</pre><blockquote>I remind you that it is convenient to use the <a href="https://addons.gsuite.google.com/uikit/builder">Card Builder</a> service for creating dialogs and cards.</blockquote><p>After that, you can use the /poll command, and you will even be able to get the following dialog:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/0*M5pkJqbzx0UW3KmB.png" /></figure><p>Now you should add the handling of the onclick-function from the previous code listing, for this make changes to onCardClick(event):</p><pre>/**<br> * Responds to a CARD_CLICKED event in Google Chat.<br> *<br> * @param {Object} event the event object from Google Chat<br> */<br>function onCardClick(event) {<br>  switch (event.common.invokedFunction) {<br> <br>    //<br>    // ... the code was cropped<br>    //<br><br>    // - /poll<br>    case &#39;actionNewPoll&#39;:<br>      return actionNewPoll(event)<br>  }<br>}</pre><p>Again, let’s create a new function actionNewPoll() in the new file actionNewPoll.gs:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionNewPoll(event) {<br><br>  const formHandler = new FormInputHandler(event)<br><br>  formHandler.getTextValue(&#39;question&#39;)<br>  formHandler.getBooleanValue(&#39;multi&#39;)<br>  formHandler.getTextValue(&#39;option1&#39;)<br>  // ...<br>  formHandler.getTextValue(&#39;option10&#39;)<br><br>  //<br>  // ... the code was cropped<br>  //<br><br>}</pre><blockquote>Here we need to pause for a moment and remind that the FormInputHandler class was created earlier, and it is responsible for retrieving data from the form. Now we have just added a new method getBooleanValue(), and I believe there will be no misunderstandings with it.</blockquote><p>But I don’t just want to retrieve data, I want to perform validation to allow for modifications to the form in case there are errors.<br>For this purpose, I will add several checks, and in case of failure, I will return the previous form with the error message:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionNewPoll(event) {<br><br>  const formHandler = new FormInputHandler(event)<br><br>  let data = {<br>    question: formHandler.getTextValue(&#39;question&#39;),<br>    multi: formHandler.getBooleanValue(&#39;multi&#39;),<br>    options: []<br>  }<br><br>  for (let i = 1; i &lt;= 10; i++) {<br>    let option = formHandler.getTextValue(`option${i}`)<br>    if (option.length) {<br>      data.options.push(option)<br>    }<br>  }<br><br>  if (!data.question.length) {<br>    return dialogPoll(event, data)<br>  }<br><br>  if (data.options.length &lt; 2) {<br>    return dialogPoll(event, data)<br>  }<br><br>  //<br>  // ... the code was cropped<br>  //<br><br>}</pre><p>In this code, I form a data object to make it easier to work with the data from the form, and I perform only two checks — that there is a question and that there are at least two answer options. When an error occurs, I return the dialog again, which we added to the function dialogPoll(). We just need to make changes so that the previously entered data is retained on the form and the error text is displayed:</p><pre>/**<br> * Opens a dialog in Google Chat.<br> *<br> * @param {Object} event the event object from Chat API.<br> * @param {Object} data the data from a form.<br> *<br> * @return {object} open a Dialog in Google Chat.<br> */<br>function dialogPoll(event, data = null) {<br><br>  let card = {<br>    &#39;action_response&#39;: {<br>      &#39;type&#39;: &#39;DIALOG&#39;,<br>      &#39;dialog_action&#39;: {<br>        &#39;dialog&#39;: {<br>          &#39;body&#39;: {<br>            &#39;sections&#39;: [<br>              {<br>                &#39;header&#39;: &#39;Create New Poll&#39;,<br>                &#39;collapsible&#39;: true,<br>                &#39;uncollapsibleWidgetsCount&#39;: 4,<br>                &#39;widgets&#39;: [<br>                  {<br>                    &quot;textParagraph&quot;: {<br>                      &quot;text&quot;: &quot;Enter the poll topic and up to 10 choices in the poll. Blank options will be omitted.&quot;<br>                    }<br>                  },<br>                  {<br>                    &#39;textInput&#39;: {<br>                      &#39;name&#39;: &#39;question&#39;,<br>                      &#39;label&#39;: &#39;Ask a question*&#39;,<br>                      &#39;value&#39;: data &amp;&amp; data.question ? data.question : &#39;&#39;<br>                    }<br>                  },<br>                  {<br>                    &#39;textInput&#39;: {<br>                      &#39;name&#39;: &#39;option1&#39;,<br>                      &#39;label&#39;: &#39;1️⃣ Option*&#39;,<br>                      &#39;value&#39;: data &amp;&amp; data.options &amp;&amp; data.options[0] ? data.options[0] : &#39;&#39;<br>                    }<br>                  }<br>                  /* Options 2, 3, 4, 5 .. 10 */<br>                ]<br>              },<br>              {<br>                &quot;header&quot;: &quot;Options&quot;,<br>                &quot;collapsible&quot;: false,<br>                &quot;widgets&quot;: [<br>                  {<br>                    &quot;decoratedText&quot;: {<br>                      &quot;text&quot;: &quot;Multiple Answers&quot;,<br>                      &quot;bottomLabel&quot;: &quot;If this checked the voters can choose more than option&quot;,<br>                      &quot;switchControl&quot;: {<br>                        &quot;name&quot;: &quot;multi&quot;,<br>                        &quot;selected&quot;: (data &amp;&amp; data.multi) ? data.multi : true,<br>                        &quot;controlType&quot;: &quot;SWITCH&quot;<br>                      }<br>                    }<br>                  }<br>                ]<br>              }<br>            ],<br>            &#39;fixedFooter&#39;: { /* ... */ }<br>          }<br>        }<br>      }<br>    }<br>  }<br><br>  if (data) {<br>    let section = {<br>      &#39;widgets&#39;: [<br>        {<br>          &quot;textParagraph&quot;: {<br>            &quot;text&quot;: &quot;&lt;b&gt;&lt;font color=&#39;#ff0000&#39;&gt;Please fill in all required data, including the question and two or more options.&lt;/font&gt;&lt;/b&gt;&quot;<br>          }<br>        }<br>      ]<br>    }<br><br>    card.action_response.dialog_action.dialog.body.sections.unshift(section)<br>  }<br><br>  return card;<br>}</pre><p>In this way, we will return the poll editing form to the user, without losing their data (pay attention to lines 9, 32, 39, and 55). To enhance clarity, we add an error message so the user is not confused about what is currently happening (line 81).</p><h3>Voting Card</h3><p>All checks are done, it’s time to create the voting card and send it to the chat. I will first demonstrate the design of the card, and then provide the corresponding code for it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AcWeFXsZ1ihOm5k1.png" /></figure><p>Let’s go back to the previous step, and add a call to another function — cardPoll() — to the function actionNewPoll():</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionNewPoll(event) {<br>  const formHandler = new FormInputHandler(event)<br><br>  let data = {<br>    question: formHandler.getTextValue(&#39;question&#39;),<br>    multi: formHandler.getBooleanValue(&#39;multi&#39;),<br>    options: []<br>  }<br><br>  //<br>  // ... the code was cropped<br>  //<br><br>  return cardPoll(event, data)<br>}</pre><p>Of course, the implementation of cardPoll() will be in the corresponding file:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> * @param {Object} data the data from the request<br> * <br> * @return {Object} the card object<br> */<br>function cardPoll(event, data) {<br>  let card = {<br>    &#39;actionResponse&#39;: {<br>      &#39;type&#39;: &#39;NEW_MESSAGE&#39;,<br>    },<br>    &quot;cardsV2&quot;: [<br>      {<br>        &quot;cardId&quot;: &quot;poll&quot;,<br>        &quot;card&quot;: {<br>          &quot;header&quot;: {<br>            &quot;title&quot;: event.user.displayName,<br>            &quot;subtitle&quot;: event.user.email,<br>            &quot;imageUrl&quot;: event.user.avatarUrl,<br>            &quot;imageType&quot;: &quot;CIRCLE&quot;<br>          },<br>          &quot;sections&quot;: []<br>        }<br>      }<br>    ]<br>  }<br><br>  let sections = [];<br><br>  sections.push({<br>    &quot;widgets&quot;: [<br>      {<br>        &quot;decoratedText&quot;: {<br>          &quot;text&quot;: data.question,<br>          &quot;endIcon&quot;: {<br>            &quot;materialIcon&quot;: {<br>              &quot;name&quot;: data.multi ? &quot;checklist_rtl&quot; : &quot;rule&quot;<br>            }<br>          }<br>        }<br>      }<br>    ]<br>  })<br><br>  for (let i = 0; i &lt; data.options.length; i++) {<br>    sections.push({<br>      &quot;collapsible&quot;: true,<br>      &quot;uncollapsibleWidgetsCount&quot;: 1,<br>      &quot;widgets&quot;: [<br>        {<br>          &quot;decoratedText&quot;: {<br>            &quot;startIcon&quot;: {<br>              &quot;materialIcon&quot;: {<br>                &quot;name&quot;: &quot;arrow_right&quot;<br>              }<br>            },<br>            &quot;topLabel&quot;: data.options[i],<br>            &quot;text&quot;: &quot;⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️⬜️&quot;,<br>            &quot;bottomLabel&quot;: &quot;0%&quot;,<br>            &quot;button&quot;: {<br>              &quot;text&quot;: &quot;vote&quot;,<br>              &quot;icon&quot;: {<br>                &quot;materialIcon&quot;: {<br>                  &quot;name&quot;: &quot;add&quot;<br>                }<br>              },<br>              &quot;altText&quot;: &quot;Vote&quot;,<br>              &quot;onClick&quot;: {<br>                &quot;action&quot;: {<br>                  &quot;function&quot;: &quot;actionVotePoll&quot;,<br>                  &quot;parameters&quot;: [<br>                    {<br>                      &quot;key&quot;: &quot;option&quot;,<br>                      &quot;value&quot;: `${i+1}`<br>                    }<br>                  ]<br>                }<br>              }<br>            }<br>          }<br>        }<br>      ]<br>    })<br>  }<br><br>  card.cardsV2[0].card.sections = sections<br><br>  return card<br>}</pre><p>Here, the main addition is the call to the function actionVotePoll() in the action button, and I will explain more about it in the next section.</p><h3>Card Update</h3><p>To begin with, of course, we will return to onCardClick() again, and add support and call the function actionVotePoll():</p><pre>/**<br> * Responds to a CARD_CLICKED event in Google Chat.<br> *<br> * @param {Object} event the event object from Google Chat<br> */<br>function onCardClick(event) {<br>  switch (event.common.invokedFunction) {<br> <br>    //<br>    // ... the code was cropped<br>    //<br><br>    // - /poll<br>    case &#39;actionNewPoll&#39;:<br>      return actionNewPoll(event)<br>    case &#39;actionVotePoll&#39;:<br>      return actionVotePoll(event)<br>  }<br>}</pre><p>Next, we will create the function in the file actionVotePoll.gs:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionVotePoll(event) {<br><br>  let parameters = event.common.parameters<br><br>  let card = event.message.cardsV2[0]<br><br>  //<br>  // ... the code was cropped<br>  //<br><br><br>}</pre><p>Let’s go step-by-step — besides the function parameters (line 6), we are generally interested in the entire card that we have in the chat (line 8).</p><p>Now, the key moment — we can update the card in the chat after the user interacts with it:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionVotePoll(event) {<br><br>  let parameters = event.common.parameters<br><br>  let card = event.message.cardsV2[0]<br><br>  //<br>  // ... the code was cropped<br>  //<br><br>  return {<br>    &quot;actionResponse&quot;: {<br>      &quot;type&quot;: &quot;UPDATE_MESSAGE&quot;,<br>    },<br>    &quot;cardsV2&quot;: [ card ]<br>  }<br>}</pre><p>Using this capability, we can store user votes as part of the card:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IiZKVZGT6yZGqjvh.png" /></figure><blockquote><em>Cards are usually displayed below the text body of a Chat message, but can situationally appear other places, such as dialogs. Each card can have a </em><strong><em>maximum size of 32 KB</em></strong><em>.</em></blockquote><p>So, all that remains is to implement this logic:</p><pre>/**<br> * @param {Object} event the event object from Google Chat<br> */<br>function actionVotePoll(event) {<br><br>  let parameters = event.common.parameters<br><br>  let sections = event.message.cardsV2[0].card.sections<br><br>  let multi = sections[0].widgets[0].decoratedText.endIcon.materialIcon.name === &quot;checklist_rtl&quot;<br><br>  let option = parseInt(parameters.option)<br><br>  let user = event.user.displayName<br>  let avatar = event.user.avatarUrl<br><br>  let widget = {<br>    &quot;decoratedText&quot;: {<br>      &quot;startIcon&quot;: {<br>        &quot;iconUrl&quot;: avatar<br>      },<br>      &quot;text&quot;: user,<br>    }<br>  }<br><br>  let votes = []<br><br>  for (let i = 1; i &lt; sections.length; i++) {<br>    let widgets = sections[i].widgets<br>    let people = []<br><br>    if (widgets.length &gt; 1) {<br>      for (let j = 1; j &lt; widgets.length; j++) {<br>        people.push(<br>          widgets[j].decoratedText.text<br>        )<br>      }<br>    }<br><br>    votes[i] = people.filter(n =&gt; n)<br><br>    Logger.log(`Votes for &quot;${i}&quot;: ${votes[i].length}`, votes[i])<br>  }<br><br>  // update votes<br>  let index = votes[option].indexOf(user)<br>  if (index === -1) {<br>    Logger.log(`+1 vote for ${option}`)<br>    votes[option].push(user)<br>    sections[option].widgets.push(widget)<br>  } else {<br>    Logger.log(`-1 vote for ${option}, index is ${index}`)<br>    votes[option].splice(index, 1);<br>    sections[option].widgets.splice(index + 1, 1)<br>  }<br><br>  // for non-multi voting poll<br>  // remove user votes for another options<br>  if (!multi) {<br>    for (let i = 1; i &lt; sections.length; i++) {<br>      if (i === option) {<br>        continue<br>      }<br>      let index = votes[i].indexOf(user)<br>      if (index !== -1) {<br>        Logger.log(`-1 vote for ${i}, index is ${index}`)<br>        votes[i].splice(index, 1)<br>        sections[i].widgets.splice(index + 1, 1)<br>      }<br>    }<br>  }<br><br>  Logger.log(`Vote for &quot;${option}&quot;: ${votes[option].length}`, votes[option])<br><br>  // removed empty value from position 0<br>  votes.shift()<br><br>  let percentages = calculatePercentages(votes)<br><br>  Logger.log(`%:`, percentages)<br><br>  for (let i = 1; i &lt; sections.length; i++) {<br>    sections[i].widgets[0].decoratedText.text = fillProgressBar(percentages[i - 1])<br>    sections[i].widgets[0].decoratedText.bottomLabel = `${percentages[i - 1]}%`<br>  }<br><br>  return {<br>    &quot;actionResponse&quot;: {<br>      &quot;type&quot;: &quot;UPDATE_MESSAGE&quot;,<br>    },<br>    &quot;cardsV2&quot;: [<br>      {<br>        &quot;cardId&quot;: &quot;poll&quot;,<br>        &quot;card&quot;: {<br>          &quot;header&quot;: event.message.cardsV2[0].card.header,<br>          &quot;sections&quot;: sections<br>        }<br>      }<br>    ]<br>  }<br>}<br><br>/**<br> * @param {Array} data<br> */<br>function calculatePercentages(data) {<br>  // Flatten the array by concatenating all sub-arrays<br>  let flattenedArray = [].concat.apply([], data);<br><br>  // Calculate total number of items across all sub-arrays<br>  let totalItems = flattenedArray.length<br><br>  // Filter out duplicates by using a temporary object where properties represent the unique items found so far<br>  let uniqueItems = flattenedArray.filter(function(item, index, self) {<br>    return self.indexOf(item) === index;<br>  });<br><br>  let totalUniqueItems = uniqueItems.length;<br><br>  // Calculate the percentage of each subarray based on the total items<br>  return data.map(function (sublist) {<br>    return totalUniqueItems ? Math.round(sublist.length / totalUniqueItems * 100) : 0;<br>  });<br>}<br><br>/**<br> * @param {Number} percentage<br> */<br>function fillProgressBar(percentage) {<br>  let totalBoxes = 10; // Total number of boxes in the text<br>  let filledBoxes = Math.round(percentage / 10); // Calculate number of filled boxes (each box represents 10%)<br>  let progressBar = &quot;&quot;; // Initialize an empty string for the progress bar<br><br>  // Build the progress bar string<br>  for (let i = 0; i &lt; totalBoxes; i++) {<br>    if (i &lt; filledBoxes) {<br>      progressBar += &quot;🟦&quot;; // Add a filled box for each 10% completed<br>    } else {<br>      progressBar += &quot;⬜️&quot;; // Fill the rest with empty boxes<br>    }<br>  }<br><br>  return progressBar;<br>}</pre><p>In this code, widgets are used to store votes, so each option is a separate section, and each vote is a separate widget. When a user votes, we retrieve the entire card, and by breaking it down into parts, we can reconstruct the voting results and make changes.</p><h3>Sequence Diagram</h3><p>I wanted to present a sequence diagram, maybe it will help you better understand the functionality:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/0*EpzYoB27UDZEY2Oc.png" /></figure><h3>Source Code</h3><p>The bot code is available on <a href="https://github.com/AntonShevchuk/bender-2.0/releases/tag/5.1.0">GitHub</a>, version 5.1.0 corresponds to the code from this article.</p><h3>P.S.</h3><p>From the beginning, there was release <a href="https://github.com/AntonShevchuk/bender-2.0/releases/tag/5.0.0">5.0.0</a>, but then I looked at that code and decided to organize it better, that’s why it’s better to look at version <a href="https://github.com/AntonShevchuk/bender-2.0/releases/tag/5.1.0">5.1.0</a> :)</p><p><em>Originally published at </em><a href="https://anton.shevchuk.name/google/google-chat-bot-interactions-and-card-updates/"><em>https://anton.shevchuk.name</em></a><em> on April 16, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2d5dc995f78" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>