24 August, 2023

No-code monitoring solution — real-time bike tracking without a single line of code

Quickly creating a basic yet functional tracking application with flespi and Telegram.

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.

vilnius cycling marathon 2023 map

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:

telegram live location feature

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

telegram create bot

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.

create flespi telegram channel

Then I added this bot into the Telegram group with all the race participants.

telegram group with gurtam racers

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.

flespi subaccount for marathon

flespi webhook to automatically create devices

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:

flespi plugin to delete parameters

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. 

flespi group for devices

flespi webhook to automatically add devices to 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:

flespi token for trackit template flespi acl token config


flespi trackit screen with tracks

Wrapping up

Let’s look back and summarize what we used to make this basic no-code monitoring solution up and running:

  1. A Telegram group of bike riders participating in the race and broadcasting their position
  2. A Telegram bot subscribed to group messages
  3. A flespi channel collecting the messages from the Telegram bot
  4. A subaccount for all newly created devices
  5. A webhook automatically creating new devices upon the first received message from a user in the Telegram group
  6. A plugin deleting text parameters from device messages
  7. 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
  8. A webhook automatically adding newly created devices to the group
  9. A token granting access to read information about devices and their messages
  10. The TrackIt application that serves as a user interface for everyone willing to monitor the position of the rider.

bike monitoring solution diagram

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!