import { Request , Response } from 'express' ; import { Telegraf } from 'telegraf' ; const { BOT_TOKEN , FUNCTION_NAME , PROJECT_ID , REGION } = process . env ; if ( BOT_TOKEN === undefined ) { throw new TypeError ( 'BOT_TOKEN must be provided!' ) ; } const bot = new Telegraf ( BOT_TOKEN ) ; bot . telegram . setWebhook ( `https://${ REGION ! }-${ PROJECT_ID ! }.cloudfunctions.net/${ FUNCTION_NAME ! }` ) ; bot . command ( 'hello' , ( ctx ) => ctx . reply ( 'Hello, friend!' ) ) ; export const botFunction = async ( req , res ) => { try { await bot . handleUpdate ( req . body ) ; } finally { res . status ( 200 ) . end ( ) ; } } ;