Value to MQTT Topic

I'm sure this is some type of newb thing.

picture

I am sending a message to the Telegram reciver node via telegram. If this message has a fixed content, the function node should pass a string with "1" to the mqtt out node. However, I always get the following error message.

picture2

But if i try to inject a string that contains "1" manualy using the inject node, it works fine. I dont know what to do about it.

Put a debug before the function. What is going into it?

Copy and paste the function code

```
like this
```

Can't help otherwise!

Edit ...

A guess, you are not returning an object at the end of the function...?

Here you can see the output from the debug:

picture3

The function contains this code here:

if (msg.payload.content=="1")
msg.payload = "1";
return msg.payload;

In the function node you want to return msg not msg.payload

If I change it the way you suggest, I get this error again:

picture4

The code inside the function now looks like this:

if (msg.payload.content=="1")
msg = "1";
return msg;

Any message returned by function node should have at least this structure:

return { payload: "1" }

Which will create new msg object with payload property set to string "1".
If You want modify and return the original msg then:

msg.payload = "1"
return msg

So in Your case:

if(msg.payload.content === "1")
   msg.payload = "1"
else
   return // this will break the flow, and send nothing to the output

return msg

Have a good read of the node red doc Working with Messages, a little time spent doing that will save you many hours very quickly. Also look through the other documents, Writing Functions in particular.
https://nodered.org/docs/user-guide/messages

Okay, I have tried out all of your suggestion. With this help it works as intended. Thanks for every comment.