Automatically translate this page?
27 February, 2018

Instantly get your Telegram messages to flespi and beyond [UPD: Mar 12, 2019]

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 to 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.

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 flespi to Telegram

Now you can not only send messages and location from Telegram to flespi via a telegram channel but also 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  \
'[{"address":{"ident":"<telegram-username>","type":"connection"},"name":"message",
"properties":{"text":"Hello, flespi user!"},"ttl":86400}]' \
'https://flespi.io/gw/channels/1234/commands-queue'

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.

How to send messages from Telegram to Wialon

We have a special WialonHostingBot for Wialon users. Just create a unit of 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.

create wialon unit of flespi_gateway type to get telegram messages

How can it be so fast?!

Telegram channel has an optimal structure — every channel sends a polling request to the Telegram API and imports 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 smartphone to laptop screen, and the data is already there. Try it — it’s impressive!



Get the latest updates and monthly newsletters from flespi in your inbox

Get data in your platform via flespi HTTP stream

Sample scripts to deploy on your server to receive the telemetry data from the flespi platform.

11 December, 2018 | flespi features | Jan Bartnitsky

Jasper modem in flespi — a cheaper way to send SMS using ICCID

Using Jasper API to send text messages to configure tracking devices from flespi.