Automation of the document circulation process

Information on your n8n setup

  • n8n version:1.11.2
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Linux

Hello. Trying to automate the process of document circulation when an employee goes on vacation, a business trip, etc…
Briefly, how the system should work: Initial mail (IMAP) - test mail that receives a letter with a specific tag in the subject. If the tag matches what is in the business_trip or vacation condition, then the document goes further down the chain to the next user. The user sees this letter and, depending on how the letter is responded to: agreed - the letter goes further along the chain, if not agreed - the letter goes back to the first sender. Now it is not possible to implement the moment when the document should stop for agreed/not agreed; it immediately tries to go through the entire process.

Hey @KamaR,

Welcome to the community :cake:

I am not sure I fully understand where the issue is here, Can you go into more detail on how something would be flagged as agreed / not agreed?

@Jon, I thought that it would be possible to add an html buttons approved/not agreed to in the letter itself, if possible, and then the letter would go further along the mail chain. For example, after the Initial mail (IMAP) trigger was processed, the letter was sent to the next person in the mail. Then he sees this letter, and in the body of the letter there are buttons: agreed/not agreed. If he clicked agreed, then the letter goes to the next person. If not agreed upon, the letter is sent back to the first sender. This was the first option. Now the second one. Again, after the trigger worked, the letter went to the next person in the mail. He saw this letter and liked everything. He decided to respond to this letter and wrote #agreed in the subject of the letter and the letter went on to the next mail

Hey @KamaR,

welcome to our community.

Its possible to create a workflow to your usecase with the wait node. You can set the wait mode to response webhook like this.

In the email node before you need to create a html with two buttons in it. (I asked ChatGPT to generate it for me :grin:):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Email with Buttons</title>
</head>
<body>

    <p>Dear recipient,</p>
    <p>We would like to get your feedback. Please click on one of the buttons below:</p>

    <!-- Agree Button -->
    <a href="{{ $execution.resumeUrl }}?agree=true" style="text-decoration: none; display: inline-block; padding: 10px 20px; background-color: #4CAF50; color: white; border-radius: 5px; margin-right: 10px;">
        Agree
    </a>

    <!-- Disagree Button -->
    <a href="{{ $execution.resumeUrl }}?agree=false" style="text-decoration: none; display: inline-block; padding: 10px 20px; background-color: #f44336; color: white; border-radius: 5px;">
        Disagree
    </a>

    <p>Thank you for your response!</p>

</body>
</html>

Make sure to reference $execution.resumeUrl as href in the anchor tag. I also added the query parameter agree which can be true or false depending on the clicked button.

This is the email:

In the following if node you need to check the agree query parameter like this:

And then you can just repeat all of this with the next recipients. The url is always $execution.resumeUrl in your send email nodes for the buttons in html.

Cheers.

5 Likes

@nico-kow, Thanks for your help, but have you tried pressing the Agree/Disagree buttons? My clicks are not working

@KamaR
I have tried and it is working.

What is not working like you would expect? Please give more information. What happend in your waiting nodes after clicking one of the buttons? how does the email look like? What is $execution.resumeUrl in your case?

Cheers.

@nico-kow
First, I write a letter to a trigger test email, indicating #vacation in the subject line so that the letter goes further in the process.


The #vacation condition is met and the letter leaves

Send Email1:

I’ll work through the process further:
I reach agreed/not_agreed

Wait:

agreed/not_agreed:

That’s it, the process stops here, the buttons don’t work, although they arrive by email.
Example:

When you say they don’t work, What happens when you click on them?

@nico-kow Perhaps I don’t understand how I can check the agreed/not_agreed node for truth

@Jon

Hey @KamaR,

You need to set the WEBHOOK_URL environment variable so that n8n knows what URL to use that should then remove the localhost option and also fix the other webhook issues you have not ran into yet.

@Jon need to add authentication in wait?

Only if you want it there.

@Jon I don’t quite understand what I should configure WEBHOOK_URL for. Under the email I work with?

Hey @KamaR,

WEBHOOK_URL would need to be to set your domain, once this is set you should then see that n8n will start using your set url for some things.

This is only needed if you wanted users to interact with n8n through webhooks or if you wanted to use oauth for some services.

Hey @KamaR,
WEBHOOK_URL is an environment variable in your installation settings. You told in your first post that you installed n8n with npm. Is it on your local mashine or is it on a server?

It is crucial that the mashine n8n is running on, is reachable for the rest of the internet. At least the email receivers must be able to reach out the n8n instance.

You find the instructions for setting WEBHOOK_URL depending on your installation method over here:

Cheers.

@nico-kow “Is it on your local mashine or is it on a server?” - on a server
Look how I’m trying to do it:
I launch webhook and enter the domain with n8n in the browser field



So maybe I should just pass a link from the browser to the buttons and keep the webhook always on?

Hey @KamaR,
So to make this work (and also the Webhook Trigger node) you need to set the environment variable WEBHOOK_URL to the url you access n8n. Something like:

WEBHOOK_URL=https://yourserver.ru:5678/

Important note!
Your email receivers need network access to your server where n8n is running, otherwise this will not work.

If you have no clue what im talking about it, I would recommend to try the cloud version of n8n. Selfhosting is not that easy and on the cloud version everything will just work as expected.

Cheers.

@nick-kow

I launch the webhook and click on the button agree. Click response:


what should I do next?

the whole process looks like this so far

Hey @KamaR

this problem is not the workflow configuration. You can copy the one i posted yesterday and it will work.

The problem is that your installation of n8n is not configured correctly. Please read the documentation about this:

Please consider switching to the cloud version of n8n, if you don’t understand what my message is about. You could also ask for professional (paid) help to install your n8n instance properly.

Cheers.