Looking for help with IF/ELSE or checking if something exists before posting

So i am building a Ransomware Blog Scraper that queries a ransomware TOR .onion blog site and extracts names of victims and info and then posts an alert on my infosec page.

One of the issues I am having is some validation checks, so it doesn’t keep posting the same thing over and over. At the moment, its not automated via cron, but it will be once I get this (and one more hurdle completed).

My flow is basically like this:

At the moment I have unlinked it, but normally its linked up.
So I added a “check for existing Wordpress post” node and it looks up the information of the title, this all works fine so far.

Using the IF node it basically says:

IF
Search finds existing post with victim name then do nothing

what I’m missing is

ELSE
if no post is found with the victim title name then continue to post the rest of the results.

Does that make sense?

Here is the post working as an example (need to edit some css of the table still :wink: )

I may have missed something but what happens when you do hook it up and put the creation on the false after checking if the post exists?

The IF node filters out the existing post, for TRUE but then nothing else comes into False, just empty

What are you using as your search options for the GetAll?

Quick edit: I will give it a quick go here.

Maybe i’ve messed up in the IF node…

I’m thinking maybe a merge node

image

Ah I see what you are saying now, So when you go through the If statement you are losing the previous data on the input node.

A Merge with multiplex might be what you are after so something like…

I cut out the rest of what you have and just used a set to make a victm_name variable.

{
  "name": "Wordpress-if-not-exists",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        50,
        300
      ]
    },
    {
      "parameters": {
        "operation": "getAll",
        "returnAll": true,
        "options": {
          "search": "=Xing Ransomware Victim: {{$json[\"victm_name\"]}}"
        }
      },
      "name": "Wordpress",
      "type": "n8n-nodes-base.wordpress",
      "typeVersion": 1,
      "position": [
        390,
        120
      ],
      "credentials": {
        "wordpressApi": "Test"
      }
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"slug\"]}}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        730,
        290
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        870,
        100
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "victm_name",
              "value": "J.Irwin Company"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "mode": "multiplex"
      },
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 1,
      "position": [
        530,
        290
      ]
    },
    {
      "parameters": {},
      "name": "NoOp1",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        860,
        430
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wordpress": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoOp1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Wordpress",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": 2
}```

thats sort of where i am at the moment, think i need to tinker some more, ill have a look at your snippet above, thanks for the help :wink:

I think the only difference is I used the Multiplex option on the merge.

see multiplex is making too much noise, as I have more than just one variable.
image

Can you filter the multiplex?

As it takes my 19 and I know there is one missing(not matched) to 361 and they are all not aligned.
image

Im not sure multiplex is what Im looking for.

Doing an else is so difficult it seem’s, on my integromate scenarios its much easier but i want to move away from that platform.

then if it passes the little filter there before the “Router” node it will carry on.
The filter does this

I’ve got to go out now, but will have to think why i cant get this IF/ELSE to work.

I don’t think it is really an else you are after it is just making the data available from everything later on as you only have 2 conditions it either exists or it doesn’t so an If is enough for that.

Have you tried just using the nodes option at the bottom of the expression builder instead of the input I think that lets you use node data from a previous option.

In my quick test though the multiplex option seemed to add in the string to the post it found, I guess if there is a lot more data to start with it is doing a bit more.

What about using a function to do the check and outputting the data.

You might want to do something like the image below.

1 Like

Nice I’ll give that a go when back at PC. Cheers

I think this is it working now


image

then ran it again after to check and no double post

seems that it working for now, thanks so much for the help with this one guys. I can use this as a template and just change the ransomware blog and pull that.

The only thing I have left to sort is pulling an image and uploading it to WordPress via API, it really doesn’t like you doing that for some reason.

What is the error you are having uploading a file?

Make sure you create another post for the uploading a file question.