27 February, 2018

Instantly get your Telegram messages to flespi and beyond [UPD: Feb 13, 2020]

Telegram channel in flespi can collect messages and shared locations from your account and forward them to Wialon via a bot.

telegram unterpretation


You would probably give more than one interpretation of the word “telegram.” Here in Belarus we still have some post offices with telegraph equipment. My grandparents often receive telegrams with birthday greetings from their friends living in other towns.

We’ll be talking about a more advanced Telegram today — a super fast and secure messenger. flespi team has recently added the telegram type of channel to the flespi telematics hub to instantly transfer Telegram messages into the flespi platform and then to a destination of your choice (and back).

How to send messages from Telegram to flespi

1. Create a Telegram Bot

  • Start a chat with BotFather Telegram bot

  • Type /newbot and choose the name and username for your bot

  • Copy the bot’s access token. You’ll need it to configure a flespi channel.

create telegram bot

2. Set up a telegram channel in the flespi panel

  • create a new channel

  • select the telegram protocol_id

  • insert the bot’s access token from the previous step

configure flespi channel for telegram

3. Check how it works

  • open a chat with your newborn baby-bot
  • type /start
  • share your location or send text messages
  • check the delivery of the messages in the channel’s toolbox

check in toolbox how telegram messages come to flespi

Note: the ident field in flespi messages corresponds to the Telegram client’s name. You can hide the ident string in the bot’s welcome message or edit it in the channel settings.

How to send messages from Telegram to Wialon

We have a special WialonHostingBot for Wialon users. Just create a unit of the flespi gateway type as described here and use your Telegram ID as the Unique ID for the Wialon Hosting unit. Messages and location will start coming from your Telegram messenger straight to this Wialon Hosting unit.

Alternatively, you can use your custom bot created via BotFather.

How to send messages from flespi to Telegram

  • You can send messages back from flespi to a Telegram user via the telegram channel command.

    Here's the REST API  request to perform this:

    curl -X POST --header 'Authorization: FlespiToken Your_flespi_token' -d  \
    "properties":{"text":"Hello, flespi user!"},"ttl":86400}]' \

    Don't forget to replace Your_flespi_token, 'Hello, flespi user', and '1234' with the real values of your flespi token, desired text to send, and the telegram channel id respectively.

    Note: your Telegram bot should have an existing conversation with the target Telegram user within the last year.

  • It is now also possible to send a setting with a message to the Telegram-type device via the flespi panel GUI or respective API call.

    To do so, you have to create a flespi device of the telegram device type. Use the ID issued by your bot as a User identifier:

    create telegram flespi deviceOnce created, navigate to the Settings tab on the device screen and find the "Send a message to the user" setting in the Actions section:

    send message from flespi to telegramType the message and click the Send icon to get it in your Telegram bot.

How to send messages from Wialon to Telegram

To send messages from Wialon to your Telegram bot, create a unit of Telegram (flespi) device type and specify the ID issued by the Telegram bot as a Unique ID:

telegram type unit in wialon

Then, create command on the Commands tab in the Wialon unit settings:

create telegram command in wialon

Configure the command; type the desired message, click Apply, then click OK:

send command from wialon

And there we have it:

message from wialon in telegram

How can it be so fast?!

Telegram channel has an optimal structure — every channel sends a polling request to the Telegram API and imports a message into the flespi storage system as soon as it appears in the Telegram services. Toolbox tracks the channel events via fast MQTT, so you see the message on your screen an instant after it arrives at the flespi platform.

fast telegram message delivery to flespi

It’s still magic to me. How can data travel from my phone to the Telegram server, then to our servers in the Netherlands, then back to my laptop again in less than a second! Almost instantly! You don’t even have time to switch from a smartphone to a laptop screen, and the data is already there. Try it — it’s impressive!