Last active
January 29, 2022 08:20
-
-
Save ilamanov/9137b0594c9e6d953f8ff719caf2422d to your computer and use it in GitHub Desktop.
Telegram BOT contant reply
This file contains hidden or 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 TELEGRAM_TOKEN = "..." | |
| export default async (req, res) => { | |
| const chat_id = req.body.message.chat.id; | |
| await respond(chat_id, "Buy Milk") | |
| res.status(200).send({}); | |
| } | |
| async function respond(chat_id, responseText) { | |
| await fetch( | |
| `https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage`, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ | |
| chat_id: chat_id, | |
| text: responseText, | |
| }) | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment