Skip to content

Sending messages to Telegram users #202

Description

@alaaet

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions