Webhoook with telegram

I need help to try call a webhook:

- I try it to add this url: "https://api.telegram.org/bot{my token}
/sendMessage?chat_id={my id chat}&text="&CONCATENATE("Hi", " this is a text")

but appear Error 1 : The webhook url .............. is not well formed!

 

So what is the correct form to use with telegram api?

 

Thanks you. 

Solved Solved
0 10 1,561
2 ACCEPTED SOLUTIONS

May be related to the fact that it's not encoded since you are adding the message on the URL.
https://help.appsheet.com/en/articles/2347653-encodeurl

 

https://api.telegram.org/bot{my token}/sendMessage?chat_id={my id chat}&text=<<ENCODEURL(CONCATENATE("Hi", " this is a text"))>>

 

I do it this way though:

SkrOYC_1-1644273143872.png

Url

https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/sendMessage

 Body:

 

{
"chat_id":yourchatid,
"text":"<<CONCATENATE(
"Your",
" text",
" here"
)>>",
"parse_mode":"MarkdownV2"
}

 

 

View solution in original post

Well, guess what? I tried it again today with the line break stuff and it worked.

This is counterintuitive so make sure you follow me.

Everytime you want to make a line break it has to be outside of your text.

On this example:

{
"chat_id":yourchatid,
"text":"<<CONCATENATE(
"Your",
" text",
" here"
)>>",
"parse_mode":"MarkdownV2"
}

 

You would think that the line break should be inside your text, like this:

 

{
"chat_id":yourchatid,
"text":"<<CONCATENATE(
"Your",
" text",
" here",
"\nNew line"
)>>",
"parse_mode":"MarkdownV2"
}

 

It won't work. The thing is, you have to make a big mess to make sure every line break is where you want it.

If you want something like this on Telegram:


Hi UserName!
Today is Feb 8, 2022
You have X pending tasks to do

You need something like this on your Body:

 

{
"chat_id":yourchatid,
"text":"<<CONCATENATE( "Hi *", [ColumnWithUserName]), "*")>>\n
<<CONCATENATE("Today is ", TEXT(TODAY(), MMM DD, YYYY))>>\n
<<CONCATENATE( "You have ", [AnyColumnOrExpressionCountingThis], " pending task to do")>>",
"parse_mode":"MarkdownV2"
}

 

Basically, make sure the \n is outside any function/expression (it's not part of your text). It should be between the expressions, out of the <<>>

In other words, every line should be it's own expression

View solution in original post

10 REPLIES 10

HBT
Silver 4
Silver 4

910F2041-5E12-471C-BD90-21FA4CECDABE.jpeg

 remove the quotes and the merge mark and try again..

May be related to the fact that it's not encoded since you are adding the message on the URL.
https://help.appsheet.com/en/articles/2347653-encodeurl

 

https://api.telegram.org/bot{my token}/sendMessage?chat_id={my id chat}&text=<<ENCODEURL(CONCATENATE("Hi", " this is a text"))>>

 

I do it this way though:

SkrOYC_1-1644273143872.png

Url

https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/sendMessage

 Body:

 

{
"chat_id":yourchatid,
"text":"<<CONCATENATE(
"Your",
" text",
" here"
)>>",
"parse_mode":"MarkdownV2"
}

 

 

It works perfectly, now my bot sends the plain text or the value of a column in the row.

 

Two more questions:

- Could you tell me how to make a line break? I tried with "\n" but it doesn't work for me.

- How could a hyperlink be included in the message?

Thank you very much for all your instructions, they have been very helpful.

About the line Break, that's a pain I have had for months without solution. I've tried a lot of things, believe me. I'd love to help you. The only thing I think worked but not the way I wanted was the \n on the URL and the ENCODEURL() function. But POST using the JSON code for the body... no luck at all.

 

The hyperlink is easy:
MarkdownV2:

 

 

[inline URL](http://www.example.com/)

 

 

HTML: 

 

<a href="http://www.example.com/">inline URL</a> 

 

Well, guess what? I tried it again today with the line break stuff and it worked.

This is counterintuitive so make sure you follow me.

Everytime you want to make a line break it has to be outside of your text.

On this example:

{
"chat_id":yourchatid,
"text":"<<CONCATENATE(
"Your",
" text",
" here"
)>>",
"parse_mode":"MarkdownV2"
}

 

You would think that the line break should be inside your text, like this:

 

{
"chat_id":yourchatid,
"text":"<<CONCATENATE(
"Your",
" text",
" here",
"\nNew line"
)>>",
"parse_mode":"MarkdownV2"
}

 

It won't work. The thing is, you have to make a big mess to make sure every line break is where you want it.

If you want something like this on Telegram:


Hi UserName!
Today is Feb 8, 2022
You have X pending tasks to do

You need something like this on your Body:

 

{
"chat_id":yourchatid,
"text":"<<CONCATENATE( "Hi *", [ColumnWithUserName]), "*")>>\n
<<CONCATENATE("Today is ", TEXT(TODAY(), MMM DD, YYYY))>>\n
<<CONCATENATE( "You have ", [AnyColumnOrExpressionCountingThis], " pending task to do")>>",
"parse_mode":"MarkdownV2"
}

 

Basically, make sure the \n is outside any function/expression (it's not part of your text). It should be between the expressions, out of the <<>>

In other words, every line should be it's own expression

Thank you very much for your time and dedication. Now it works perfectly.

I think more: Are you try to add a cell with document? I know that telegram admit file (log) so... could be posible to send file insidd to json from a cell?

HBT
Silver 4
Silver 4

Place %0a where you will cut the line. Do not use any joins or quotation marks.

If you use it without quotation marks, broken json format and if you use it with "%0a" read like text ... so not woeks. The correct solution to use in json format is like SkrOYC's explanation.   I

also appreciate your response.

how about entering characters like '=','-----' in the body?

Those are just characters without any impact in the JSON, so just add them in your expressions as text

Top Labels in this Space