0

How can I send messages to users via their number? I saw this site http://notificatio.divshot.io/ , but there is no way to delete its references in the messages.

Eliana
  • 395
  • 3
  • 10
  • 20
  • Hi! Just write to support@notificatio.me with subject: "Delete references please [StackOverflow]". – Ilia P Sep 09 '15 at 01:34

1 Answers1

4

You can make use of the Telegram Bot API, it is an easy to use HTTP interface to the Telegram service. Use their BotFather to create a bot token. JavaScript (NodeJS) usage example:

var TelegramBot = require('telegrambot');
var api = new TelegramBot('<YOUR TOKEN HERE>');

// You can either use getUpdates or setWebHook to retrieve updates.
// getUpdates needs to be done on an interval and will contain all the 
// latest messages send to your bot.

// Update the offset to the last receive update_id + 1
api.invoke('getUpdates', { offset: 0 }, function (err, updates) {
    if (err) throw err;
    console.log(updates);
});

// The chat_id received in the message update
api.invoke('sendMessage', { chat_id: <chat_id>, text: 'my message' }, function (err, message) {
    if (err) throw err;
    console.log(message);
});

The example makes use of a NodeJS library I have used for my projects.

In order to start a conversation with a user, you can use the deep-linking feature. For example, you can put a link on your website like so:

https://telegram.me/triviabot?start=payload (payload being a custom variable value if you want to use one, like an auth ID etc)

Following that link will prompt the user to launch the Telegram App and add bot into the contact list. You will then receive a message via the getUpdates() call with the chat_id for that user. This chat_id you can then use to message the user whatever you want. I don't believe it's possible to send a message to a mobile number using the Telegram Bot API, they only work with chat_id's as this is a mechanism to protect Telegram users from being spammed by marketing bots...that is what you need to initiate the conversation with the bot first.

Chris Brand
  • 1,962
  • 16
  • 9
  • Thank you, but how i add group dynamically with all numbers? – Eliana Jul 03 '15 at 20:24
  • The closest thing I am aware of is the deep linking feature, https://core.telegram.org/bots#deep-linking. I don't think you can start a group with a series of numbers as that would be intrusive, in Telegram the end user will have to be the one that takes the action of adding a bot to their contact list etc. You can use deep-linking to dynamically start a group or execute an action when a user clicks a link. The link format will be something like https://telegram.me/yourbot?startgroup=CustomBotGroup – Chris Brand Jul 03 '15 at 20:31
  • But it's possible insert a number phone instead a chat id? like a http://notificatio.divshot.io/ that use a number phone – Eliana Jul 03 '15 at 20:37
  • Is the phone number the number of the user you are trying to interact with or the address of your bot (application account that will send messages)? – Chris Brand Jul 04 '15 at 09:51
  • The phone number of the users.. i want to send notification – Eliana Jul 04 '15 at 11:54
  • I updated my answer with more information on deep-linking. Unfortunately I don't think it's possible to send a message to a mobile number instead of a chat_id using the bot API. This is to avoid spamming, so if you don't want the user to initiate the conversation by adding the bot contact first...it's probably not the solution for you. – Chris Brand Jul 04 '15 at 13:09
  • Yes, I'm doing well . thanks a lot – Eliana Jul 05 '15 at 09:21
  • You can't send messages to a phone number with BotAPI, that's why you should use Notificatio (http://landing.notificatio.me). – Ilia P Sep 09 '15 at 01:35
  • Here is how i add contacts and send them messages, it requires https://github.com/vysheng/tg installed. – ycode Oct 19 '15 at 19:20