I recently installed a rocket.chat server which I covered here

Rocket Chat, yes it’s better than Teams.
There are a fair few Rocket Chat blogs published over the last few weeks. Sothis post is going to show you how to install it and some cool things you can dowith it. Rocket.Chat - The Leading Communication HubLead with a Communication Hub thatallows total control of your data. All in one platform…

One of the features I really like is the integration with Rocket Chat and Zapier. While it works really well, its also very expensive (at time of writing) from the free tier to the next one up.

Turns out the free tier is really just for dev work, as soon as you start using it, it depletes very quickly.

I understand this, its a business model, and one many businesses use. However as I look to take the entire project self hosted I was interested to see what was available for performing the Zapier/IFTTT type functionality.

n8n

After a look around I setup n8n

n8n
n8n is an extendable workflow automation tool which enables you to connect anything to everything via its open, fair-code model.

The business has only been "public" since Oct 2019 and describes itself as

n8n, a Berlin-based company that has built a “fair code” workflow automation platform to let developers quickly integrate any of the apps that they use to work together automatically — from standard third-party APIs to internal tools created by developers themselves

From my perspective its a a web gui interface backed by code which takes items from X and passes them through gates to Y and displays them.

Off the bat its not as intuative as the aforementioned Zapier and IFTTT and you will need to get your hands dirty with some code. There is however good comunity support (considering this has only been around for a short time) which is google aware as well.

I was able to setup a quick and simple n8n workflow for Rocket chat with a bit of googling without reading the documentation.

Installation

n8n is an npm app, and the site does show examples of both running and installing it as an npm app. However I found the quickets method of getting something up and running to see what it looked like was to use the docker container

# Spin up a basic container
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n:latest

This will get you what can only be classed as a dev environment, it has no credntials to login with, the webhook stuff only listens on localhost etc. The idea here is to quickly get a test environment to see if n8n is for you.

Proper Installation

If you'd like something a lot more stable and secure setup then head over to the n8n Docker Hub page

Docker Hub

Where there ware plenty of options for getting n8n setup in different types of production environment.

I chose to go a little hybrid in my docker compose as at current i'm using this at home.

nano docker-compose.yaml
version: "3"

services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - WEBHOOK_TUNNEL_URL=http://10.10.100.10/
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n

Then crerated a hidden environment file

nano .env
# Folder where data should be saved
DATA_FOLDER=/opt/applications/n8n

# The top level domain to serve from
DOMAIN_NAME=my.lan

# The subdomain to serve from
SUBDOMAIN=n8n

# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: http://n8n.my.lan

# The user name to use for autentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_USER=admin

# The password to use for autentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_PASSWORD=eNtErAsAsSyPaSsWoRdHeRe

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/London

# The email address to use for the SSL certificate creation
SSL_EMAIL=anexample@gmail.com

running this up with Docker compose

docker-compose up -d

Should spin up an n8n environment asking for creds on

http://n8n.my.lan:5678

Enter the creds you provided an you'll be away to go.

First Screen

Once you launch n8n you'll be taken to the webgui home screen

A blank canvas of imagination

Clicking on the Plus in the top right creates nodes, nodes are the steps of the workflow.

And on the left hand side is a menu system for saving, exporting, importing etc.

So the interfaced is pretty sparse, its supposed to be

There is a good n8n video covering the basics

Basic Workflow

Rather than trying to read all the documentation I jumped straight in as I had a workflow I wanted to try and get working.

Input

My Input is a set of rss feeds, for this example i've chosen comics

Output

The output was to daily get the latest comic from the feed to the "dailycomics" channel in my Rocket Chat feed.

The Result

What I ended up with was this

  • Cron node runs the job at 7am each day
  • Several RSS feeds are then checked
  • Because this would provide me with the last weeks worth of output for each RSS feed there is some code to only take the last feed
  • Push this to Rocket chat using a personal token.

What does this look like?

If we double click on each node type its possible to see how this is setup

Cron

The Cron Node is a built in node and in this example i've setup the task to run twice a day

RSS

This is a very basic built in node and needs the URL of the RSS feed

Function

These code blocks are interesting as there isn't an obvious node to use with them, however if you drag and drop code blocks onto the interface n8n will create an appropriate node block. this is handy as well in the support forums where there are lots of code blocks answering questions. Copy them and paste into the n8n interface and a node is created.

This is javascript code stating just the latest item in the rss list.

Rocket.Chat

Rocket Chat again is a built in node type and is after some core information

What will need to be setup are the creds used to communicate with Rocket Chat

Which can be done using Create new

Then enter the personal toen information from Rocket Chat

Click on Create

And its done.

What that looks like as code

n8n provides an interface to download all of this as code, you'll notice that there are no creds stored in the downloaded json file, these are stored in the associated mongoDb

{

"name": "rss to rocket.chat",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"url": "=https://www.comicsrss.com/rss/calvinandhobbes.rss"
},
"name": "RSS - Calvin and Hobbes",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
540,
890
]
},
{
"parameters": {
"url": "https://www.comicsrss.com/rss/dilbert.rss"
},
"name": "RSS Feed - Dilbert",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
550,
710
]
},
{
"parameters": {
"url": "https://www.comicsrss.com/rss/fredbasset.rss"
},
"name": "RSS Feed - Fred Bassett",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
550,
550
]
},
{
"parameters": {
"channel": "dailycomics",
"text": "={{$json["title"]}}\n{{$json["link"]}}",
"jsonParameters": true,
"options": {}
},
"name": "RocketChat",
"type": "n8n-nodes-base.rocketchat",
"typeVersion": 1,
"position": [
1190,
650
],
"alwaysOutputData": false
},
{
"parameters": {
"functionCode": "return [\n items[0]\n];"
},
"name": "Only First Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
890,
640
]
},
{
"parameters": {
"triggerTimes": {
"item": [
{
"hour": 7
},
{
"hour": 19
}
]
}
},
"name": "Cron",
"type": "n8n-nodes-base.cron",
"typeVersion": 1,
"position": [
300,
740
]
},
{
"parameters": {
"url": "https://www.comicsrss.com/rss/garfield.rss"
},
"name": "RSS Feed R- Garfield",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
560,
390
]
},
{
"parameters": {
"url": "https://www.comicsrss.com/rss/hagarthehorrible.rss"
},
"name": "RSS Feed - Hagar",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
550,
240
]
},
{
"parameters": {
"url": "https://www.comicsrss.com/rss/wizardofid.rss"
},
"name": "RSS Feed Read",
"type": "n8n-nodes-base.rssFeedRead",
"typeVersion": 1,
"position": [
540,
1060
]
}
],
"connections": {
"RSS Feed - Dilbert": {
"main": [
[
{
"node": "Only First Function",
"type": "main",
"index": 0
}
]
]
},
"RSS Feed - Fred Bassett": {
"main": [
[
{
"node": "Only First Function",
"type": "main",
"index": 0
}
]
]
},
"RSS - Calvin and Hobbes": {
"main": [
[
{
"node": "Only First Function",
"type": "main",
"index": 0
}
]
]
},
"Only First Function": {
"main": [
[
{
"node": "RocketChat",
"type": "main",
"index": 0
}
]
]
},
"Cron": {
"main": [
[
{
"node": "RSS Feed - Fred Bassett",
"type": "main",
"index": 0
},
{
"node": "RSS Feed - Dilbert",
"type": "main",
"index": 0
},
{
"node": "RSS - Calvin and Hobbes",
"type": "main",
"index": 0
},
{
"node": "RSS Feed R- Garfield",
"type": "main",
"index": 0
},
{
"node": "RSS Feed - Hagar",
"type": "main",
"index": 0
},
{
"node": "RSS Feed Read",
"type": "main",
"index": 0
}
]
]
},
"RSS Feed R- Garfield": {
"main": [
[
{
"node": "Only First Function",
"type": "main",
"index": 0
}
]
]
},
"RSS Feed - Hagar": {
"main": [
[
{
"node": "Only First Function",
"type": "main",
"index": 0
}
]
]
},
"RSS Feed Read": {
"main": [
[
{
"node": "Only First Function",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {},
"id": "1"
}

This code can also be imported back into n8n if you need to rebuild.. as I did, and all i needed to do was setup the Rocket Chat creds again.

Moving forward

This is just a very high level example of something I was able to quickly knock up and produce without reading the manual or doing any other tutorials, so it is possible to pick this up and do something as a non coder

I've got some additional ideas arount webhooks i'd like to try and will add them here as code examples.

Thoughts

This isn't as consumer friendly as Zaper or IFTTT however it is a very powerful product. Its got a lot of scope for automation or data manipulation. I hope the funding by Sequoia is spent well and the support carries on being friendly.