Created
August 9, 2019 00:40
-
-
Save chengsokdara/a036e01467527ca5a051c9fe6a6885c2 to your computer and use it in GitHub Desktop.
Telegraf Firebase Cloud Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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