How it looks:

https://drive.google.com/file/d/1gTlt25-f9ltKrNbV9BVhPg_DY63BS6kE/view?usp=sharing

WhatsApp Image 2023-05-01 at 22.26.23.jpg

WhatsApp Image 2023-05-01 at 22.15.17.jpg

Final general design:

telegramchat2.png

About Implementation:

Telegram bot was created by talking to the BotFather bot through the Telegram app. It allows you to assign a unique identifier, in this case defined as @BikesPolito bot, and provide an API token, Telegram API requirement. It uses Telebot as its main library to implement all functions and retrieves data from MongoDB collections: ”Bike Count” provides real-time rack state, ”Forecasting” provides predicted values, and ”Racks” provide localization, that is, longitude and latitude.

It allows users to select their preferred language, English or Italian, show zones they can go to find a rack, and once they select one, provide current and predicted free slots for available racks in the corresponding zone. Users can decide where to go based on the number of free slots. Once they select the rack, the bot provides the precise location on an embedded map.

Tutorials:

Creating chatbot and connecting with server:

How To Create A Telegram Bot With Python

# Example initial code

import telebot
import requests
from urllib.parse import urlencode

# Google Maps API settings
GOOGLE_MAPS_API_BASE_URL = 'https://maps.googleapis.com/maps/api/geocode/json'
GOOGLE_MAPS_API_KEY = 'AIzaSyBxcPtKP8h6Mc9kKXutehNPgfmQLLClJ0A'

# create bot
bot = telebot.TeleBot(API_KEY)

@bot.message_handler(commands=['Greet'])
def greet(message):
    bot.reply_to(message, "Hey, How's it going?")

@bot.message_handler(content_types=['text'])
def get_location(message):
    # send request to Google Maps API to get location coordinates
    params = {
        'address': message.text,
        'key': GOOGLE_MAPS_API_KEY,
    }
    url = f'{GOOGLE_MAPS_API_BASE_URL}?{urlencode(params)}'
    response = requests.get(url).json()
    
    # check if API response is successful
    if response['status'] == 'OK':
        # extract latitude and longitude from response
        lat = response['results'][0]['geometry']['location']['lat']
        lng = response['results'][0]['geometry']['location']['lng']
        
        # generate Google Maps URL with location coordinates
        maps_url = f'https://www.google.com/maps/search/?api=1&query={lat},{lng}'
        
        # send location message to user
        bot.send_message(message.chat.id, f'Location of {message.text}: {maps_url}')
    else:
        # send error message if API response is not successful
        bot.send_message(message.chat.id, 'Error getting location. Please try again.')
    
bot.polling()

To send emojis:

https://unicode.org/emoji/charts/full-emoji-list.html

Additional notes:

https://core.telegram.org/bots/api

Some references:

Untitled

Untitled