rmed

blog

Zoe, Telegram and transportation

2015-09-05 08:17

These past days I decided I wanted to end my summer holidays (back to university... yaaaay...) doing something cool with Zoe. So now Zoe can communicate through Telegram and has some knowledge on the public transportation system in Madrid (in particular, buses).

Telegram

Obviously, I'm not the first to do this, voiser had already implemented an agent (found here that could connect to the Telegram network in order to send and receive messages. That agent is awesome, but does require a phone number in order to connect. However, not so long ago, the Telegram team released a bot API which, in fact, does not require the additional phone number.

So there I am, wondering if we can implement the bot API in Zoe when I find the pyTelegramBotAPI module, which is really nice, and decide to just go for it. The resulting agent can be found in https://github.com/rmed/zoe-tgbot and is basically the code voiser had written slightly adapted to the bot API (kudos to him).

The agent supports user and group chats (giving preference to group chats when finding an user to respond to), as well as user nicknames, although the agent prompts you to include your unique ID in the users configuration file in order to receive messages from other agents (API limitations...).

I've also updated other agents so that they can relay their feedback messages to either Telegram or Jabber. This is interesting in case other communication methods are added in the future, because the agents are aware of how the dialog was started and will use the same channel when communicating with the user.

Madtrans

I don't have an Android (nor an iPhone, of course) device, therefore I don't really have a Hangouts app (although there are Jabber apps available). By connecting Zoe to Telegram, I can now communicate through my phone, so I thought about adding something I could ask Zoe to do without having to open a browser or installing an additional app.

The zoe-madtrans agent exists purely because I wanted to know how much time I have to wait in the bus stop next to my home for the next bus. Sure, it also includes some additional functionality from the EMT API, but that is purely because I thought "Meh, I may as well include some of these just in case".

The result is an agent that, after a lot of time figuring out how the API works and dealing with (their) server downtime, can do things such as:

  • Telling you how much time you have to wait for the next bus
  • Obtaining schedules for a given bus line
  • Obtaining the number of incidents in a given line
  • Obtaining the route of the line
  • Finding bus stops in X meters from the specified stop
  • Some other things I may have forgotten

So yeah, there's that. Get a Zoe in your life.