Skip to content
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

Sending messages to Telegram users #202

Open
alaaet opened this issue Jun 21, 2024 · 0 comments
Open

Sending messages to Telegram users #202

alaaet opened this issue Jun 21, 2024 · 0 comments

Comments

@alaaet
Copy link

alaaet commented Jun 21, 2024

I would like to see if there are other people interested in adding more channels, in this case I believe that Telegram would be nice to have, please upvote if you are interested

Issue:

Telegram is not recognized as a channel.

Suggestion:

I used a library called node-telegram-bot-api to actually send the message to a telegram user and added it as a custom provider to the configuration of NotifmeSdk, the problem I noticed is that telegram is not a recognized channel, but if you give it recognized channel name (ex: email, sms, voice...etc) it will work, but this is not a good solution.

how to send a message to a telegram user?

  • You should start by creating a bot in telegram, there are several ways to do it, I used the 'Botfather' provided by telegram, which as you can imagine is a bot to create your custom bots.
  • Save the token that you are provided with as it will be the way to identify your bot in the code.
  • Initialize your library with the token
  • The user should initialize a conversation with your bot
  • This will expose a chatId that you can use later to send messages later
bot.on('message', (msg) => {
  const chatId = msg.chat.id;
  contactName = msg.chat.name // supposing you are storing this variable somewhere
    console.log(chatId)
});
  • Knowing the chat id, now you can send back messages to your subscribed users
    bot.sendMessage(chatId,Hi ${contactName}!);

Limitations

  • first issue is as mentioned earlier, telegram as a channel does not exist
  • the user should initiate contact with your bot before you can send any messages to them.
    The first point is the focus of this issue, the second is just how telegram works.

Solution

add telegram as a channel type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant