<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: maxtkacz</title>
    <description>The latest articles on DEV Community by maxtkacz (@maxtkacz).</description>
    <link>https://dev.to/maxtkacz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F374543%2F7527e4c8-7f62-4f6b-842c-a7ee346a21b2.jpg</url>
      <title>DEV Community: maxtkacz</title>
      <link>https://dev.to/maxtkacz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/maxtkacz"/>
    <language>en</language>
    <item>
      <title>Automate Designs with Bannerbear and n8n</title>
      <dc:creator>maxtkacz</dc:creator>
      <pubDate>Tue, 19 May 2020 12:19:49 +0000</pubDate>
      <link>https://dev.to/n8n/automate-designs-with-bannerbear-and-n8n-368i</link>
      <guid>https://dev.to/n8n/automate-designs-with-bannerbear-and-n8n-368i</guid>
      <description>&lt;p&gt;As a designer and self-proclaimed data nerd, I’ve been involved in &lt;a href="https://en.wikipedia.org/wiki/Procedural_generation"&gt;proceduralizing&lt;/a&gt; creative deliverables for some time. Up until now however, my concepts always had to reconcile with the limitations of &lt;a href="https://www.adobe.com/products/indesign.html"&gt;InDesign&lt;/a&gt; macros or my coding skills. &lt;a href="https://n8n.io"&gt;n8n&lt;/a&gt; empowers me to apply my basic understanding of data objects and the interwebs to create some pretty slick automations with minimal effort.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VteKFx-H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A-hgpo9yBGc6kNrw4CkTA6A.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VteKFx-H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A-hgpo9yBGc6kNrw4CkTA6A.jpeg" alt=""&gt;&lt;/a&gt;Automating designs with Bannerbear and n8n&lt;/p&gt;

&lt;p&gt;When it comes to creativity in a design context, many tasks don’t involve a whole lot of creativity — for example, updating a daily quote post graphic. What piques my interest is how do we empower designers to stay creative and leave the grunt work to automation.&lt;/p&gt;

&lt;p&gt;In this tutorial, I will teach you how to create your very own procedural graphic banner workflow. Using a styled template, we’ll automate modifying image and text layers to generate creative graphics on-demand. In the interest of fun, we’ll create some Cocktail Recipe banners. However, this workflow can easily be tweaked to be very useful in marketing, e-commerce, and beyond.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the workflow in five parts
&lt;/h3&gt;

&lt;p&gt;We’ll use n8n integrations for &lt;a href="https://www.bannerbear.com/"&gt;Bannerbear&lt;/a&gt; and &lt;a href="https://rocket.chat/"&gt;Rocket.Chat&lt;/a&gt; to get this workflow up and running. Rocket.Chat is a scalable and open-source alternative to messaging app &lt;a href="https://slack.com"&gt;Slack&lt;/a&gt;, and Bannerbear is a simple REST API that automatically generates variations of graphic templates at scale.&lt;/p&gt;

&lt;p&gt;To accomplish this, we’ll go through five steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating a &lt;a href="https://docs.n8n.io/nodes/n8n-nodes-base.cron/"&gt;&lt;em&gt;Cron&lt;/em&gt;&lt;/a&gt; node&lt;/li&gt;
&lt;li&gt;Creating an &lt;a href="https://docs.n8n.io/nodes/n8n-nodes-base.httpRequest"&gt;&lt;em&gt;HTTP Request&lt;/em&gt;&lt;/a&gt; node&lt;/li&gt;
&lt;li&gt;Designing a Bannerbear template&lt;/li&gt;
&lt;li&gt;Creating a &lt;a href="https://docs.n8n.io/nodes/n8n-nodes-base.bannerbear/"&gt;&lt;em&gt;Bannerbear&lt;/em&gt;&lt;/a&gt; node&lt;/li&gt;
&lt;li&gt;Creating a &lt;a href="https://docs.n8n.io/nodes/n8n-nodes-base.rocketchat/"&gt;&lt;em&gt;Rocket.Chat&lt;/em&gt;&lt;/a&gt; node&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have also submitted the &lt;a href="https://n8n.io/workflows/365"&gt;workflow&lt;/a&gt; (the workflow was build using &lt;a href="mailto:n8n@0.111.0"&gt;n8n@0.111.0&lt;/a&gt;) on n8n.io, in case you’d like to skim through it. Please note that you’ll still need to configure a couple of things like your credentials as well as the settings of the &lt;em&gt;Bannerbear&lt;/em&gt; and &lt;em&gt;Rocket.Chat&lt;/em&gt; node. You can find information on how to set up n8n in the &lt;a href="https://docs.n8n.io/#/setup"&gt;documentation&lt;/a&gt;. Alternatively, you can sign-up for &lt;a href="https://n8n.cloud"&gt;n8n.cloud&lt;/a&gt; to get access to our hosted service.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Cron node: Trigger the workflow every Friday evening
&lt;/h3&gt;

&lt;p&gt;In the Node Editor view, add a new node by clicking on the '&lt;strong&gt;&lt;em&gt;+&lt;/em&gt;&lt;/strong&gt;' button on the top right of the Editor UI. Select the &lt;em&gt;Cron&lt;/em&gt; node under the &lt;strong&gt;&lt;em&gt;Triggers&lt;/em&gt;&lt;/strong&gt; section. Click on the &lt;strong&gt;&lt;em&gt;Add Cron Time&lt;/em&gt;&lt;/strong&gt; button, select ‘Every Week’ as the &lt;strong&gt;&lt;em&gt;Mode&lt;/em&gt;&lt;/strong&gt;, ‘18’ as the &lt;strong&gt;&lt;em&gt;Hour&lt;/em&gt;&lt;/strong&gt;, and ‘Friday’ as the &lt;strong&gt;&lt;em&gt;Weekday&lt;/em&gt;&lt;/strong&gt;. You can set the cron job to trigger whenever you like.&lt;/p&gt;

&lt;p&gt;In my case, it’ll trigger at 6 PM, giving me enough time to prepare the cocktail before enjoying it. Unfortunately, the workflow can’t make the actual cocktail for you … yet 🙃&lt;/p&gt;

&lt;p&gt;Here’s a video of me following the steps above.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/e2fu5-QyFEE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  2. HTTP Request node: Get random cocktail recipe data
&lt;/h3&gt;

&lt;p&gt;Next, let’s add an &lt;em&gt;HTTP Request&lt;/em&gt; node. It can be used to query an &lt;a href="https://docs.n8n.io/reference/glossary.html#api"&gt;API&lt;/a&gt; so that we can fetch a random cocktail recipe whenever the workflow is triggered.&lt;/p&gt;

&lt;p&gt;We’ll use &lt;a href="https://www.thecocktaildb.com/api.php"&gt;TheCocktailDB&lt;/a&gt; to get information about a random cocktail recipe. They offer a free test API key and each Cocktail comes with an image, name and recipe which will be perfect for our use case. Create the &lt;em&gt;HTTP Request&lt;/em&gt; node by clicking on the '&lt;strong&gt;&lt;em&gt;+&lt;/em&gt;&lt;/strong&gt;' button on the top right of the Editor UI. In the node configuration view, enter the following URL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.thecocktaildb.com/api/json/v1/1/random.php"&gt;https://www.thecocktaildb.com/api/json/v1/1/random.php&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you click on the &lt;strong&gt;&lt;em&gt;Execute Node&lt;/em&gt;&lt;/strong&gt; button, you’ll see that the node will pull in the details of a random cocktail for you. Here’s a video of me following the steps mentioned above.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/z0ild90leUU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;3. Bannerbear app: create a template&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;First of all, create a free &lt;a href="https://www.bannerbear.com/"&gt;Bannerbear&lt;/a&gt; account. Now, create a new Project. I named mine ‘Cocktail Recipes’. Each project in Bannerbear can house many templates. Create a new template by clicking on the &lt;strong&gt;&lt;em&gt;Create a Template&lt;/em&gt;&lt;/strong&gt; button. Next, select ‘Square (1000x1000)’ as your size format and hit &lt;strong&gt;&lt;em&gt;Save&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now, click on &lt;strong&gt;&lt;em&gt;Edit Template&lt;/em&gt;&lt;/strong&gt; to open the template designer — if you’ve ever used Photoshop or Sketch, this should look familiar. It’s a typical layer-based design tool, where you add layers of images, text, and shapes to create your graphic template. CocktailDB provides a square image for each cocktail entry, so let’s use that as a background image for our template. Click the + icon next to &lt;em&gt;New Layer&lt;/em&gt; on the left-hand side panel, and select “Image Rectangle (API)”.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Don’t select ‘Image’ as we need the API functionality to be able to modify this image programmatically and use Bannerbear’s fancy auto-resizing logic.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On your canvas, click on the newly added image and resize it to fit the entire canvas. Here’s a video of me following the steps mentioned above.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/1kcIg1uGivM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;With the ‘Image Rectangle’ still selected, set the &lt;strong&gt;&lt;em&gt;Type&lt;/em&gt;&lt;/strong&gt; to &lt;code&gt;fill&lt;/code&gt;. Set &lt;strong&gt;&lt;em&gt;AnchorX&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;AnchorY&lt;/em&gt;&lt;/strong&gt; to ‘center’ from the &lt;strong&gt;&lt;em&gt;Layer property&lt;/em&gt;&lt;/strong&gt; panel (located on the right-hand side of your canvas). This will ensure that images scale to fit the whole canvas while maintaining their aspect ratio — to avoid it looking “squished”. Lastly, set the layer’s name to &lt;code&gt;cocktail-image&lt;/code&gt;— we’ll use this later to access the layer from n8n.&lt;/p&gt;

&lt;p&gt;Next, add another new layer and select ‘Text (API)’ from the dropdown. Set the layer’s name to &lt;code&gt;title&lt;/code&gt;. Increase the font size to ±80 as we’ll use this layer for our Cocktail name. Feel free to style or position it how you like.&lt;/p&gt;

&lt;p&gt;Repeat this step and create another text layer, this time naming it &lt;code&gt;recipe&lt;/code&gt;. In my template, I’m overlaying the recipe instructions over the Cocktail image. To ensure it’s always legible, for example, when the background image has lots of light colors, you can opt to assign a “Background color” to the text. Here’s a GIF of me following the steps mentioned above.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/rQ6l8BiCRP8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Lastly, I created some overlay graphics in Illustrator to give our banner some visual oomph. This is a great way to incorporate a visual identity into the template and offload the “heavy lifting” of design into more advanced tools. &lt;a href="https://drive.google.com/drive/folders/1NxMcEebuY2me76gdAzea0O-TJl_O67X3?usp=sharing"&gt;Download the assets&lt;/a&gt; I created or design your own (free templates are available for personal use on &lt;a href="https://www.vecteezy.com/"&gt;vecteezy.com&lt;/a&gt;). In the template editor, Add a new layer, select “Image” then upload your image via the &lt;strong&gt;&lt;em&gt;Layer property&lt;/em&gt;&lt;/strong&gt; panel.&lt;/p&gt;

&lt;p&gt;Below is a photo reference of our final template in the Bannerbear editor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gfv-Y3R4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A1Frz6q5qrj38pxOMgKEc8A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gfv-Y3R4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A1Frz6q5qrj38pxOMgKEc8A.png" alt=""&gt;&lt;/a&gt;Finished Cocktail Recipe template&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Bannerbear node: Automate the image design&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before switching back to the n8n editor, click on the &lt;strong&gt;&lt;em&gt;Settings / API Key&lt;/em&gt;&lt;/strong&gt; button in Bannerbear and copy the &lt;strong&gt;&lt;em&gt;Project API Key&lt;/em&gt;&lt;/strong&gt;. Back in the n8n editor, we will add a Bannerbear node to automate creating variations of our template.&lt;/p&gt;

&lt;p&gt;In the Bannerbear node, add a new credential and paste the &lt;em&gt;Project API Key&lt;/em&gt; there. Select ‘Cocktail Recipe’ as the &lt;strong&gt;&lt;em&gt;Template ID&lt;/em&gt;&lt;/strong&gt; from the dropdown. Now, click on the &lt;strong&gt;&lt;em&gt;Add Field&lt;/em&gt;&lt;/strong&gt; button, select ‘Wait for Image’ and toggle the button to activate it. Since Bannerbear takes a few seconds to generate the image, this option makes sure that the node waits until the image has been created and passes the image URL in the result.&lt;/p&gt;

