Automate Blogging Workflow using Notion + Hashnode + n8n

AriesAries
5 min read

In the previous article , I have described how to build an automated blogging workflow using Hashnode and Notion on Make platform. It has been tremendously helpful for bloggers in managing their blog posts, allowing them to focus on content creation rather than boring administrative tasks. From the functional perspective, it has been doing fine.

However, there’s lots of room for improvement. If we look at the structure of the workflow that has been built using Make, it looks quite complex and not so intuitive. That makes things if there is anything I can do to improve it. When I discovered n8n, I immediately could see that I can build a better automated blogging workflow using this platform. And I will describe the setup in this article.

Automate Blogging Workflow

Imagine managing blogs with numerous posts. As a content creator, you want to focus on creating posts for your blogs. The process of writing and updating previously uploaded blog posts involves tedious navigation through the blogging platform, like Hashnode. Wouldn't it be more efficient to manage all your posts within Notion and having them automatically uploaded to the blogging platform? This automation workflow aims to boost your productivity by streamlining the process, allowing you to focus more on content creation and less on the administrative tasks of blogging.

About n8n

n8n is an open-source workflow automation platform that allows users to connect various applications and automate tasks with a drag-and-drop interface. It offers an intuitive interface to easily build a workflow automation with the possibility to insert custom code. This gives the flexibility of code with the speed of no-code.

Compared to Zapier, IFTTT, and Make, n8n offer several unique advantages:

  • Intuitive interface. It is very easy to specify trigger options and to connect different applications and tools using a drag-and-drop interface.

  • Custom-code. It supports custom codes written in JavaScript and Python. This enables technical users to build powerful automatic workflows, giving more flexibility.

  • Self-hosted option. Hence, it is possible to run n8n totally free.

Building the Workflow

Building a workflow on n8n is much easier. It is pretty intuitive to connect the apps, tools, and supporting logic nodes (such as If-else, filter, merge, and so on). It is similar to a flow-chart.

The components needed for this workflow are as follows.

  • Notion, where the contents of the blog post are stored.

  • Hashnode.

  • AWS S3, to store images.

  • Code node for custom codes.

Here is the complete setup of the workflow. As you can see, the workflow looks simpler compared to the one I built on Make. It is also easier to understand, in my opinion. There is no weird construct in the workflow.

The workflow consists of two parts. The first part is the trigger. The workflow is triggered when there’s some updates (i.e., a new page has been created or updated) in the table.

The second one is the main part for the workflow. It retrieves Notion pages and for each page, it will parse the full contents, upload images to AWS S3, convert the contents to Markdown format, and publish the contents to Hashnode using GraphQL.

The conversion from Notion blocks to Markdown has to be manually implemented in a code node. This is how it looks like.

# Loop over input items and add a new field called 'myNewField' to the JSON of each one
output = {}
output["markdown"] = ""
output["items"] = []

def check_annotate(item, type):
  parsed_text = ""
  rich_texts = item.json[type]["text"]
  for rich_text in rich_texts:
    text = rich_text["plain_text"].strip().rstrip()
    if rich_text["annotations"]["bold"]:
      text = "*" + text + "*"
    if rich_text["annotations"]["italic"]:
      text = "**" + text + "**"
    if rich_text["href"]:
      text = "[" + text + "](" + rich_text["href"] + ")"

    parsed_text += text + " "

  parsed_text = parsed_text.replace('    ', '\t').replace('"', '\"').replace('
', '\n')
  parsed_text += "\n\n"
  return parsed_text

for item in _input.all():
  parsed_text = ""
  if (item.json["type"] == "paragraph"):
    parsed_text = check_annotate(item, item.json["type"])
    output["items"].append(parsed_text)
  elif (item.json["type"] == "image"):
    parsed_text = "![](" + item.json["image"]["file"]["url"] + ")\n\n"
    output["items"].append(parsed_text)
  elif (item.json["type"] == "divider"):
    output["items"].append("---

")
  elif ("heading_" in item.json["type"]):
    parsed_text = check_annotate(item, item.json["type"])
    if item.json["type"] == "heading_1":
      parsed_text = "# " + parsed_text
    elif item.json["type"] == "heading_2":
      parsed_text = "## " + parsed_text
    elif item.json["type"] == "heading_3":
      parsed_text = "### " + parsed_text
    output["items"].append(parsed_text)
  elif (item.json["type"] == "bulleted_list_item"):
    parsed_text = check_annotate(item, item.json["type"])
    parsed_text = "- " + parsed_text + "\n"
    output["items"].append(parsed_text)
  elif (item.json["type"] == "numbered_list_item"):
    parsed_text = "1"
    output["items"].append(parsed_text)
  elif (item.json["type"] == "code"):
    parsed_text = check_annotate(item, item.json["type"])
    parsed_text = "```\n" + parsed_text + "```\n\n"
    output["items"].append(parsed_text)

  output["markdown"] += parsed_text
return output

Pricing Models

Compared to Make’s pricing model which is based on the number of operations performed, n8n uses a different pricing model. The price depends solely on your hosting solution and not the number of operations. If you self-host n8n, you can run it for free. n8n also offers a n8n cloud-host option, it will cost you around $20 per month. Hence, it is much cheaper than Make.

Summary

n8n offers a very intuitive, easy-to-use interface to build any automation workflow. Compared to Make, it also offers a better pricing model. By using Hashnode, Notion, and n8n, we are able to build a automatic blogging workflow that can significantly enhance your productivity and streamline your blog management process. Having this automation allows content creators to focus on content creation rather than mundane administrative tasks. I hope this article can be helpful!. Happy automating.

0
Subscribe to my newsletter

Read articles from Aries directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aries
Aries