Telegram Bot Post

Posted by David Blue, Last update about 2 years ago


about 2 years ago

-Description update
-Listed publicly

Send draft contents to a specified Telegram channel/group chat via the Telegram Bot API.

The URL of the result will be copied to the clipboard and inserted as a markdown-formatted hyperlink one line break below the cursor’s current position in the following format:


Example Result


Upon first run, the action creates the Telegram Bot credential identifier, which requires both the numeric chat_id of the target group chat/channel (best obtained with the Rose bot, imo,) and a bot API token (which you can obtain from @botfather)


  • script

    // setup and request credentials
    let credential = Credential.create("Telegram Bot", "Enter your bot token and target chat id.");
    credential.addTextField("chat", "Chat ID");
    credential.addPasswordField("token", "Bot Token");
    const chat = credential.getValue("chat");
    const token = credential.getValue("token");
    // make post
    let endpoint = `${token}/sendMessage`;
    let data = {
    	"chat_id": chat,
    	"text": draft.content,
    	"parse_mode": "markdown",
    // create and post HTTP request
    var http = HTTP.create();
    var response = http.request({
    	"url": endpoint,
    	"method": "POST",
    	"data": data,
    // log result post ID and setup template tags for insertion
    if (response.success == true) {
    	let d = JSON.parse(response.responseText);
    	console.log("Posted to Telegram Message ID: " + d.result.message_id);
    	draft.setTemplateTag("messageid", d.result.message_id);
    else {
    	console.log("Telegram Error: " + response.error);;
  • insertText

    - [[[chatalpha]]-[[messageid]]]([[chatalpha]]/[[messageid]])
  • clipboard



  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.