# Telegram admins

**URL:** <https://discourse.nodered.org/t/telegram-admins/54151>\
**Category:** General\
**Created:** [23 November 2021 10:33 UTC](https://discourse.nodered.org/t/telegram-admins/54151 "2021-11-23T10:33:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gleba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gleba/32/50938_2.png) [@gleba](https://discourse.nodered.org/u/gleba)\
**Post date:** [23 November 2021 10:33 UTC](https://discourse.nodered.org/t/telegram-admins/54151/1 "2021-11-23T10:33:56Z")

</div>

I am trying to create a command that only responds to administrators.  
how should i set the command to get an array of all admin?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1f0f8018c7d44b2cf10607061749c297546b2bf9.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 November 2021 12:27 UTC](https://discourse.nodered.org/t/telegram-admins/54151/2 "2021-11-23T12:27:17Z")

</div>

The /command node should return the property  
`msg.originalMessage.from.id` this will be who sent the command use it to compare it to the admins id to filter /commands for others.

To use the getChatAdministrators method, you can send a http request as below

```auto
[{"id":"b1175572.28c0d8","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":340,"wires":[["5a160730.12f4f8"]]},{"id":"5a160730.12f4f8","type":"http request","z":"c791cbc0.84f648","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.telegram.org/bot12DGHHGRF56FQ_Vgg6SNzs3LzFW_525Kmrl-ilr5EfE/getChatAdministrators?chat_id=-1003456774444","tls":"","persist":false,"proxy":"","authType":"","x":350,"y":320,"wires":[["e68bb3e2.78de2"]]},{"id":"e68bb3e2.78de2","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":340,"wires":[]}]

```

should return

```auto
{"ok":true,"result":[{"user":{"id":8592451409,"is_bot":true,"first_name":"mybot","username":"e1cidbot"},"status":"administrator","can_be_edited":false,"can_manage_chat":true,"can_change_info":true,"can_delete_messages":true,"can_invite_users":true,"can_restrict_members":true,"can_pin_messages":true,"can_promote_members":false,"can_manage_voice_chats":true,"custom_title":"Boss","is_anonymous":true},{"user":{"id":274758257,"is_bot":false,"first_name":"ElCid","language_code":"en"},"status":"creator","is_anonymous":false}]}

```

---

<div class="post-metadata">

**Author:** ![gleba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gleba/32/50938_2.png) [@gleba](https://discourse.nodered.org/u/gleba)\
**Post date:** [23 November 2021 13:45 UTC](https://discourse.nodered.org/t/telegram-admins/54151/3 "2021-11-23T13:45:51Z")

</div>

> [@E1cid](#):
>
> To use the getChatAdministrators method, you can send a http request as below

can I get the admin list only through the webhook?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 November 2021 13:55 UTC](https://discourse.nodered.org/t/telegram-admins/54151/4 "2021-11-23T13:55:34Z")

</div>

I have not seen any way to get it from the telegram node But others may know differently. If there was the telegram node would use a http call or web sockets to do the same thing.

You would only need to do the http call once a day (or similar) to store admin id's

---

<div class="post-metadata">

**Author:** ![gleba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gleba/32/50938_2.png) [@gleba](https://discourse.nodered.org/u/gleba)\
**Post date:** [23 November 2021 14:02 UTC](https://discourse.nodered.org/t/telegram-admins/54151/5 "2021-11-23T14:02:56Z")

</div>

to which address should I bind the token to get the webhook for node-red?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 November 2021 15:24 UTC](https://discourse.nodered.org/t/telegram-admins/54151/6 "2021-11-23T15:24:40Z")

</div>

Look in the http request node the full url is there. Just change the bot secret key and the chat\_id.

---

<div class="post-metadata">

**Author:** ![gleba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gleba/32/50938_2.png) [@gleba](https://discourse.nodered.org/u/gleba)\
**Post date:** [23 November 2021 19:35 UTC](https://discourse.nodered.org/t/telegram-admins/54151/7 "2021-11-23T19:35:01Z")

</div>

Yes, thank you. It's working. I just have to filter the playolad. I was expecting an array.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [23 November 2021 19:59 UTC](https://discourse.nodered.org/t/telegram-admins/54151/8 "2021-11-23T19:59:09Z")

</div>

Try this JSONata expression in a change node, it should return an array of id's  
Set msg.what\_ever  
to J:

```auto
[**.id]

```

---

<div class="post-metadata">

**Author:** ![gleba](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gleba/32/50938_2.png) [@gleba](https://discourse.nodered.org/u/gleba)\
**Post date:** [24 November 2021 15:33 UTC](https://discourse.nodered.org/t/telegram-admins/54151/9 "2021-11-24T15:33:50Z")

</div>

> [@E1cid](#):
>
> `[**.id]`

I tested the proposed solution but it had no result

---

<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:** [8 December 2021 15:34 UTC](https://discourse.nodered.org/t/telegram-admins/54151/10 "2021-12-08T15:34:02Z")

</div>

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