Digital Farmer
Digital Farmer

Reputation: 2107

Create hyperlink in Telegram message sent by bot via script / google sheets

My current script is:

function EnviarTelegram(botSecret, chatId, body) {
var response = UrlFetchApp.fetch("https://api.telegram.org/bot" + botSecret + "/sendMessage?text=" + encodeURIComponent(body) + "&chat_id=" + chatId + "&parse_mode=HTML");
}

The formula in Google Sheets I use to send the message is:

=EnviarTelegram("Code to Bot","Code to ChatId","Created Message")

I would like to be able to create the following message:

"Full list of games tomorrow

Click here to access"

In Click here to access I wish there was a hyperlink for example: www.google.com/testtesttesttest

Is there any way to be able to adjust the script or the text created for this?

Upvotes: 1

Views: 1770

Answers (1)

Tanaike
Tanaike

Reputation: 201338

In your query parameter, parse_mode=HTML is used. So I thought that in this case, HTML tags can be used for text. When you want to use =EnviarTelegram("Code to Bot","Code to ChatId","Created Message"), how about the following modification?

From:

=EnviarTelegram("Code to Bot","Code to ChatId","Created Message")

To:

=EnviarTelegram("Code to Bot","Code to ChatId","Full list of games tomorrow\n\n<a href='https://www.google.com/testtesttesttest'>Click here to access</a>")

Upvotes: 1

Related Questions