Exemplo de código em python que responde à mensagens do telegram

import os
import json
import requests
import functions_framework
 
family_users = {
    'my-telegram-username',
}
 
@functions_framework.http
def webhook(request):
    # Extract the message from the incoming request
    request_json = request.get_json()
 
    print('REQUEST:', request_json)
 
    msg = request_json.get('message', {})
 
    prefix_msg = ''
    msg_from = msg['from']['username']
    if msg_from in family_users:
        prefix_msg = 'Olá! vc é especial! Me enviou a msg: '
 
    message = prefix_msg + msg.get('text', '')
    chat_id = request_json['message']['chat']['id']
    
    bot_token = os.environ["TELEGRAM_TOKEN"]
 
    # Send a reply message to the Telegram bot
    url = f'https://api.telegram.org/bot{bot_token}/sendMessage'
    payload = {'chat_id': chat_id, 'text': message}
    response = requests.post(url, json=payload)
    
    return response.content