-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send Message without Event #58
Comments
Hi, Hm, this should work fine. Try this code: const TeleBot = require('telebot');
const TOKEN = 'TELEGRAM_BOT_TOKEN';
const USER = 000000;
const bot = new TeleBot(TOKEN);
bot.sendMessage(USER, "Hello!"); To get idea whats going on, let's print server response to console log: bot.sendMessage(USER, "Testing!").then((response) => {
console.log('Ok:', response);
}).catch((error) => {
console.log('Error:', error);
}); |
Hi mullwar Thanks for your fast response, I actually got it working with your code when the full error showed up! Fix: I had to first start the bot in Telegram itself... Thank you! |
Nice! If you have any questions, don't hesitate to ask. Also, you can join to our Telegram community group: https://goo.gl/gXvm12 |
it worked for me. thank you |
Hi mullwar
Many thanks for your awesome API!
I'm trying to use your API to send simple notifications without an event and I'm using following code:
bot.sendMessage(<user-id>, "message");
But I get following error:
(node:5735) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): [object Object]
I've created the bot object as following:
const TeleBot = require('telebot'); const bot = new TeleBot({ token: '<token>, // Required. Telegram Bot API token. webhook: { // Optional. Use webhook instead of polling. key: './cert/key.pem', // Optional. Private key for server. cert: './cert/cert.pem', // Optional. Public key. url: 'https://127.0.0.1', // HTTPS url to send updates to. host: '127.0.0.1', // Webhook server host. port: 88 // Server port. } });
I'm listening via an express server.
Could you help me out?
Thank you very much!!
The text was updated successfully, but these errors were encountered: