-
Notifications
You must be signed in to change notification settings - Fork 2
Receiving Updates by Webhook
Alper Kürşat edited this page Feb 14, 2022
·
1 revision
@botocrat/express allows creating express middleware to receive POST requests from telegram.
Library removes existing webhook and creates new webhook via client once you start express server (by .listen(port)
)
// /middlewares/bot.js
import createMiddleware from "@botocrat/express"
import bot from "../bot.js"
import client from "../client.js"
export default createMiddleware({
bot, client,
url: "http://botocrat.myfancybotdomain.com/" + BOT_TOKEN,
})
// index.js
import botApp from "./middlewares/bot.js"
import express from "express"
express()
.use("/" + BOT_TOKEN, botApp) // plug middleware
.get("/", (req, res) => {
res.send("This is an express server.")
})
.listen(80)