# Use TTN payload as a GPS message in Telegram

**URL:** <https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003>\
**Category:** General\
**Tags:** telegram\
**Created:** [2 March 2023 16:28 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003 "2023-03-02T16:28:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prilex](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@Prilex](https://discourse.nodered.org/u/Prilex)\
**Post date:** [2 March 2023 16:28 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/1 "2023-03-02T16:28:47Z")

</div>

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!

 ![nodered](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/90be47499618747d40d3cf1fb0ac9e257533c426.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [2 March 2023 16:33 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/2 "2023-03-02T16:33:38Z")

</div>

> [@Prilex](#):
>
> I don't know who to format the TTN payload to use it as a location message in the Telegram node

It is documented in the [readme](https://www.npmjs.com/package/node-red-contrib-telegrambot) (search the document for "location")

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

---

<div class="post-metadata">

**Author:** ![Prilex](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@Prilex](https://discourse.nodered.org/u/Prilex)\
**Post date:** [2 March 2023 16:40 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/3 "2023-03-02T16:40:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [2 March 2023 16:43 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/4 "2023-03-02T16:43:39Z")

</div>

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"

---

<div class="post-metadata">

**Author:** ![Prilex](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@Prilex](https://discourse.nodered.org/u/Prilex)\
**Post date:** [2 March 2023 16:59 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/5 "2023-03-02T16:59:01Z")

</div>

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

 ![node3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/8/f8cc164f0af7ce8b7b92fbdf4af78b39f5f85a76.png)

In "function 3" I use this code to give Telegram node all the necessary info:  
 ![node4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/8292a19268d30342024f5fbdb503b6e8946c091f.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [2 March 2023 17:01 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/6 "2023-03-02T17:01:55Z")

</div>

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](https://nodered.org/docs/user-guide/messages)) 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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<div class="post-metadata">

**Author:** ![Prilex](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@Prilex](https://discourse.nodered.org/u/Prilex)\
**Post date:** [2 March 2023 17:10 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/7 "2023-03-02T17:10:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 March 2023 17:10 UTC](https://discourse.nodered.org/t/use-ttn-payload-as-a-gps-message-in-telegram/76003/8 "2023-03-16T17:10:25Z")

</div>

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