Experiment: Crowdsourced traffic information

Does anyone have experience with Telegram bots?

In december Telegram released “Voice chat” for groups, which is a very neat feature. This open ups for an idea I’ve had in the idea box for a couple of years: Crowdsourced traffic information :bus: :bike: :red_car: :bullettrain_front: :train: :sailboat: :aerial_tramway:

There can currently be 200 000 people in a Telegram group. The idea is to combine traffic information from P4 and Trafikverket with crowdsourced comments and observations. When something happens in traffic you can report live what you see. I’ve started the experiment here: https://t.me/skjutsgruppen_trafik

:robot: I’m looking into having a bot that publish traffic information from P4 and Trafikverket in the group, and been going through the first steps with BotFather. Seems to be not too difficult: https://core.telegram.org/bots
Anyone got any experience with building or best practices?

2 gillningar

Hi Mattias!

Not answering your question exactly*, but have you thought of faking it with IFTTT? It can post in your group eg relevant info from P4 and Trafikverket feeds. Might be worth it as a first step, to verify the concept.

Not much of a bot developer but I have a paying account on IFTTT, let me know if I can help.

*hate it when people do that, like in this case :grinning:

1 gillning

Hi @giorgos !

That’s a very good idea! As you say, that could work as a proof of concept. I tried it right away. We have an IFTTT account for Skjutsgruppen, but it’s not a paid one so we will see if it makes a difference. I found an IFTTT that sends RSS to a Telegram group, and then found this RSS from P4: https://api.sr.se/api/rss/program/183

Not sure if that’s the RSS link I should use though. So far nothing in https://t.me/skjutsgruppen_trafik . What do you think?

Had a look @mattiasjay and I’m afraid P4’s RSS won’t do. It seems the feed is updated a lot less frequently than the webpage you’re seeing (i.e. most recent item in the feed was from 2 days ago).

This is understandable since there are different pieces of code running here. For the webpage, they are using Trafikverkets API (here), which pulls data every time you load the page. For the RSS, I am guessing they are using some code that runs automatically every e.g. day. This doesn’t make sense in this page, but the RSS infrastructure is probably the same for the whole site.

I think the only reasonable option is to use the API itself. It’s not very difficult but it’s not easy either.

Sorry to be the bearer of bad news - wish I had more time to help you.

Hi,
I made a quick telegram bot that posts traffic related messages in telegram group along with location, map, road, commune, län etc. It takes information from Trafikverket and my own APIs.

Setup a test group with the bot in case anyone wants to see: https://t.me/joinchat/2smwn5YL4Jg2NTA0

2 gillningar

Love it @Sharjeel! Very nice with the maps, this is probably something we can extend further beyond Telegram, with like a simple webpage of traffic reports and some sort of chat.

Also Live Trafik is really great and straight forward. I see that the e-mail on livetrafik.com goes to you, do you work for Sveriges Åkeriföretag? (or SIRT/Trafikverket?)

By the way @giorgos - I found the correct (or slightly correct) RSS for P4 and managed to get it into the Telegram group! It works now! :tada:

Thanks. Yes I work at SIRT and run different sub-projects within Live Trafik in collaboration with others.

1 gillning

That’s awesome @mattiasjay, very cool!

I joined the channel @Sharjeel but how does it work? I haven’t interacted with telegram bots before, and my attempts to coax it to help me, with /help and similar were not successful… :pensive:

1 gillning

I don’t know much about telegram bot either and have never interacted with one before. I made a quick one directional bot with 2 lines of code that just posts new traffic information in the group, right now you can’t interact with it.
I can see maybe it’s possible to subscribe to only information for a selected region/city/road using commands but then it will be either 1vs1 chat or same region for all in the group and it would need bigger backend that listens to user commands.

No worries @Sharjeel , it was just a matter of waiting a bit for the bot to bring reports to my screen :slight_smile: Maybe a pinned post telling people to not worry would be good, but maybe it’s just me :slight_smile:

Some way to filter for region would be nice indeed. As it stands I muted it because it’s too chatty, but it’s still nice to know it’s there when I need it.