Triggers and Custom Channel

Describe the problem/error/question

I would to use channel with triggers, in particular Posgresql triggers, to not listen all update events for example (otherwise, my workflow loops)
I was able to find the documentation on how to listen on the channel (it is easy), but no documentation on how to generate an event on th right channel for Postgresql
For example, how to make an update in Posgresql with a specific channel?

If you have information abour that, it will be great

Information on your n8n setup

  • **n8n version: 1.27.3
  • **Database (default: SQLite): Postgresql
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • **Operating system: Debian

Nobody knows how to manage triggers in postgresql?

Hey @ppcm,

From what I understand a channel is just a named notification channel on a table so you may not need to change anything, Looking at the postgres documentation though they do mention a pg_notify option.

Hello @Jon
Thanks for the answer

This is what I understood too. But my question is how to change the channel name (without a custom request to Postgresql)

I saw different posts about that, like this one

But nothing on how to change the name of the channel. If we can not change it throw a standard node like Update or Insert, it is not real useful

So I can’t imagine it is not possible
Thanks for your help

Hey @ppcm,

The channel name is set by the trigger node when it starts the listen, if you want to change the channel name you would need to do it in the trigger node then it will connect using the new channel name to listen for events.

Hello @Jon,

Thanks for that point
But how to tell to an update (for example) to send the notification to a specific channel?

In that way, the trigger listening on the right channel will receive the message

Hey @ppcm,

It should be automatic as the event channel is notified by Postgres, As mentioned earlier though Postgres does seem to have a pg_notify() option that you might be able to use as well but for that you would to dig through the postgres docs as that is outside of n8n.

Thnaks @Jon,

I was afraid about that, it’s mean that I need to make a request manually for an update (for example) and fire a postgres event

It is sad, because the postgres node fire this event by itself, and the parmater for the channel is missing

perhaps a feature to add…

Hey @ppcm,

Does an insert on it’s own not notify the channel automatically? From what I understand there shouldn’t be a need to manually fire an event on a channel as Postgres should just handle it.

This is the sort of thing I would need to take your guidence on as I would assume you have the knowledge on how Postgres works, We just make the nodes that interact with the specification / api provided.

Hello @Jon,

The idea of my question is not to find a tricky solution to send an event on a specific channel after an insert in Postgres, because there is no way for that. The goal is to add an option in insert, update, select, … of Postgres node to fire events without a painful way to write everything with our little fingers

For example, here we have a trigger which listen on MyTrigger channel. There are 2 nodes, one inserts data in database and the second fires an event
In the second node, I need to write all fields to fire a good payload, and it is painful because, the node need to be adapted on each situation, and it is frustrating because it could be done automatically

If, in the insert node, we have an option to select a trigger (because we know all triggers) or to write a trigger name (it is easier to implement), we could collect data from the insert node in a payload and fire an event like it is done in the second node

It will offer lot of possibilities to communicate between workflows on an easy way

What do you thing about that?

Hey @ppcm,

I take it then that Postgres does not automatically just post these updates and what you are actually after here is a feature request to add the Notify option?

Hello @Jon,

Finally yes, the question around the existence of a feature becomes a request for a new feature :slight_smile:
In my mind, the biggest part of the work was done in the Postgres node, the Notify option should not be a big work - but I am perhaps wrong…

Thanks for your help

Hey @ppcm,

I have moved this to feature requests so we can work out how popular this would be.

1 Like