Use TTN payload as a GPS message in Telegram

Hi forum,

I'm starting learning node-red for an Arduino project. I have an MQTT node that receives the TTN (The Things Network) data, another one that send messages to Telegram (using a bot) with the information of the previous function. The Arduino project I said send the GPS data to TTN every some seconds.

The issue, I have, is because I don't know who to format the TTN payload to use it as a location message in the Telegram node. I add a photo of my flow.

Thanks for the future help!

It is documented in the readme (search the document for "location")

Also, checkout the built in examples (CTRL-I -> examples -> node-red-contrib-telegrambot)

Thanks for that fast reply!

I already send a location to Telegram, but my problem is sending the location received by TTN. I add the path for "latitude" and "longitude" variables:

payload.uplink_message.decoded_payload.lat
payload.uplink_message.decoded_payload.lon

So you get "something" from MQTT and you need to reformat it into the correct format for telegram right?

So, you need to show us what you get in "debug 1" and then you need to tell us how you want it to look AFTER "function 3"

This is all what I get from TTN (MQTT):

In "function 3" I use this code to give Telegram node all the necessary info:
node4

in a function node, the incomming data is ALWAYS contained in the msg object

therefore, you should use msg.payload.x.y.z

Also, since the values you want are in odd named variables, you will need to use square bracket notation to access them - OR - use the tools provided (i.e. copy the EXACT path without mistake) see below...

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

I already solved the issue so thanks, Steve, for your fast help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.