-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetWebhook.js
More file actions
27 lines (23 loc) · 827 Bytes
/
setWebhook.js
File metadata and controls
27 lines (23 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const axios = require('axios');
require('dotenv').config();
const token = process.env.TELEGRAM_BOT_TOKEN;
const url = `https://${process.env.VERCEL_URL}/api/telegram-bot`;
const setWebhook = async () => {
try {
const response = await axios.post(`https://api.telegram.org/bot${token}/setWebhook`, {
url: url
});
console.log('Set Webhook Response:', response.data);
} catch (error) {
console.error('Error setting webhook:', error);
}
};
const getWebhookInfo = async () => {
try {
const response = await axios.get(`https://api.telegram.org/bot${token}/getWebhookInfo`);
console.log('Webhook Info:', response.data);
} catch (error) {
console.error('Error getting webhook info:', error);
}
};
setWebhook().then(() => getWebhookInfo());