<?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 Claudio Tesoriero on Medium]]></title>
        <description><![CDATA[Stories by Claudio Tesoriero on Medium]]></description>
        <link>https://medium.com/@c.tesoriero?source=rss-22a2eb9c42a9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rlCo35LQiy9h7hQpSiCnRA.png</url>
            <title>Stories by Claudio Tesoriero on Medium</title>
            <link>https://medium.com/@c.tesoriero?source=rss-22a2eb9c42a9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:46:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@c.tesoriero/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[How I dynamically added buttons in Landbot.io]]></title>
            <link>https://blog.chatbotslife.com/how-i-dynamically-added-buttons-in-landbot-io-345bcf2fe7c2?source=rss-22a2eb9c42a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/345bcf2fe7c2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[landbot]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[chatbot-design]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Claudio Tesoriero]]></dc:creator>
            <pubDate>Fri, 17 May 2019 07:54:44 GMT</pubDate>
            <atom:updated>2020-05-23T18:19:48.529Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jN9uD_z3u9k6_lymdKdOXQ.png" /></figure><p>Again! It happened again. Our awesome marketing team was building a new terrific marketing experience, this time using a <a href="https://chatbotslife.com/">chatbot</a>, and needed a hand to solve an apparently easy task: to fetch data from an external provider and to dynamically add buttons as possible answers given to users.</p><p>They were using Landbot.io and I was a little surprised when I discovered that Landbot does not have a native way to accomplish this task.</p><figure><a href="https://www.eventbrite.com/e/chatbot-ai-conference-tickets-55380774387"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ac4Wm94IFfL37KAAXnEUXQ.png" /></a></figure><p>I googled around a little bit and I found a very informative <a href="https://landbot.helpdocs.io/article/vp9cf66kms-how-to-create-dynamic-buttons-from-a-json-api-response-or-array-ualee">article</a> on their documentation that explains this topic quite well. In the end, it is a very “hardcore” hack. But, there was a problem. I barely just wanted to knew how to add buttons, that’s it. That article goes even too far and beyond my purposes. I had to dig more than necessary to find out how the hack works, so I decided to write this post to share in a more concise way just how I dynamically added buttons to a “Question Box” block.</p><p>What do I mean with “dynamically”? I mean that buttons, and options/values associated with them, are unknown at the coding-time. In most scenarios, this means that values are retrieved or computed at execution-time.</p><p>The hack I used is derived from the article I mentioned before and needs the Pro account.</p><p>First of all, let’s create a new “Ask a question/Buttons” block and link it to the start message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*_UCWVFn6UZG8BAE68OSEnA.png" /></figure><p>Now the first part of the hack: open the new block and replace the caption text with:</p><blockquote>What is your choice?</blockquote><blockquote>{html}</blockquote><blockquote>&lt;button class=”customButton” id=”showButtons” onclick=’ createButtons(this,“buttonsCanvas”,[“one”,”two”,”three”])’ style=”width: 194px;”&gt;Click to show your options&lt;/button&gt;</blockquote><blockquote>&lt;span id=”buttonsCanvas”&gt;&lt;/span&gt;</blockquote><blockquote>{/html}</blockquote><p>(Please be careful with cut&amp;paste from Medium because it may change quotes and double-quotes characters)</p><p>Landbot will output the HTML code inside the {html} block. This code will show a button that will call the createButtons() function in order to display the available options.</p><p>createButtons() will accept three arguments: the first one is the button itself, the second one is the id of the DOM element that will contain the buttons, and the last one is an array of options (that in this very first step is still hardcoded).</p><p>Well, now we need a place to put the Javascript code. It is not possible to use the same code block of the button because that code is injected at runtime by Landbot into the DOM and any script code will be not parsed by the browser. This means that the code must be present when the page is loaded.</p><p>To do so, click on the “Design” link and then “Advanced” (available only to Pro accounts).</p><p>Here we can add custom CSS and scripts.</p><p>Add this script and click on the Apply button:</p><blockquote>&lt;script&gt;<br> function createButtons(caller,elId,values){<br> var div = document.getElementById(elId);<br> var buttonElementTemplate = document.createElement(“BUTTON”);<br> for (var i = 0; i &lt; values.length; i++){<br> var button = buttonElementTemplate.cloneNode(true);<br> button.innerText=values[i];<br> div.appendChild(button);<br> }<br> caller.style.visibility = “hidden”;<br> }<br>&lt;/script&gt;</blockquote><p>Let’s try it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*RfvzUvy9Cza3SNvua9Q_2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*uEHr89za9Qd9dsaVPfSnyw.png" /></figure><p>Wow, it works!</p><p>Now we need at least a couple (+1) of other things:</p><ul><li>To retrieve options from a remote source</li><li>To use/show the chosen option</li><li>To add a style to our buttons</li></ul><h3>Fetch data from an external API</h3><p>In order to fetch data from an external resource, Landbot.io gives us “PowerUps”. We need two of them: Webhook and Callback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZKS63hg_RnTOnHPRenJo_Q.png" /><figcaption>Add a Webhook and a Callback block</figcaption></figure><p>For this article, we also are going to use a REST/JSON API. The simplest way to build one is to use <a href="http://myjson.com/">http://myjson.com/</a>. (Edit: unfortunately, myjson.com was closed on April 2020)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*RMN1CbRt_b-Tha2PSLB5lQ.png" /></figure><p>Click “save” and you will have a convenient URL to use.</p><p>Mine is <a href="https://api.myjson.com/bins/1b2shi">https://api.myjson.com/bins/1b2shi</a> (try it).</p><p>Now, open the “Send Webhook” block and paste the URL above, also select “Custom method” and choose “GET”. Click Apply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*OIG3LAOpaT3bk08nm4YLtw.png" /><figcaption>The Webhook block</figcaption></figure><p>Now open the “Callback” block, and configure it like in the following picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*N2xRE-pbUAzjDItQ1SA75Q.png" /></figure><p>“ @dataset” will be the Landbot variable where the fetched data will be stored.</p><p>Open the first block we created, and change the code inside it in order to use the fetched data:</p><blockquote>What is your choice?</blockquote><blockquote>{html}<br>&lt;button class=”customButton” id=”showButtons” onclick=’ createButtons(this,”buttonsCanvas”,<a href="http://twitter.com/dataset">@dataset</a>)’ style=”width: 194px;”&gt;Click to show your options&lt;/button&gt;<br>&lt;span id=”buttonsCanvas”&gt;&lt;/span&gt;<br>{/html}</blockquote><p>Done! Let’s try it…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*ThEdOSjqvZFpD4D1KdUxLA.png" /></figure><p>Ok, now it’s time to use the clicked one.</p><h3>Use the chosen button value</h3><p>Open the Design →Advanced section once again and copy this code:</p><blockquote>&lt;script&gt;<br>function createButtons(caller,elId,values){<br> var div = document.getElementById(elId);<br> var buttonElementTemplate = document.createElement(“BUTTON”);<br> for (var i = 0; i &lt; values.length; i++){<br> var button = buttonElementTemplate.cloneNode(true);<br> button.setAttribute(“onclick”,’submitInput(‘${elId}’,’${values[i]}’);’);<br> button.innerText=values[i];<br> div.appendChild(button);<br> }<br> caller.style.visibility = “hidden”;<br>}<br> <br>function submitInput(elId,inputValue) {<br> // To hide buttons <br> var buttons = document.getElementById(elId).getElementsByTagName(“BUTTON”);<br> for (var i=0; i&lt;buttons.length; i++){<br> buttons[i].style.display = “none”;<br> } <br> <br> // To set the variable <a href="http://twitter.com/result">@result</a> in Landbot<br> Landbot.exec(‘landbot-custom-data’, { result: inputValue }) <br> // So the flow continues after is pressed a button, by sending a message as the user.<br> Landbot.exec(‘landbot-msg-send’, {<br> message:inputValue ,<br> text: ‘***’,<br> payload:’****’,<br> type: ‘button’,<br> }); <br>}</blockquote><blockquote>&lt;/script&gt;</blockquote><p>Now we have the variable @result that we can use inside our <a href="https://chatbotslife.com/">bot</a>.</p><p>For example, let’s add a new “Send a Message” block:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*BYNBR3bvGfodGnnjV2chJQ.png" /></figure><p>And paste this code inside it:</p><blockquote>Great!<br>you chose the option number <br>{html}<br><a href="http://twitter.com/result">@result</a><br>{/html}</blockquote><p>Done!</p><p>Now you can style your buttons or play around to do more experiments with Landobot.</p><h3>Don’t forget to give us your 👏 !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*VXLYMBivBHMxZkD_" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e59ef%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e59ef&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e59ef%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href">https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href</a></iframe><figure><a href="https://chatbotslife.com/bot-communities-mastermind-group-d2dae9876709#.53x0py6ou"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*6XUspT9JOSq0w0Fi35HIaA.png" /></a></figure><figure><a href="https://m.me/ChatbotsLife"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*c1LDMH5vbnIz9rmAka8Hwg.png" /></a></figure><figure><a href="https://chatbotslife.com/chatbot-development-hire-top-ai-chatbot-developers-c8b45ef7f207"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*D0Jf3dI6ZThtqcfwDYY7mg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=345bcf2fe7c2" width="1" height="1" alt=""><hr><p><a href="https://blog.chatbotslife.com/how-i-dynamically-added-buttons-in-landbot-io-345bcf2fe7c2">How I dynamically added buttons in Landbot.io</a> was originally published in <a href="https://blog.chatbotslife.com/">Chatbots Life</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I extract section titles and screen names from InvisionApp]]></title>
            <link>https://medium.com/@c.tesoriero/how-i-extract-section-titles-and-screen-names-from-invisionapp-e700210b2c4?source=rss-22a2eb9c42a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e700210b2c4</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[invision]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <dc:creator><![CDATA[Claudio Tesoriero]]></dc:creator>
            <pubDate>Mon, 04 Feb 2019 14:47:21 GMT</pubDate>
            <atom:updated>2019-02-04T14:47:21.438Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXPK8Y7i8ZrQezwU1OXxfQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/vHVfpi3h5xk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Daniel Korpai</a> on <a href="https://unsplash.com/search/photos/app?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In my company, designers use <strong>Sketch</strong> to design and prototype the user interface of apps, websites and other useful nowadays stuff. They then export all this cool work in <strong>InvisionApp</strong> so the final clients can see and explore the prototype in a very cool fashion way, and of course, give feedbacks.</p><p>Once the feedback cycle is completed I need to extract all the screens and their sections names both for documentation purpose and for the calculation of the estimate for software development, because every screen has its own complexity.</p><p>But, there is a problem: how can I export the sections and screens names? InvisonApp and Sketch do not have such export feature (AFAIK).</p><p>Since I am in love with the KISS (Keep It Simple Stupid) approach, I use the following simple method.</p><ul><li>Open the link of the <strong>InvisionApp</strong> project. The same you gave to the client. Something like: h<a href="https://projects.invisionapp.com/share/YUOTFLZHKM7#/screens/328123087">ttps://projects.invisionapp.com/share/YYYYYYYYY#/screens</a></li><li>Now click on the “grid” icon at the right-bottom of the screen, next to the comment one. You should see all the screen in a grid mode.</li></ul><p>Open the “Developer tools” (<strong>DevTools</strong>) from within your browser.</p><p>In Chrome, press <strong>Command+Option+C</strong> (Mac) or <strong>Control+Shift+C</strong> (Windows, Linux).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*v39Vu8pwvkMrzQnTS5tW1w.png" /><figcaption>right-click → Inspect</figcaption></figure><p>Or you can just <strong>“right-click” → Inspect.</strong></p><p>Or you can click on <strong>Customize and control Google Chrome </strong>(the three-dots icon at the top-right corner)<strong> </strong>and then select <strong>More Tools</strong> &gt; <strong>Developer Tools:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZuZIgqlJsYUZa-VuCvDWJQ.png" /><figcaption>More tools → Developer Tools</figcaption></figure><p>Click on the <strong>Console</strong> tab. You should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTrFPx_RPD4hE5Tmr_QJgQ.png" /><figcaption>Browser Console</figcaption></figure><p>To clean up the console, press <strong>CRTL + L</strong></p><p>To list the <strong>sections names</strong>, type:</p><pre>document.querySelectorAll(&#39;.title&#39;).forEach(function (item){console.log(item.innerText)})</pre><p>Whereas the screen names can be listed typing:</p><pre>document.querySelectorAll(&#39;.name&#39;).forEach(function (item){console.log(item.innerText)})</pre><p>Now you can <strong>select →copy →paste</strong> the lists in your favorite text editor.</p><p>One last thing. You maybe need a way to remove the debugger information printed next to the names:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*uL125Afs5xnxLBP0wvOeaw.png" /><figcaption>On the right, there are debug information</figcaption></figure><p>If you are using <strong>OSX</strong>, you could use <strong>TextEdit</strong>:</p><p>Paste the list in it and holding the <strong>Option key, </strong>you enter in “column mode”. Now you will be able to cut away the right part of the list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*VZLCnPAkSkTwz4Dq5wkCMw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e700210b2c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I used Google Suite to automate contracts creation]]></title>
            <link>https://medium.com/@c.tesoriero/how-to-use-google-suite-to-automate-contracts-creation-a2f4b0c341f4?source=rss-22a2eb9c42a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2f4b0c341f4</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[g-suite]]></category>
            <category><![CDATA[google-forms]]></category>
            <category><![CDATA[google-sheets]]></category>
            <category><![CDATA[google-docs]]></category>
            <dc:creator><![CDATA[Claudio Tesoriero]]></dc:creator>
            <pubDate>Mon, 28 Jan 2019 15:09:45 GMT</pubDate>
            <atom:updated>2019-01-28T15:16:28.262Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ighhQwXaaYFR59GU9qNGJg.jpeg" /></figure><p>In a world where mainstream words are Artificial Intelligence, Machine Learning, Deep Learning, Blockchain and other more and less fancy-buzz-words, sometimes there is still space for very simple solutions.</p><p>It is the KISS (Keep It Simple Stupid) principle, and I still use it whatever I can.</p><h4>TLTR:</h4><p>I wanted to use Google Form to collect data from our clients, and then, automatically receive a PDF document (get from a set of already prepared Google Docs contract templates) filled with the provided data.</p><p>So here is what I have done:</p><ul><li>Open my Google Drive account and create a new Google Form;</li><li>Insert questions and fields;</li><li>Create an associated Google Sheet;</li><li>Create one or more Google Doc templates using convenient placeholders (for instance &lt;client_last_name&gt;, &lt;price&gt;, &lt;vat_percentage&gt;, etc.)</li><li>Create a Script inside the Google Sheet I have created earlier</li><li>Put the logic of the doc creation inside a convenient function</li><li>Create a trigger inside Google Suite so the function will start every time a new form is submitted</li></ul><h3>Document generation</h3><p>Once I have created a Google Form and I have set up it in order to store Form responses in a spreadsheet, I should have a Google Sheet where the column names are the questions of the form.</p><p>Every time a form is submitted a new row will be created with the user response.</p><p>Now we can open the Script Editor of the Sheet (Tools → Script editor) and let’s start coding.</p><p>The first thing to do is to associate the column names with the placeholders used into templates, and then to build a JSON object with the pairs placeholder/value. I think that this is important. We can, of course, directly use the form field names as template placeholders, but we will have to modify any template every time we need to change something in our form.</p><pre>//this object maps GSheet column into convenient placeholders used into GDocs templates</pre><pre>var columns_placeholder_map = { <br>  &quot;chronological information&quot; : &quot;{{date_time}}&quot;, //placeholders have the form of {{placeholder name}},<br>  &quot;Please, insert the company name&quot; : &quot;{{company_name}}&quot;,<br>  &quot;Company director first name&quot; : &quot;{{first_name}}&quot;,<br>  &quot;Company director last name&quot; : &quot;{{last name}}&quot;,<br>  &quot;Price (in $)&quot; : &quot;{{price}}&quot;<br>  //...<br>  //...<br> }</pre><p>Let’s write a simple procedure to map the values of a row with the corresponding placeholder:</p><pre>/*<br>Returns an object having keys as in columns_placeholder_map values, and values equals to the given row<br>*/</pre><pre>function transformRowInJSON(row_number) {<br>  var ss = SpreadsheetApp.getActiveSpreadsheet();<br>  var sheet = ss.getSheets()[0];<br>  var cols = sheet.getLastColumn();<br>  //we get the first row as form field (label) names<br>  var labels = sheet.getRange(1, 1, 1, cols).getValues()[0]<br>  <br>  //now we get the values of the given row<br>  var dataRange = sheet.getRange(row_number, 1, 1, cols);<br>  var data = dataRange.getValues(); <br>  var row_data = data[0];<br>  <br>  //now we have labels and row_data, let&#39;s build the final JSON object to return<br>  var result = {};//this is the returned object<br>  <br>  for (var i=0;i&lt;row_data.length;i++){<br>    var label = labels[i];<br>    var key = columns_placeholder_map[label.trim()];<br>    //maybe some label is not mapped <br>    if (key) {<br>      var value = row_data[i];<br>      result[key] = value;<br>    }<br>  }<br>  <br>  /*<br>  At this point we will have something like this:<br>  {<br>    &quot;{{date_time}}&quot;:&quot;2019-01-28 07:22:34&quot;, //actually this is a Date object<br>    &quot;{{company_name}}&quot;: &quot;ACME ltd&quot;,<br>    &quot;{{first_name}}&quot;: &quot;John&quot;,<br>    &quot;{{last name}}&quot;: &quot;Doe&quot;<br>    &quot;{{price}}&quot;:&quot;1000&quot;<br>  }<br>  */<br>  <br>  return result;<br>}//transformRowInJSON</pre><p>Now we have to pick the template, make a copy of it and then replace the placeholders with the right values.</p><pre>var templateId = &quot;.......&quot;;<br>var docId = DriveApp.getFileById(templateId).makeCopy().getId();</pre><p>The template id can be found opening the template doc and copy/paste its id from the URL:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*gGWP2XY9oFR6-hk780_uvg.png" /><figcaption>How to retrieve the Template Id</figcaption></figure><p>Of course, we could have more than one template and we can implement some business logic in order to choose the right one depending on the response given through the form.</p><p>At this point, we can replace the values. To do this, we can use the replaceText() method of the body object:</p><pre>var doc = DocumentApp.openById(docId);<br>doc.setName(&quot;foo&quot; /* put your computed name of the final document */ );</pre><pre>var body = doc.getBody();</pre><pre>//data is the object returned by transformRowInJSON()<br>for(var key in data){<br>  body.replaceText(key, data[key]);<br>}<br>doc.saveAndClose();//flush the changes</pre><h3>Export in PDF</h3><p>Now we can save the computed document in PDF format.</p><p>This can be useful if we have to send/share the final result with someone as clients or business partners.</p><pre>var doc = DocumentApp.openById(docId);<br>var docPdf= doc.getAs(&#39;application/pdf&#39;).setName(doc.getName() + &quot;.pdf&quot;);<br>var pdf = DriveApp.createFile(docPdf);</pre><p>To share the document, we have to set the right permissions:</p><pre>pdf.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);</pre><h3>Send the result via email</h3><p>Why do not send the PDF file or its link via email?</p><p>We can ask for an email to whom filled the form or send the document to ourselves.</p><p>Suppose we have a very simple email content, we can have a placeholder inside it and replace the link and/or attach the PDF directly to the email.</p><pre>var EMAIL_CONTENT = &quot;New PDF has been generated, please see the attached file, or click the following link {{pdf_link}}&quot;;var var recipientEmail = &quot;me@example.com&quot;;</pre><pre>var content = EMAIL_CONTENT.replace(&quot;{{pdf_link}}&quot;,&quot;<a href="http://drive.google.com/uc?export=download&amp;id=">http://drive.google.com/uc?export=download&amp;id=</a>&quot; + pdf.getId());</pre><pre>MailApp.sendEmail(recipientEmail, &quot;New generated PDF: &quot;  + pdf.getName(), content,<br>  {<br>    noReply:true,<br>    attachments:[pdf]<br>  });</pre><h3>Let’s automate!</h3><p>We have to write a function that will be the entry point of the automation.</p><p>Then we will instruct GSuite to execute the function every time a new set of responses is submitted.</p><p>The function could be something like this:</p><pre>function compute() {<br>  var ss = SpreadsheetApp.getActiveSpreadsheet();<br>  var sheet = ss.getSheets()[0];</pre><pre>  //this is the row that has the values provided by the user<br>  var lastRow = sheet.getLastRow();</pre><pre>  //let&#39;s start with the Magic!<br>  var data = transformRowInJSON(lastRow);</pre><pre>  //load the template<br>  //...</pre><pre>  //create a copy of the template<br>  //...</pre><pre>  //replace placeholders with row values (stored into data object)<br>  //...</pre><pre>  //prepare and store the PDF file<br>  //...</pre><pre>  //send PDF via email<br>  //...<br><br>}</pre><p>To define the trigger:</p><ul><li>From the Script Editor go to Edit → Current project’s triggers</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*lyBH265Kb3DCXTVvzbs5DA.png" /><figcaption>Open the current project’s triggers dashboard</figcaption></figure><ul><li>Click on Add Trigger</li><li>Select the function to execute</li><li>Select “From spreadsheet” as the event source</li><li>Select “On form submit” as the event type</li><li>Save</li></ul><p>And that’s it.</p><p>Of course, there is plenty of space for improvements such as sub-templates, table generation and so on, but for the moment this is enough for my purposes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2f4b0c341f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>