{"id":7065,"date":"2016-02-21T14:12:03","date_gmt":"2016-02-21T14:12:03","guid":{"rendered":"http:\/\/mcslp.me\/?p=10397"},"modified":"2016-02-21T14:12:03","modified_gmt":"2016-02-21T14:12:03","slug":"how-to-buffer-postshashtags-from-your-blog-using-zapier","status":"publish","type":"post","link":"https:\/\/planet.mcb.guru\/?p=7065","title":{"rendered":"How to Buffer posts+hashtags from your Blog using Zapier"},"content":{"rendered":"<p>I try to automate as much my life as possible, particularly when it comes to computers.<\/p>\n<p>I\u2019ve been using the automated \u2018Social Sharing\u2019 on WordPress.com (and indeed, my blogs in general) for years. However, I\u2019m also a keen Buffer user and WordPress.com does not offer a Buffer connection. Because I also use Buffer to handle my Patreon posts, concentrating them all in one place would make things a lot easier.<\/p>\n<p>What I wanted to do was something quite straightforward, I wanted to turn a blog post entry into post to Twitter (and others) that turned the list of tags I created on the post into #hashtags. This actually doesn\u2019t seem like a particularly complex or uncommon request, but apparently it\u2019s not a standard offering. What I was even more surprised at was that nobody else seemed to have done the same, which has me confused&#8230;<\/p>\n<p>Now there are many options for doing this kind of automated posting, I could have used <a href=\"http:\/\/ifttt.com\/\" >IFTTT<\/a>, but IFTTT while incredibly useful (I have about 60 recipes on there) is also incredibly simplistic and your options are limited. That means I can\u2019t post from WordPress to Buffer with the required hashtags.<\/p>\n<p><a href=\"http:\/\/zapier.com\/\" >Zapier<\/a> is very similar to IFTTT, but also has the option of running multistep Zaps that do more than one thing (IFTTT is limited to one target), but better than that you can include a step that runs information through a JavaScript (or Python) script to do some additional processing.<\/p>\n<p>And this is the key that enables me to do precisely what I need, take a blog post from one of my blogs, process the list of tags into a list of (de-duplicated) hashtags, and then post it into my Buffer queues.<\/p>\n<p>So, here\u2019s how to get Zapier to do what you need, there are going to be five steps to this:<\/p>\n<ol>\n<li>Identify when a new post appears on a WordPress blog<\/li>\n<li>Run a short Javascript program to take the list of tags (actually Terms) from the Blog post into a deduced and hash tagged version<\/li>\n<li>Add it to my Twitter Buffer<\/li>\n<li>Add it to my Facebook Buffer<\/li>\n<li>Add it to my LinkedIn Buffer<\/li>\n<\/ol>\n<p>Here\u2019s how to get it setup. I\u2019m going to assume you know Zapier and can follow the onscreen instructions, it\u2019s not that complex.<\/p>\n<h3>Step 1<\/h3>\n<ul>\n<li>Register for a Zapier account, if you don\u2019t already have one.<\/li>\n<li>Connect your Zapier account to your WordPress blog<\/li>\n<li>Connect your Zapier account to your Buffer account<\/li>\n<\/ul>\n<h3>Step 2<\/h3>\n<p>Create a new Zap on Zapier.<\/p>\n<p>Select \u2018Wordpress\u2019 as your trigger app.<\/p>\n<div><img class=\"alignnone size-full wp-image-10400\" src=\"https:\/\/mcslp.files.wordpress.com\/2016\/02\/screenshot-2016-02-21-13-45-18.png?w=840\" alt=\"Screenshot 2016-02-21 13.45.18.png\"   \/><\/div>\n<p>Now configure how you want the trigger to occur. I basically every post in every category, but if you want to add specific categories or other filtering, feel free.<\/p>\n<h3>Step 3<\/h3>\n<p>For the Action select \u2018Code &lt;\/&gt;&#8217;<\/p>\n<div><img class=\"alignnone size-full wp-image-10401\" src=\"https:\/\/mcslp.files.wordpress.com\/2016\/02\/screenshot-2016-02-21-13-45-28.png?w=840\" alt=\"Screenshot 2016-02-21 13.45.28.png\"   \/><\/div>\n<p>Now Select \u2018Javascript&#8217;<\/p>\n<div><img class=\"alignnone size-full wp-image-10402\" src=\"https:\/\/mcslp.files.wordpress.com\/2016\/02\/screenshot-2016-02-21-13-45-34.png?w=840\" alt=\"Screenshot 2016-02-21 13.45.34.png\"   \/><\/div>\n<p>When it gets to the Edit Template, you\u2019ll need to specify the input variable to the JavaScript, in this case, create one called \u2018tags\u2019 and then select the \u2018Terms Name\u2019 from WordPress Step 1 and you\u2019ll be ready to go.<\/p>\n<div><\/div>\n<div><img class=\"alignnone size-full wp-image-10403\" src=\"https:\/\/mcslp.files.wordpress.com\/2016\/02\/screenshot-2016-02-21-13-45-40.png?w=840\" alt=\"Screenshot 2016-02-21 13.45.40.png\"   \/><\/div>\n<p>These variables that you select here are placed into a hash (associative array) in the JavaScript context called \u2018input\u2019, so in this case, we\u2019ll have the item \u2018input.tags\u2019 to parse in our JavaScript code. The actual list of terms will come through as a comma-separated string<\/p>\n<p>The code itself is quite straightforward:<\/p>\n<blockquote>\n<pre>var hashlist = {};\n\ninput.tags.split(',').forEach(function(item,index)\n{\n\u00a0 var res = item.replace(\/ \/g,'');\n\u00a0 res = res.toLowerCase();\n\u00a0 res = '#' + res;\n\u00a0 hashlist[res] = 1;\n});\nreturn({'hashlist' : Object.keys(hashlist).join(' ')});<\/pre>\n<\/blockquote>\n<p>We iterate over the terms by using \u2018split\u2019 to separate by a comma, then we replace any spaces with nothing (so we turn things like \u2018data migration\u2019 to \u2018datamigration\u2019, convert it to lower case, add the # prefix and add that all to a new associative array. The reason for this is to get rid of duplicates, so even if we have \u2018data migration\u2019 and \u2018datamigration\u2019 in the input, we only get one in the output. This is particularly useful because the \u2018Terms\u2019 list from WordPress is actually composed of both the tags and the categories for each post.<\/p>\n<p>Finally, we return all of that as a string with all the keys of the hash (ie. our nicely formatted tags) separated by a space. However, just like the input value, we return this as an Object with the string assigned to the field \u2018hashlist\u2019. We\u2019ll need this when creating the Buffer post.<\/p>\n<p>I recommend you test this thoroughly and make sure you check the output.<\/p>\n<h3>Step 4<\/h3>\n<p>Choose your target Buffer.<\/p>\n<p>The Buffer API only allows you to post to one queue at a time, but brilliantly, Zapier lets us add multiple steps and so we can do one for each Buffer queue, in my case, the three. The benefit of this is that I can customise and tune the text and format for each. So, for example, I could omit the tags on Facebook, or, as I do, give a nice intro to the message \u2018Please read my new blog post on\u2026\u2019 on FB because I\u2019m not character (or attention span) limited.<\/p>\n<p>Now for each Buffer queue, create your message, and when it comes to choosing the output, make sure you select your JavaScript output (which will be Step 2) and the \u2018hashlist\u2019 value.<\/p>\n<h3>Step 5<\/h3>\n<p>That\u2019s, it! Test it, make sure your posts are appearing, and check your Buffer queue (deleting the entries if required so you don\u2019t double-post items).<\/p>\n<p>You can duplicate and use this as many times as you like, in fact I\u2019ve done this across my two blogs and am now looking into where else I can use the same method.<\/p><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/mcslp.wordpress.com\/10397\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/mcslp.wordpress.com\/10397\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"http:\/\/pixel.wp.com\/b.gif?host=mcslp.me&#038;blog=164882&%23038;post=10397&%23038;subd=mcslp&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>I try to automate as much my life as possible, particularly when it comes to computers. I&rsquo;ve been using the automated &lsquo;Social Sharing&rsquo; on WordPress.com (and indeed, my blogs in general) for years. However, I&rsquo;m also a keen Buffer user and WordPress.com does not offer a Buffer connection. Because I also use Buffer to handle &hellip; <a href=\"http:\/\/mcslp.me\/2016\/02\/21\/how-to-buffer-postshashtags-from-your-blog-using-zapier\/\">Continue reading<span> &#8220;How to Buffer posts+hashtags from your Blog using&nbsp;Zapier&#8221;<\/span><\/a><img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/pixel.wp.com\/b.gif?host=mcslp.me&amp;blog=164882&amp;post=10397&amp;subd=mcslp&amp;ref=&amp;feed=1\" width=\"1\" height=\"1\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[126,70,127],"tags":[42],"_links":{"self":[{"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=\/wp\/v2\/posts\/7065"}],"collection":[{"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7065"}],"version-history":[{"count":5,"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=\/wp\/v2\/posts\/7065\/revisions"}],"predecessor-version":[{"id":7101,"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=\/wp\/v2\/posts\/7065\/revisions\/7101"}],"wp:attachment":[{"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planet.mcb.guru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}