# How to connect Telegram with Navixy-IoT Logic.

This is a quick guide of the steps that might be followed to create the connection between IoT logic and Telegram.&#x20;

1\) Create a bot and get your token

* In Telegram, open the chat with @BotFather.
* Run the command /newbot.
* Follow the instructions and copy the bot token provided (it looks like: 123456:ABC-...).

2\) Get the chat\_id you want to message

Common ways to do this:

* Send a message to your bot (or add it to a group and send a message there).
* Then call the getUpdates method from the Telegram API.
* If it’s a group, the chat\_id is usually a negative number.
* Make sure the bot has received at least one message so it appears in getUpdates.

<figure><img src="https://3650643549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIgDb43gtyXcm1Av4h1np%2Fuploads%2F8tPWkDRAgitQjhSQTXxz%2Funknown.png?alt=media&#x26;token=a2176142-fe0e-4bf7-bee5-55e7ca7b2475" alt=""><figcaption></figcaption></figure>

3\) Send the message (REST call)

* Use the sendMessage method from the Telegram API.
* In the request body, include the chat\_id and the message text.
* The request should be sent in JSON format with the header Content-Type: application/json.

<figure><img src="https://3650643549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIgDb43gtyXcm1Av4h1np%2Fuploads%2F3SGFOtW0j9U8nIW4agfb%2Funknown.png?alt=media&#x26;token=c090c3e6-836e-43b0-8bca-c08533f49638" alt=""><figcaption></figcaption></figure>

4\) Create the IoT Flow in Navixy

* Once the flow has been created, connect the Webhook node in the section where you want to send the data.
* Follow the same structure as the API call. In the URL field, place the request endpoint:

<https://api.telegram.org/bot\\>\<BOT\_TOKEN>/sendMessage

* In the Headers section:
* Key: Content-Type
* Value: application/json
* Finally, in the body of the request, include the telemetry parameters you want to send, making sure to include the chat\_id again, for instance:

{

&#x20; "chat\_id": X,

&#x20; "text": "Device 12563254, latitude: {{latitude}}, longitude: {{longitude}}, satellites: {{satellites}}, speed: {{speed}}"

}

![](https://3650643549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIgDb43gtyXcm1Av4h1np%2Fuploads%2FJeLMUhGFDY9HbHrlex1I%2Funknown.png?alt=media\&token=8dd58258-fb16-4dc9-abbc-4ca9a53eaf66)        ![](https://3650643549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIgDb43gtyXcm1Av4h1np%2Fuploads%2FaE6WoDU6yerRsmvyhxv2%2Funknown.png?alt=media\&token=dfdc312d-8f25-429c-916c-cc633ab980e8)

With these steps, your bot will be able to receive messages successfully, including automated telemetry data from Navixy.

<br>
