Daniel Phiri Open Source Advocate. Technical Writer and Speaker. Community Lead and Builder.

Workflow automation with n8n.io

4 min read 1267

n8n.io logo against a sky background

It’s always been part of human nature to automate the boring and mundane tasks of everyday life — whether its scraping a website every 4 days or sharing updates to a Slack channel.

I was doing so myself when I wound up on a really interesting workflow automation tool called n8n.io (pronounced nodemation).

You know — like Kubernetes is k8s, nodemation is n8n.io.

It’s pretty sweet.

Out of the box, it doesn’t look like it has much to do with programming.

A quick check on the integrations page and you see a growing number of third party APIs available to make your life easy.

Don’t worry if you can’t find inspiration immediately, the templates and community inspired workflows page has a cool list of already automated workflows you can either use yourself or get a few ideas from.

This product has a pretty cool thing going on.

Today, we’ll be adding to that list of workflows.

We aren’t going through the easiest time at the moment with everything going on in the world, and sometimes we need a little lift up.

We made a custom demo for .
No really. Click here to check it out.

We’re going to create a workflow that sends positive affirmations to your telegram chat or group everyday at the time you want.

Prerequisites

Getting up and started with n8n.io is really cool.

  • You need to have Node.js installed
  • You need to have npm installed

Note: You might have some trouble if you don’t have node-gyp installed.

The official GitHub page has instructions for how to get it running on multiple operating systems.

Getting started

Once you meet all the prerequisites, you can install the n8n CLI with npm install n8n -g and run it with n8n.

When prompted, press o in your terminal to open the local address in your browser and begin automating workflows.

You’ll be met with this screen:

The starting screen to begin an automated workflow on n8n.io
Nodemation calls integrations nodes.

It has a good number of third party nodes and inbuilt nodes.

Sometimes, nodes can be used to trigger or start a workflow.

To start it off, we’ll add a Cron trigger that will start our workflow at a specific time.

If you click the X in the top right corner, you’ll open up a menu of nodes.

Click on the trigger tab and search Cron.

Click on it at the time you want it to be triggered.

Click execute workflow, and you should see a small alert in the bottom right corner telling you the workflow ran successfully.

A screenshot of n8n.io when a workflow runs successfully.

Be sure to change settings in left tab so that the Cron job runs at a time in your timezone. That can be an issue.

We have our workflow being triggered at a specific time every day.

Now we need to request data from an API to get us these affirmations.

Luckily for us, n8n has an HTTP Request node and thanks to the folks at affirmations.dev, we have some awesome messages to return.

Again, we click the X in the top right corner and search HTTP and click on the HTTP Request node.

Paste https://affirmations.dev in the URL section and execute the workflow.

Successfully run it again, but this time you get returned some data, which is always good when making a request.

Close the modal and now the flow portion, click and hold the circle on the Cron node, and drag it to the left side of the HTTP Request node.

This way, we’re telling nodemation that when the Cron node is triggered, we need to make a request and return some data.

A screenshot showing developers how to request that n8n.io return data.

We’re being returned affirmations in JSON format, and we want to be able to send these out via Telegram.

We have a Telegram node at our disposal.

As we did before with the Cron and HTTP Request nodes, search and click Telegram.

Searching and clicking Telegram in nodemation.

There’s a few fields highlighted and we don’t have that data yet.

So before we use the Telegram node, we have to get those details. Here’s what we need to do:

Here, you give your bot a name and a unique username and get back a URL that directs you to the bot and token to access the bot via HTTP. We need to keep this safe.

Click on the bots URL (t.me/<bot username>) and press start when taken to its chat window.

The chat window for the botfather.

  • Add the bot to a group
  • Send /test hi in the group chat you just added the bot to
  • In your browser, go to https://api.telegram.org/bot<TOKEN>/getUpdates – replace <TOKEN> with the token you get when creating the bot.
  • You’ll get back some JSON, find a property called chat, and get the corresponding ID (i.e. chat:{id:-12345)

Now we have our Telegram API token and chat ID.

We need to add credentials in our n8n credentials section.

We’ll name it Telegram Token and then paste the token from the botfather into the access token field.

A gif depicting a user pasting a token from the botfather into the access token field.

We connected the HTTP Request node and Telegram so we can send the response as a message.

n8n lets us take data from other nodes and use it in different fields.

In our case, we’re getting the response data from the HTTP Request node and adding it to a message that we’ll send using the Telegram node.

We open the Telegram node, click the gears next the the text field, and click add expression.

We have two sections — variable selector and expression.

In the expression section, we type out the message.

Because we want the affirmation to be sent at the end of the text, we make a few new lines before we head over to the variable selector.

We use this section to interpolate data from other nodes into the main expression.

To select the data, we click on current node > Input Data > JSON and then select the JSON property we want, which in our case is affirmations.

This way, at the end of the expression “Hey Daniel, here is your daily affirmation”, we have a different affirmation every day depending on what the API request returned.

Setting up our daily affirmations in n8n.io.

Add your Chat ID and make sure all other credentials in the Telegram field have been filled.

We’ll leave the chat operation as send message because that’s what we’re going for.

Close the node and click execute workflow.

The final step to initiating our workflow.

Check your Telegram and you should have a new message from your Daily Good Vibes bot.

Our 'Daily Good Vibes' workflow autoamtion.

Looking back it’s pretty cool what we’ve got done with practically no code.

We’re requesting data from an API and delivering it to our Telegram client.

With tons of other cool nodes, there’s so much to do with nodemation.

Now, this is a really basic example of workflow automation, check it out here.

These happen to be some of my favorites that aren’t as basic:

Conclusion

Hopefully with this you now have an understanding of how to use n8n.io. I hope you’ll go on to create some really useful workflows.

Let me know on Twitter if you do or add them to be displayed on the n8n.io workflows page.

Stay safe and take care.

200’s only Monitor failed and slow network requests in production

Deploying a Node-based web app or website is the easy part. Making sure your Node instance continues to serve resources to your app is where things get tougher. If you’re interested in ensuring requests to the backend or third party services are successful, try LogRocket. https://logrocket.com/signup/

LogRocket is like a DVR for web apps, recording literally everything that happens on your site. Instead of guessing why problems happen, you can aggregate and report on problematic network requests to quickly understand the root cause.

LogRocket instruments your app to record baseline performance timings such as page load time, time to first byte, slow network requests, and also logs Redux, NgRx, and Vuex actions/state. .
Daniel Phiri Open Source Advocate. Technical Writer and Speaker. Community Lead and Builder.

Leave a Reply