Wazy is a bot based on Telegram bot that allows checking travel times using Waze.
wazy.mp4
- Check current route travel time.
- Set interval for route travel time checks.
- Get waze navigation url that opens in the application.
- Set maximum travel time and get warning is the travel time exceeds the maximum.
- Configure default rout.
- Configure list of routes.
- Configure addresse.
- Rest API to integrate with other applications/systems.
- Loguru For logging.
- FastAPI For REST API.
- WazeRouteCalculator For interacting with Waze.
- pyTelegramBotAPI For the Bot.
- schedule For scheduling route checks.
Before we can start working with Wazy, we need to create a new telegram bot.
How to Create a New Bot for Telegram Open Telegram messenger, sign in to your account or create a new one.
Enter @Botfather in the search tab and choose this bot (Official Telegram bots have a blue checkmark beside their name.)
Click “Start” to activate BotFather bot.
In response, you receive a list of commands to manage bots. Choose or type the /newbot command and send it.
Choose a name for your bot — your subscribers will see it in the conversation. And choose a username for your bot — the bot can be found by its username in searches. The username must be unique and end with the word “bot.”
After you choose a suitable name for your bot — the bot is created. You will receive a message with a link to your bot t.me/<bot_username>, recommendations to set up a profile picture, description, and a list of commands to manage your new bot.
Wazy is a docker based application that can be installed using docker compose:
version: "3.6"
services:
wazy:
image: techblog/wazy
container_name: wazy
restart: always
ports:
- "8081:8081"
environment:
- LOG_LEVEL=DEBUG
volumes:
- ./wazy:/app/config
- LOG_LEVEL - Optional valuse are: DEBUG (default), INFO, ERROR
In order to adapt Wazy to the needs of the user, several things must be defined such as addresses, routes and Telegram API key. Inside the config folder there is a file called config.ini where you can define the necessary parameters for the bot to work.
In order to enable integration with other systems, Wazy is also accessible via Rest API. In order to allow access, the port must be defined in the docker-compose file. The default port is 8081.
Wazy can be easily using the config.ini file. by default this file is empty and created on first system start. you can also copy the following content and to new file inside the config folder prior to the containr startup.
[Telegram]
bot.token=
bot.allowedid=
bot.welcome.message=Hi, my name is Voicy
bot.enabled=False
[WAZE]
route.avoid_toll_roads=False
route.avoid_subscription_roads=False
route.region=IL
route.start_address=
route.end_address=
route.max_duration=20
routes=['work2home','home2work']
address=['home','work','school','parents']
[work2home]
route.avoid_toll_roads=False
route.avoid_subscription_roads=False
route.start_address=
route.end_address=
rout.max_duration=20
[home2work]
route.avoid_toll_roads=False
route.avoid_subscription_roads=False
route.start_address=
route.end_address=
rout.max_duration=20
[ADRESSES]
address.home=
address.work=
address.parents=
address.school=
-
Telegram:
- bot.token: Bot token generated in installation section.
- bot.welcome.message: Bot welcome message when clicking the start command.
- bot.enabled: Enables or Disables the bot. default is set to disabled.
-
Waze:
- route.avoid_toll_roads: When true, the waze route calculator will avoid toll roads.
- route.avoid_subscription_roads: same as above but for subscription roads.
- route.start_address & route.end_address: setting the default toute to check.
- routes: List of routes that can be monitored.
- address: List of addresses that can be set as start and end for routes.
-
work2home and home2work - example of pre-configured routes:
-
ADDRESSES: Pre-configured addresses that can be set as route start and end points.
As I mentioned, working with Wazy is also possible using the Rest API. API documentation can be found by adding /docs to the server address. For example http://wazy:8081/docs.
-
"/route/get": Get travel time for route between addtesses:
- from_address: can be any addres, like "Raanana, Israel"
- to_address: can be any address, like "Tel aviv, Israel"
-
"/route/default": Get travel time for default route that was configured in the config.ini file.
-
"/route/byname" : Get travel time for route by it's name.
-
"/route/locations": Get travel time between to addresses taken the configuration file ander [ADDRESSES] section.