I reply to myself, I succeeded to make it work. The \n was missing in the payload before sending it back to the gateway. This took me months to see this... Works like a charm now, I just need to implement the inclusion feature in NodeRED.