Task:
Create a simple API endpoint using the Webhook and Respond to Webhook nodes
Why:
You can prototype or replace a backend process with a single workflow
Main use cases:
Replace backend logic with a workflow
Task:
Merge two datasets into one based on matching rules
Why:
A powerful capability of n8n is to easily branch out the workflow in order to process different datasets. Even more powerful is the ability to join them back together with SQL-like joining logic.
Main use cases:
Appending data sets
Keep only new items
Keep only existing items
This workflow will backup your workflows to Github. It uses the public api to export all of the workflow data using the n8n node.
It then loops over the data checks in Github to see if a file exists that uses the workflow name. Once checked it will then update the file on Github if it exists, Create a new file if it doesn't exist and if it's the same it will ignore the file.
Config Options
repo_owner - Github owner
repo_name - Github repository name
repo_path - Path within the Github repository
>This workflow has been updated to use the n8n node and the code node so requires at least version 0.198.0 of n8n
This creates a git backup of the workflows and credentials.
It uses the n8n export command with git diff, so you can run as many times as you want, but only when there are changes they will create a commit.
Setup
You need some access to the server.
Create a repository in some remote place to host your project, like Github, Gitlab, or your favorite private repo.
Clone the repository in the server in a place that the n8n has access. In the example, it's the ., and the repository name is repo. Change it in the commands and in the workflow commands (you can set it as a variable in the wokflow). Checkout to another branch if you won't use the master one.
cd .
git clone repository
Or you could git init and then add the remote (git remote add origin YOUR_REPO_URL), whatever pleases you more.
As the server, check if everything is ok for beeing able to commit. Very likely you'll need to setup the user email and name. Try to create a commit, and push it to upstream, and everything you need (like config a user to comit) will appear in way. I strong suggest testing with exporting the commands to garantee it will work too.
cd ./repo
git commit -c "Initial commmit" --allow-empty
-u is the same as --set-upstream
git push -u origin master
Testing to push to upstream with the first exported data
npx n8n export:workflow --backup --output ./repo/workflows/
npx n8n export:credentials --backup --output repo/credentials/
cd ./repo
git add .
git commit -c "manual backup: first export"
git push
After that, if everything is ok, the workflow should work just fine.
Adjustments
Adjust the path in used in the workflow. See the the git -C PATH command is the same as cd PATH; git ....
Also, adjust the cron to run as you need. As I said in the beginning, you can run it even for every minute, but it will create commits only when there are changes.
Credentials encryption
The default for exporting the credentials is to do them encrypted. You can add the flag --decrypted to the n8n export:credentials command if you need to save them in plain. But as general rule, it's better to save the encryption key, that you only need to do that once, and them export it safely encrypted.
This n8n workflow demonstrates how to build a simple uptime monitoring service using scheduled triggers.
Useful for webmasters with a handful of sites who want a cost-effective solution without the need for all the bells and whistles.
How it works
Scheduled trigger reads a list of website urls in a Google Sheet every 5 minutes
Each website url is checked using the HTTP node which determines if the website is either in the UP or DOWN state.
An email and Slack message are sent for websites which are in the DOWN state.
The Google Sheet is updated with the website's state and a log created.
Logs can be used to determine total % of UP and DOWN time over a period.
Requirements
Google Sheet for storing websites to monitor and their states
Gmail for email alerts
Slack for channel alerts
Customising the workflow
Don't use Google Sheets? This can easily be exchanged with Excel or Airtable.