&lt;p&gt;Now, under the &lt;strong&gt;&lt;em&gt;Modifications&lt;/em&gt;&lt;/strong&gt; section, click on the &lt;strong&gt;&lt;em&gt;Add Modification&lt;/em&gt;&lt;/strong&gt; button. First of all, let’s specify the background image by selecting the cocktail-image layer. Since the Image URL is a dynamic piece of information, click on the &lt;strong&gt;&lt;em&gt;Add Expression&lt;/em&gt;&lt;/strong&gt; button by clicking on the gears icon. In the &lt;strong&gt;&lt;em&gt;Variable Selector&lt;/em&gt;&lt;/strong&gt;, choose the following variable:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Current Node &amp;gt; Input Data &amp;gt; JSON &amp;gt; drinks &amp;gt; [Item: 0] &amp;gt; strDrinkThumb&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add another modification, select the title layer and in the &lt;strong&gt;&lt;em&gt;Text&lt;/em&gt;&lt;/strong&gt; field, select the following from the &lt;strong&gt;&lt;em&gt;Variable Selector&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Current Node &amp;gt; Input Data &amp;gt; JSON &amp;gt; drinks &amp;gt; [Item: 0] &amp;gt; strDrink&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Finally, add another modification, select the recipe layer and in the &lt;strong&gt;&lt;em&gt;Text&lt;/em&gt;&lt;/strong&gt; field, select the following from the &lt;strong&gt;&lt;em&gt;Variable Selector&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Current Node &amp;gt; Input Data &amp;gt; JSON &amp;gt; drinks &amp;gt; [Item: 0] &amp;gt; strInstructions&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, click on the &lt;strong&gt;&lt;em&gt;Execute Node&lt;/em&gt;&lt;/strong&gt; button, you’ll see that the node will output the prepared image’s URL as well. Here’s a video of me following the steps mentioned above.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/a-obLjhHx-k"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Rocket.Chat node: Post the image in a channel&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Add a &lt;em&gt;Rocket.Chat&lt;/em&gt; node by clicking on the '&lt;strong&gt;&lt;em&gt;+&lt;/em&gt;&lt;/strong&gt;' button on the top right and selecting the &lt;em&gt;Rocketchat&lt;/em&gt; node. In the Node Editor, enter your Rocket.Chat credentials. Here’s some detailed &lt;a href="https://docs.n8n.io/credentials/rocketchat"&gt;information&lt;/a&gt; on how to create an &lt;em&gt;User ID&lt;/em&gt; and &lt;em&gt;Auth Key&lt;/em&gt; for the credentials. While creating your personal access tokens, don’t forget to select ‘Ignore (Two Factor Authentication)’ before clicking on the &lt;strong&gt;&lt;em&gt;Add&lt;/em&gt;&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;Next, we need to enter the &lt;em&gt;Channel&lt;/em&gt;. I entered &lt;code&gt;general&lt;/code&gt;, feel free to enter a channel of your choosing. Now, we can send a picture of the delicious cocktail by clicking on &lt;strong&gt;&lt;em&gt;Add Attachment&lt;/em&gt;&lt;/strong&gt; under Attachments. Click on &lt;strong&gt;&lt;em&gt;Add Attachment Item&lt;/em&gt;&lt;/strong&gt; and select ‘Image URL’. To fill the &lt;strong&gt;&lt;em&gt;Image URL&lt;/em&gt;&lt;/strong&gt; field, select the &lt;strong&gt;&lt;em&gt;Add Expression&lt;/em&gt;&lt;/strong&gt; option. Once you have the editor open, select the following in the variable selector:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Current Node &amp;gt; Input Data &amp;gt; JSON &amp;gt; image_url&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Don’t forget to activate the workflow by toggling the activate button on the top right. Here’s a GIF of me following the steps mentioned above.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/6VYBBC-int4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;You can apply the steps in this walkthrough to build far more powerful use cases than our fun Cocktail Recipe banners. Especially for marketing, e-commerce, and content calendar needs. Below I’ve listed some ways in which this workflow could be expanded — feel free to try these out and drop a comment if you’d like for us to cover them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You could design different versions of the banner template, each optimized for their intended delivery channel — like an Instagram Story (9:16) or a Facebook post (1.91:1) and attach them to a new card in a Trello board.&lt;/li&gt;
&lt;li&gt;Use IF nodes in n8n to pass a predefined image to a Bannerbear template. In our Cocktail banner, this could be used to add the correct drinkware icon depending on the glass type of the cocktail (like “Highball” or “Collins”).&lt;/li&gt;
&lt;li&gt;Create a Bannerbear template for a mockup of your SaaS solution and generate variations with your leads’ name, photo and company logo.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DBqZeIkZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/500/1%2A5NrW7xOke_3xqdPXhA8fwg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DBqZeIkZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn-images-1.medium.com/max/500/1%2A5NrW7xOke_3xqdPXhA8fwg.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;We’ve created a nifty proof of concept to demonstrate procedurally modifying graphics. A similar setup using the Sketch command-line tool is also possible. But from my experience, this is a much longer process that requires a lot more lines of code.&lt;/p&gt;

&lt;p&gt;The biggest takeaway for designers and programmers alike is how simple yet potentially powerful the actual mechanics of this whole workflow are. I am really curious to see what kinds of workflows you cook up with Bannerbear and n8n. What types of use cases do you think would be most valuable? Drop a comment below — I love to discuss use case ideas or get feedback on what you’d like to see next.&lt;/p&gt;

&lt;p&gt;In case you’ve run into an issue while following the tutorial, feel free to reach out to me on &lt;a href="https://www.linkedin.com/in/max-tkacz-696774153/"&gt;LinkedIn&lt;/a&gt; or ask for help on our &lt;a href="https://community.n8n.io/"&gt;forum&lt;/a&gt; 💙&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This &lt;a href="https://n8n.io/blog/automate-designs-with-bannerbear-and-n8n/"&gt;post&lt;/a&gt; originally appeared on n8n.io &lt;a href="https://n8n.io/blog/"&gt;blog&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>tutorial</category>
      <category>api</category>
      <category>graphicdesign</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
