How to send an audio file to a Telegram user from Google Apps Script (GAS)

Using the WhatsMate Telegram Gateway REST API



This article shows you how to send an audio file (e.g. an MP3 file) to a registered Telegram user from a Google Apps Script.

Before the recipient can receive your Telegram message, she will need to register with the WhatsMate Telegram Gateway. Instructions are available on the official site. Unregistered users will NEVER receive messages from the Gateway.

To send a Telegram message containing an audio file from a Google Apps Script, do this:

  1. First, learn how to send a simple text message on the official site.
  2. With the above knowledge, you can now download our sample code.
  3. Copy the following source code to your Google Apps Script project.
  4. Customize the TODO lines:
    • Specify your gateway instance ID on line 19.
    • Specify your client ID and secret on lines 20 and 21.
    • Specify your target recipient on line 3. Remember to include the country code.
    • Specify your MP3 file on line 4.
  5. Run the function demoSendTelegramMp3InDrive() to send your first MP3 file.

You will need a trial account to call the above API. Go sign up now.