How to use the IF statement with Notion database?

I just started with the n8n this week to automate a task in my Notion database.
I’m trying to make simple bot to see what is in my task list on Notion.

The objective is simple:

  • I send “/hoje” and the bot returns the tasks to today. If there are no today’s tasks I get a congratulation message.
  • I send “/semana” and a get the task for this week. If there are no more tasks to this week, I get a congratulation message.
  • I send “/atraso” and I get the late tasks. And also if there are no late tasks I get a congratulation message.

The problem with the IF Statement

And I can get the first part of all commands, if my “IF statement” return positive, but I can’t get an answer if there is no task.
I tried many ways to make this work, but I still don’t get a response.
I ready a lot of pages of tutorials on internet, but nothing helped me to understand how works the “IF” in n8n.
Right below you can see my workflow and someone knows how to make it works properly, please help me.
It’s just a personal use bot, but I realy want to make this work.

My workflow


Notion tasks to today exists:

Telegram Return

Notion tasks to today don’t exists:

No Telegram Returns

  • Running n8n via [desktop app]:

Hey @brazillucas,

Welcome to the community :tada:

Apologies in delay in the response. Were you able to solve this? If not, please let us know :slight_smile:

Hello @harshil1712 ,

thank you :slight_smile:

Unfortunately, I has not solved the question. I don’t understand how can I use the if statement to send the else answer.

Can you help me with this?

Hey @brazillucas,

If I understand it correctly, you want to return a default message if an unknown command is entered. Is that correct?

One small change that I’ll make to the workflow is to replace the IF nodes with a Switch node. This will reduce the complexity of the workflow. I’m sharing the updated workflow:

Hope this helps :slight_smile:


Hello again, @harshil1712,

I tried change and that worked pretty well in the first statement, thank you.

But I have a doubt yet: how can I treat the data received from the “NotionHoje” node in a switch?
Because I tried several ways and I can’t send a Telegram Message if none Notion’s item has return from “NotionHoje”.

My intention is to send a specific message if I have no task for today. Or to send a message with a list of items (the tasks) if I have at least one task for today.