# Unable to send text\_link from telegram bot

**URL:** https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615
**Category:** General
**Created:** [13 May 2021 22:37 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615 "2021-05-13T22:37:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Ozero](https://avatars.discourse-cdn.com/v4/letter/o/e495f1/32.png) [@Ozero](https://discourse.nodered.org/u/Ozero)
#### Post date: [13 May 2021 22:37 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/1 "2021-05-13T22:37:41Z")

</div>

I'm working on a RPi Zero W based doorbell camera, that sends a picture with a caption via a telegram bot. Sending the pictures with a text only caption works flawlessly. However, I would like to include a text link to the livestream inside the caption, but have thus far been unsuccessful in doing so. In order to get it this work, I have tried the text link format as described [here](https://core.telegram.org/bots/api#messageentity).

Unfortunately, this this doesn't result in any hyperlink in messages received from the bot. This is strange, because sending pictures with the text\_link in their caption to the bot itself, maintains their formatting and results in a working link.

Using the receiver block from node-red-contrib-telegrambot, I was able to intercept a received message with the desired formatting. Its payload looks like this:

> {"content":[image data array],"type":"photo","caption":"There's someone at the door Live Image","entities":[{"offset":27,"length":10,"type":"text\_link","url":"192.168.1.100/html/cam.php"}],"chatId":xxxxxxx}

Unfortunately, when I use the same formatting to make the bot send images, the picture and the caption work, but the link behind "Live Image" is gone.

Does anyone have an idea how I can get the link to work?

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [14 May 2021 05:50 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/2 "2021-05-14T05:50:16Z")

</div>

You should be able to use 'markdown', to show it's a URL, by surrounding it with \< and \> as shown below.

"url":"\<192.168.1.100/html/cam.php\>"

---

<div class="post-metadata">

### Author: ![Ozero](https://avatars.discourse-cdn.com/v4/letter/o/e495f1/32.png) [@Ozero](https://discourse.nodered.org/u/Ozero)
#### Post date: [14 May 2021 10:09 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/3 "2021-05-14T10:09:02Z")

</div>

Thanks, but unfortunately this didn't work.

To be clear I'm looking for an equivalent to the following HTML code:

> There's someone at the door. Live Image

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [14 May 2021 10:26 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/4 "2021-05-14T10:26:05Z")

</div>

Try using markdown...

```auto
msg.payload = {
  content: msg.payload, //the image buffer
  caption: `There's someone at the door. [Live Image](http://camera_url).`,
  type : 'photo',
  chatId: "xxxx"
}
msg.payload.options = { parse_mode : "Markdown" };

return msg;

```

---

<div class="post-metadata">

### Author: ![Ozero](https://avatars.discourse-cdn.com/v4/letter/o/e495f1/32.png) [@Ozero](https://discourse.nodered.org/u/Ozero)
#### Post date: [14 May 2021 10:39 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/5 "2021-05-14T10:39:17Z")

</div>

That didn't work either. When I use markdown within this string, telegram displays the string character by character, hereby ignoring the markdown.

When I try `caption: 'There's someone at the door.' [Live Image](http://camera_url) ` (so outside of the string), I get a "bad invocation" error.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [14 May 2021 11:04 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/6 "2021-05-14T11:04:24Z")

</div>

> [@Ozero](#):
>
> When I try `caption: 'There's someone at the door.' [Live Image](http://camera_url) ` (so outside of the string), I get a "bad invocation" error.

Why are you doing that?

Put the link URL inside the string

```auto
caption: `There's someone at the door. [Live Image](http://camera_url).`, 

```

### OK

Firstly, to confirm, are you using [node-red-contrib-telegrambot](https://flows.nodered.org/node/node-red-contrib-telegrambot)?

Try this as an example - PS dont put the `[Live Image](http://xxxxxx)` part outside of the quotes - just do exactly as I have below

```auto
msg.payload = {
  content: msg.payload, //<<set the content to your image buffer
  caption: `There's someone at the door. [Live Image](http://google.com).`,
  type : 'photo', // << DONT CHANGE THIS
  chatId: "xxxx" // << set chatId correctly
}
msg.payload.options = { parse_mode : "Markdown" }; // << DONT CHANGE THIS
return msg; // << DONT CHANGE THIS

```

### NOTES

- For some odd reason, the URL is NOT rendered as a hyperlink in **telegram web** - only in the mobile app (andoid)
- For some odd reason, the URL is sometimes NOT rendered as a hyperlink when it doesnt end with .com or .something - but only when the `type` is "photo"
- Messages that are not "photo" type always render the markdown hyperlink correctly

So - you might want to consider ...  
OPTION1: sending two separate messages. First one a photo, second one a hyperlink  
OPTION2: Just send a text message with a hyperlink to live view  
OPTION3: Send a photo as you do now & use a command like `/live` to get the link sent to you  
OPTION4: Send a message `"Theres someone at the Door, [Live Image](http://xxxx)"` AND a "[keyboard](https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating)" with the option "Get Image" (to get a static picture)

---

<div class="post-metadata">

### Author: ![Ozero](https://avatars.discourse-cdn.com/v4/letter/o/e495f1/32.png) [@Ozero](https://discourse.nodered.org/u/Ozero)
#### Post date: [14 May 2021 11:35 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/7 "2021-05-14T11:35:58Z")

</div>

Thanks! This worked.

My message was missing the:

```auto
msg.payload.options = { parse_mode : "Markdown" };

```

I'm using the node-red-contrib-telegrambot by the way.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [14 May 2021 11:38 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/8 "2021-05-14T11:38:42Z")

</div>

> [@Ozero](#):
>
> My message was missing the:
> 
> ```auto
> msg.payload.options = { parse_mode : "Markdown" };
> 
> ```

Yeah, that was the critical bit to using markdown 🤣

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [14 May 2021 13:16 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/9 "2021-05-14T13:16:43Z")

</div>

Sorry - I've been out today and missed all the interactions.

This is what I use in a function node to get Node-RED's dashboard to appear as a link.

```auto
msg.payload = {chatId: "12345678", type:"message", content:"<192.168.1.154:1880/ui/#!/>"};
return msg;

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [28 May 2021 13:16 UTC](https://discourse.nodered.org/t/unable-to-send-text-link-from-telegram-bot/45615/10 "2021-05-28T13:16:57Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
