Created
January 10, 2020 17:59
-
-
Save samermurad/2f274764e9d7a83f4b8167b39c47b635 to your computer and use it in GitHub Desktop.
Nodejs Request send Telegram Message through a bot
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 requrest = require('request') | |
const BOT_TOKEN = '<YOUR_TOKEN_HERE>' | |
const CHAT_ID = 0 // <YOUR_CHAT_ID> | |
const tmMsg = (text) => { | |
const options = { | |
method: 'POST', | |
url: `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, | |
headers: { 'Content-Type': 'application/json' }, | |
body: JSON.stringify({ chat_id: CHAT_ID, text }) | |
}; | |
request(options, function (error, response) { | |
if (!error) //throw new Error(error); | |
console.log(response.body); | |
else console.log(error); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment