Skip to content

Instantly share code, notes, and snippets.

@chengsokdara
Created August 9, 2019 00:40
Show Gist options
  • Save chengsokdara/a036e01467527ca5a051c9fe6a6885c2 to your computer and use it in GitHub Desktop.
Save chengsokdara/a036e01467527ca5a051c9fe6a6885c2 to your computer and use it in GitHub Desktop.
Telegraf Firebase Cloud Function
const functions = require('firebase-functions');
const Telegraf = require('telegraf');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
const bot = new Telegraf(functions.config().bot.token);
bot.command('test', ctx => {
ctx.reply('Test');
});
exports.telegramBot = functions.https.onRequest((request, response) =>
bot.handleUpdate(request.body, response)
);
// After deploy seWebhook manually
// https://api.telegram.org/bot[BOT_TOKEN]/setWebhook?url=https://us-central1-[FIREBASE_PROJECT_ID].cloudfunctions.net/[FUNCTIONS_NAME]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment