This year, Vilnius — the capital of Lithuania and the HQ of Gurtam — celebrates its 700th anniversary and holds numerous cultural and sports events in this regard. One of the events was the cycling marathon, during which hundreds of bike-lovers were riding the central streets of Vilnius for fun, for health, or even for a prize.
I and my Gurtam colleagues decided to team up and enjoy the event together (since we didn’t intend to compete for any prizes). But since we live in different parts of Vilnius and getting together in a crowded downtown could become a challenge.
However, modern technologies, such as Telegram, can greatly simplify this task. Telegram lets chat members broadcast their real-time location and see each other on a single map. Finding and meeting friends is becoming so much easier:
There’s one problem though — Telegram cannot record tracks and I wanted to be able to share this event, so that our friends who didn’t participate could watch our ride. Well, luckily, one of us (me) appeared to be a developer and a flespi fan;)
Collecting data
What I did first is created a Telegram bot and tied it to the flespi channel with the proper protocol.
Hint: you can use any supported GPS tracker and the respective channel instead of Telegram.
Then I added this bot into the Telegram group with all the race participants.
After that, I gave the bot permissions to view group messages and asked all my colleagues to broadcast their location during the race.
Since messages from all participants come to a single Telegram channel, it becomes difficult to track each bike separately. To fix that, I created a subaccount and a webhook that will automatically create devices in this subaccount.
Showing the track
I used TrackIt to show the track and the real-time location on the map.
Hurdle: Since our Telegram group was used not only for location sharing but also for usual text communication, it was necessary to filter out messages and only give TrackIt position data to show. For this purpose, I created an msg-erase plugin that automatically deleted parameters with text messages:
Remember, that we have a webhook that automatically creates devices? We could also automatically assign the above plugin to each of the devices (also via webhook), but… I wasn’t sure if I want to add something else (e.g. another plugin), so I decided to assign the plugin not directly to the device but to the group and simply add devices to the group.
With a group, assigning anything else to fine-tune or develop a solution further (e.g. a calculator, a plugin, a stream) becomes super-easy — once you assign an instance to the group, it applies to all devices in the group.
Sharing access
The solution is already operable, but the idea was to give others access to view information about the devices and see the track in TrackIt. We need to create an ACL token for that:
Wrapping up
Let’s look back and summarize what we used to make this basic no-code monitoring solution up and running:
- A Telegram group of bike riders participating in the race and broadcasting their position
- A Telegram bot subscribed to group messages
- A flespi channel collecting the messages from the Telegram bot
- A subaccount for all newly created devices
- A webhook automatically creating new devices upon the first received message from a user in the Telegram group
- A plugin deleting text parameters from device messages
- A group of devices with the above plugin assigned to it gives an easy way to grow and extend functionality by assigning other plugins, calculators, and streams once needed
- A webhook automatically adding newly created devices to the group
- A token granting access to read information about devices and their messages
- The TrackIt application that serves as a user interface for everyone willing to monitor the position of the rider.
All in all, we’ve created a simple but functional bike tracking application without a single line of code using only flespi and Telegram!
We hope it can serve a great starting point for your new projects. Try, explore, invent!