We have a Telegram bot that notifies our users of Traccar events, but as Traccar is only one source out of a few that provide events, and also provides other functionality, our solution is probably a bit complex.
Probably the best way is to use the Traccar API as the data source for your bot.
Hello,
thank you, just to get it right. I have the telegram bot running, but I don't see a way to have different bot for different users. Of course, I don't want to share the notification with my friends. A workaround might be, that they use the mail notification, sending a message to a push service like prowl.
About the API, thanks to the hint, have not dealt with this, yet. Are there examples?
Regards, Tomte.
Google for the API, you will find examples. We use it from Python.
First pick your language environment for the bot. Most bot examples are language (and library) dependent. We use Python, Redis, and Postgresql for our bot / system.
You don't want a different bot for different users. You could use a Channel to which your users could sign up, and send messages to that channel. We tried that, it's fine for broadcast, but not much for fine-grained messaging.
WHat we do instead, is let users add our bot (you can provide a URL or QR code to make it easier), and then there is a /register command that they use to register to their particular vehicle that we created.
We validate that request and then create the link in our own DB. One prime reason to do this is that it's the easiest and most consistent way to get their chat id, which you need to be able to directly receive from and send messages to the user
First attempt was using standard /command style buttons (reply_markup paramenter in the bot send text will create the buttons), or entering /reg command with the group or vehicle id as the target.
Busy doing a new service for a different solution now, which is more conversational.
For example
The conversational examples and the associated libraries I found via Google are often outdated / incomplete / not too understandable.
So instead I used Redis to manage the conversation state. This made things much simpler.
I am also using redis as a performance mechanism and to break up the bot into different modules. For example, some commands will be processed directly in the receiving function, receiving functions will encode the necessary information into a Redis queue, which is then monitored by a separate Python module for further processing. In it's turn, it may write to yet another Redis queue (for example long running reports) to be picked up by yet another module.
If you are interested I can provide you some tips.
We are using Python to do the work, against a Postgresql database: be very careful which Python libraries you choose, as many that you will find in Google examples are not actively maintained or widely used.
Regards
Hello,
I have some friends on my traccar server. Can they get there individual notifications for geofences, e.g. via telegram? How could I define for each user a different telegram bot or something like that, please?
Regards, Tomte