Setting a msg.topic value in an HTTP IN request

#1

Hypothetical use-case: as a third party client, I want to set a topic for an incoming message from a producer (whether a conventional application/client or another message queue like Kafka) using a webhook/http pattern

How can I set the msg.topic value?

As you're likely familiar, any inbound message POST'd is converted by the Node-RED workflow into the msg.payload body. I have been googling around for any examples of this but none are readily surfacing.

Any thoughts or suggestions?

#2

You can use a change node to set the topic after the http-in.

#3

@TotallyInformation, thanks for the note! Yes, I had set a topic with the function node as well. I am curious if there is a way to set the topic upon the message entering in the Node-RED workflow.

I see the Inject node has this functionality and obviously the MQTT nodes can be set to subscribe to a specific topic from the MQTT queue, so I think this is possible in theory but I am curious how it could be done (like, a special HTTP Header?)

#4

If you mean you want the topic to be set by the incoming message then that would have to be something that the HTTP In node did. Since it is not documented then I assume it does not to do this, so the answer is no.

#5

What about adding a query Param to your http call named topic followed by a change node to set msg.topic?

3 Likes