Skip to content

Instantly share code, notes, and snippets.

@whatsmate
Last active June 29, 2022 00:32
Show Gist options
  • Select an option

  • Save whatsmate/7555d8435a0d769fd01b3acefdf6ce47 to your computer and use it in GitHub Desktop.

Select an option

Save whatsmate/7555d8435a0d769fd01b3acefdf6ce47 to your computer and use it in GitHub Desktop.
Sending a text message to a Telegram Group in Google Apps Script
function main() {
var group_name = "Muscle Men Club"; // TODO: Specify the name of your group
var group_admin = "12025550108"; // TODO: Specify the number of the group admin
var message = "Your six-pack is on the way!";
sendTelegramGroupText(destNumber, message);
}
function sendTelegramGroupText(group_name, group_admin, message) {
var instanceId = "YOUR_INSTANCE_ID_HERE"; // TODO: Replace it with your gateway instance ID here
var clientId = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Premium Account client ID here
var clientSecret = "YOUR_CLIENT_SECRET_HERE"; // TODO: Replace it with your Premium Account client secret here
var jsonPayload = JSON.stringify({
group_name: group_name,
group_admin: group_admin,
message: message
});
var options = {
"method" : "post",
"contentType": "application/json",
"headers": {
"X-WM-CLIENT-ID": clientId,
"X-WM-CLIENT-SECRET": clientSecret
},
"payload" : jsonPayload,
"Content-Length": jsonPayload.length
};
UrlFetchApp.fetch("https://api.whatsmate.net/v3/telegram/group/text/message/" + instanceId, options);
}
@whatsmate
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment