Community discussions

MikroTik App
 
MarkReyan
just joined
Topic Author
Posts: 14
Joined: Wed Dec 28, 2022 9:40 am
Location: UK

Send message from Mikrotik to the telegram group

Wed Dec 28, 2022 10:14 pm

Hello
I'm trying to send a message from Mikrotik to my telegram group using bot
[ I already added a new Traffic Monitor] my OS version is: 6.47.10
and this is the script:
/tool fetch
url="https://api.telegram.org/bot<TOKEN>/sen ... xt=Message"
already ,I have been set the <TOKEN> AND <CHAT_ID>
I'm wondering if there is need to upgrade the OS.
I tried to execute the script in the terminal I got this error
failure: invalid URL protocol
can you help me please
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send message from Mikrotik to the telegram group

Thu Dec 29, 2022 6:14 pm

correct syntax is
/tool fetch url="https://api.telegram.org/bot<TOKEN>/sendMessage\3Fchat_id=<CHAT ID or @channelusername>&text=<MESSAGE (max 4096 chrs)>"
But you can use only space, numbers and upper and lowercase latin letters, no special chars or signs.

supported characters code

<SPACE>	!	"	 	$	 	 	'	(	)	*	 	,	-	.	 
0	1	2	3	4	5	6	7	8	9	 	;	<	=	>	 
 	A	B	C	D	E	F	G	H	I	J	K	L	M	N	O
P	Q	R	S	T	U	V	W	X	Y	Z	[	\	]	^	_
`	a	b	c	d	e	f	g	h	i	j	k	l	m	n	o
p	q	r	s	t	u	v	w	x	y	z	{	|	}	~
The list can have errors.

You must urlencode first the text if is not standard or you must use reserved chrs like &, #, etc.

For example if the message must be Привіт <MESSAGE> must be equal to %D0%9F%D1%80%D0%B8%D0%B2%D1%96%D1%82
 
MarkReyan
just joined
Topic Author
Posts: 14
Joined: Wed Dec 28, 2022 9:40 am
Location: UK

Re: Send message from Mikrotik to the telegram group

Fri Dec 30, 2022 10:35 am

I tried that doesn't work
and I can't see any thing in the log that means the script isn't working
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send message from Mikrotik to the telegram group

Fri Dec 30, 2022 11:21 am

Post full script
 
MarkReyan
just joined
Topic Author
Posts: 14
Joined: Wed Dec 28, 2022 9:40 am
Location: UK

Re: Send message from Mikrotik to the telegram group

Fri Dec 30, 2022 12:57 pm

I tried All of them
/tool fetch url="https://api.telegram.org/bot5801257/sendMessage?
chat_id=10559&text=%20%22Donload%20is%20more%20than%202M" keep-result=no;

/tool fetch url="https://api.telegram.org/bot5801257/sendMessage?
chat_id=1055&text=%20%22Donload%20is%20more%20than%202M"

/tool fetch url="https://api.telegram.org/bot5801257/sendMessage?
chat_id=1055&text=Download speed is more than 25MB"

/tool fetch url="https://api.telegram.org/bot5801257/sendMessage\
chat_id=-1055&text=Download speed is more than 25MB"
Last edited by MarkReyan on Fri Dec 30, 2022 2:32 pm, edited 2 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send message from Mikrotik to the telegram group

Fri Dec 30, 2022 1:00 pm

I hope you post false bot and chatid...


What error you give?
For me, with your URL is:

error code

failure: closing connection: <401 Unauthorized> 149.154.167.220:443 (4)
 
MarkReyan
just joined
Topic Author
Posts: 14
Joined: Wed Dec 28, 2022 9:40 am
Location: UK

Re: Send message from Mikrotik to the telegram group

Fri Dec 30, 2022 1:13 pm

sure, I posted false bot and chatID.
actually seems not working I can't see any thing in the log
after I pasted the script in the terminal I got this line below:
expected end of command (line 1 column 105)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send message from Mikrotik to the telegram group  [SOLVED]

Fri Dec 30, 2022 1:30 pm

Regardless if work or not,
you have read my previous post???
Try this, without touch anything except set correct token and chat id:
/tool fetch url="https://api.telegram.org/bot<TOKEN>/sendMessage\3Fchat_id=<CHAT-ID>&text=test+message"

Who is online

Users browsing this forum: No registered users and 27 guests