To set up SMS forwarding in Telegram, follow the steps below:
Step 1. Create a new bot to receive SMS messages in Telegram. Do the following:
- open BotFather in Telegram;
- send the command /newbot;
- set a name for your bot;
- save the API token received from the bot for further customization.
Example:
Use this token to access the HTTP API:
60655699310:AAFz6ptUnB71ILePbXKwB71ILePbXUeU4
Use this token to access the HTTP API:
60655699310:AAFz6ptUnB71ILePbXKwB71ILePbXUeU4
Step 2. Create a new group in Telegram to receive SMS messages and add your bot to it. Then find out the group id:
- open the web version of Telegram and log in with your account;
- access the created group;
- find the group id in the browser address bar, which will be specified at the end of the URL starting with the "-" symbol.
Example of an address bar:
where:
"https://web.telegram.org/k/#-4000000000" - URL
"-4000000000" - group id
"https://web.telegram.org/k/#-4000000000" - URL
"-4000000000" - group id
Step 3. Set up SMS forwarding to HTTP via webhook in your personal cabinet:
- in the number settings, enter the following HTTP webhook format to send messages to your Telegram group:
https://api.telegram.org/botAPItoken/sendMessage?chat_id=groupid&text=Incoming%20SMS%20to%20%TO%%20from%20%FROM%%20%MESSAGE% - save the SMS forwarding settings.
Now you will automatically receive inbound SMS messages to your Telegram group in the following format:
Incoming SMS to +XXXXX from XXXXX SMS Text
You can change the format of messages from the bot using variables:
- TO: SMS recipient number;
- FROM: number of the SMS sender;
- MESSAGE: message text.
- TO: SMS recipient number;
- FROM: number of the SMS sender;
- MESSAGE: message text.