Не работет отправка ТГ-уведомлений

Здравствуйте.
Решение вопроса отложилось, поскольку проблема была не критичной. Система работала через мобильную связь. За прошедшее с весны время ситуация с мобильной связью изменилась – Telegram теперь не работает, поэтому надо решать проблему с отправкой уведомлений через проводную сеть.
Сегодня перепрошил WB на 2507 и попробовал отправить уведомление с помощью команды:

Notify.sendTelegramMessage("token", "chatID", "Text");

В ответ в журнале появилось такое сообщение:

wb-rules[1953]: ERROR: [rule error] error sending telegram message to *********:
wb-rules[1953]: INFO: [rule info] error running command callback for /bin/sh: SyntaxError: invalid json
                                                             duk_bi_json.c:73
                                                             parse  native strict preventsyield
                                                             exitCallback /usr/share/wb-rules-system/scripts/lib.js:510
                                                             anon /usr/share/wb-rules-system/scripts/lib.js:339 preventsyield

На всякий случай, попробовал отправить из консоли с помощью
curl -s -X POST https://api.telegram.org/...
– всё получилось. Подскажите, пожалуйста, куда копать?

Добрый день!

Перенёс ваше сообщение в отдельную ветку согласно правилам портала.

Для диагностики проблемы пришлите, пожалуйста, архив с диагностической информацией контроллера. Создание архива описано в документации.

diag_output_AGO7HF6L_2025-09-29-20.30.38.zip (245,4 КБ)

Добрый день!

Попробуйте вариант, описанный в данной статье.

Если вы про этот пример:

var message = "Text"; // напишите свой текст сообщения
var token = "TOKEN"; // замените на токен бота
var chat_id = CHATID; // замените на свой chat_id
var command = 'curl -s -X POST https://api.telegram.org/bot{}/sendMessage -d chat_id={} -d text="{}"'.format(token, chat_id, encodeURIComponent(message));

runShellCommand(command);

То я именно с этого метода и начинал. Не получалось. wb-rules в журнале отписался об ошибке и невозможности отправить сообщение. Потом попробовал прямо из консоли с root-правами указать команду curl -s -X POST https://api.telegram.org/bot123456/sendMessage -d chat_id=123456 -d text="Test" – сообщение ушло.

Добрый день!

Попробуйте данный пример, подставив ваши переменные для Telegram:


defineRule("spam_telegram_test", {
  when: function () { return true; }, 
  then: function () {
    var token   = "ВАШ ТОКЕН";
    var chat_id = "ВАШ АЙДИ";

    for (var i = 1; i <= 100; i++) {
      var message = "Тестовое сообщение №" + i;

      var cmd = "LANG=C.UTF-8 curl -s -X POST " +
                "https://api.telegram.org/bot" + token + "/sendMessage " +
                "--data-urlencode chat_id=" + chat_id + " " +
                "--data-urlencode text=\"" + message + "\"";

      runShellCommand(cmd);
    }
  }
});

Сделал как вы просили и, видимо, поскольку when всегда возвращала true

то на контроллере начался трэш. Суть в том, что пока я не остановил службу wb-rules и не стёр этот блок кода, не мог остановить бесконечный цикл.
В общем, “повесил” ваш код на виртуальную кнопку. В журнале появилось следующее (всё писать не буду, ибо смысл понятен):

Sep 30 15:28:35 wirenboard-AGO7HF6L wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -X POST https://api.telegram.org/bot123/sendMessage --data-urlencode chat_id=-321--data-urlencode text="Тестовое сообщение №2"' failed with exit status 60
Sep 30 15:28:35 wirenboard-AGO7HF6L wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -X POST https://api.telegram.org/bot123/sendMessage --data-urlencode chat_id=-321--data-urlencode text="Тестовое сообщение №10"' failed with exit status 60
Sep 30 15:28:35 wirenboard-AGO7HF6L wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -X POST https://api.telegram.org/bot123/sendMessage --data-urlencode chat_id=-321--data-urlencode text="Тестовое сообщение №3"' failed with exit status 60
Sep 30 15:28:35 wirenboard-AGO7HF6L wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -X POST https://api.telegram.org/bot123/sendMessage --data-urlencode chat_id=-321--data-urlencode text="Тестовое сообщение №12"' failed with exit status 60

Добрый день!

Верно ли я понимаю, что сообщения до Telegram не ушли?
Если так, рекомендую проверить настройки интернета и времени на контроллере, так как ошибка failed with exit status 60 указывает на проблему с SSL-сертификатом.

Да, всё верно.

Доступ в интернет специфический и осуществляется через прокси-сервер, IP которого прописан в /etc/environment
Время установлено адекватное в соответствии с временной зоной – текущее UTC +7. Но синхронизировать не получается, так как серверы времени заблокированы провайдером:

~# timedatectl
               Local time: Wed 2025-10-01 14:06:09 +07
           Universal time: Wed 2025-10-01 07:06:09 UTC
                 RTC time: Wed 2025-10-01 07:06:10
                Time zone: Asia/Krasnoyarsk (+07, +0700)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

Доступ в интернет – имеется, поскольку могу отправить в ТГ сообщение из консоли с правами root с помощью curl

И ещё. Почему из консоли могу отправить сообщение в ТГ, а из wb-rules появляются проблемы с сертификатом?

Добрый день!

Уточню у коллег, что можно сделать и почему консоль только отсылает сообщения.

Добрый день!

Уточнил у коллег, сошлись во мнении, что для отладки нужно добавить ключ -v (--verbose) и сравнить оба исполнения — через правило и через curl.
Предполагаю, что при отработке wb-rules не подхватываются данные с прокси.

Лог с wb-rules:

Oct 02 22:05:48 wirenboard-A321 wb-rules[13597]: INFO: reloading file: /etc/wb-rules/alarm_rules_sms.js
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: *
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: *
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]:    Trying 149.154.167.220:443...
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]:   Trying 149.154.167.220:443...
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: *   Trying 149.154.167.220:443...
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: *   Trying 149.154.167.220:443...
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: *   Trying 149.154.167.220:443...
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: *
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: *
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]:  ALPN, offering h2
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: ALPN, offering h2
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: *
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: *
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: ALPN, offering http/1.1
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: ALPN, offering http/1.1
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * ALPN, offering h2
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * ALPN, offering http/1.1
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * ALPN, offering h2
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * ALPN, offering http/1.1
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * ALPN, offering h2
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * ALPN, offering http/1.1
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * successfully set certificate verify locations:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: *  CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: *  CApath: /etc/ssl/certs
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: } [5 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: } [512 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * successfully set certificate verify locations:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: *  CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: *  CApath: /etc/ssl/certs
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: } [5 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: } [512 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * successfully set certificate verify locations:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: *  CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: *  CApath: /etc/ssl/certs
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: } [5 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: } [512 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * successfully set certificate verify locations:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: *  CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: *  CApath: /etc/ssl/certs
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: } [5 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: } [512 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * successfully set certificate verify locations:
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: *  CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: *  CApath: /etc/ssl/certs
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: } [5 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: } [512 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: { [122 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: { [6 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: { [698 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: } [2 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * SSL certificate problem: self signed certificate
Oct 02 22:05:53 wirenboard-A321 wb-rules[15785]: * Closing connection 0
Oct 02 22:05:53 wirenboard-A321 wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №4"' failed with exit status 60
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: { [122 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: { [6 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: { [698 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: } [2 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * SSL certificate problem: self signed certificate
Oct 02 22:05:53 wirenboard-A321 wb-rules[15784]: * Closing connection 0
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: { [122 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: { [6 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: { [698 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: } [2 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * SSL certificate problem: self signed certificate
Oct 02 22:05:53 wirenboard-A321 wb-rules[15781]: * Closing connection 0
Oct 02 22:05:53 wirenboard-A321 wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №5"' failed with exit status 60
Oct 02 22:05:53 wirenboard-A321 wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №1"' failed with exit status 60
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: { [122 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: { [6 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: { [698 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: } [2 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * SSL certificate problem: self signed certificate
Oct 02 22:05:53 wirenboard-A321 wb-rules[15783]: * Closing connection 0
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: { [122 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: { [6 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: { [698 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: } [2 bytes data]
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * SSL certificate problem: self signed certificate
Oct 02 22:05:53 wirenboard-A321 wb-rules[15782]: * Closing connection 0
Oct 02 22:05:53 wirenboard-A321 wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №2"' failed with exit status 60
Oct 02 22:05:53 wirenboard-A321 wb-rules[13597]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №3"' failed with exit status 60

Вывод из консоли:


root@wirenboard-AGO7HF6L:~# curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage -d chat_id=-456 -d text="Test 02.10.2025 22:15"
* Uses proxy env variable https_proxy == 'http://*.*.*.*:3128/'
*   Trying *.*.*.*:3128...
* Connected to *.*.*.* (*.*.*.*) port 3128 (#0)
* allocate connect buffer!
* Establish HTTP proxy tunnel to api.telegram.org:443
> CONNECT api.telegram.org:443 HTTP/1.1
> Host: api.telegram.org:443
> User-Agent: curl/7.74.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.0 200 Connection established
<
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* CONNECT phase completed!
* CONNECT phase completed!
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=api.telegram.org
*  start date: Mar 25 13:09:41 2025 GMT
*  expire date: Apr 26 13:09:41 2026 GMT
*  subjectAltName: host "api.telegram.org" matched cert's "api.telegram.org"
*  issuer: C=US; ST=Arizona; L=Scottsdale; O=GoDaddy.com, Inc.; OU=http://certs.godaddy.com/repository/; CN=Go Daddy Secure Certificate Authority - G2
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x4c62c0)
> POST /bot123:ABC/sendMessage HTTP/2
> Host: api.telegram.org
> user-agent: curl/7.74.0
> accept: */*
> content-length: 49
> content-type: application/x-www-form-urlencoded
>
* We are completely uploaded and fine
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200
< server: nginx/1.18.0
< date: Thu, 02 Oct 2025 15:16:23 GMT
< content-type: application/json
< content-length: 451
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< access-control-allow-origin: *
< access-control-allow-methods: GET, POST, OPTIONS
< access-control-expose-headers: Content-Length,Content-Type,Date,Server,Connection
<
* Connection #0 to host *.*.*.* left intact
{"ok":true,"result":{"message_id":2543,"from":{"id":7604256657,"is_bot":true,"first_name":"\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0438\u043a \u0421\u0428 29","username":"wbsec29_bot"},"author_signature":"\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0438\u043a \u0421\u0428 29","chat":{"id":-456,"title":"\u041e\u0445\u0440\u0430\u043d\u0430 \u0421\u042829","type":"channel"},"date":1759418183,"text":"Test 02.10.2025 22:15"}}

Добрый день!

Благодарю за информацию, уточню у разработчиков, как исправить данную проблему.

Добрый день!

Попробуйте прописать в /etc/default/wb-rules переменные с вашими настройками прокси:

Environment="http_proxy=http://IP:3128/"
Environment="https_proxy=http://IP:3128/"
Environment="no_proxy=127.0.0.1,localhost"

В каталоге /etc/default файл wb-rules отсутствовал, поэтому я его создал. Правильно понял, что переменная Environment должна быть записана с большой буквы?
В общем, я сохранил файл, перезагрузил сервис командой service wb-rules restart, запустил ваш скрипт и вот:

Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: *   Trying 149.154.167.220:443...
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: *   Trying 149.154.167.220:443...
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: *   Trying 149.154.167.220:443...
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * Connected to api.telegram.org (149.154.167.220) port 443 (#0)
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: ALPN, offering h2
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: ALPN, offering h2
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: ALPN, offering http/1.1
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: ALPN, offering http/1.1
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * ALPN, offering h2
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * ALPN, offering http/1.1
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * successfully set certificate verify locations:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: *  CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: *  CApath: /etc/ssl/certs
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: } [5 bytes
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: da
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: ta
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: successfully set certificate verify locations:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: ]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]:   CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: *
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]:  CApath: /etc/ssl/certs
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: } [512 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: } [5 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: } [512 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * successfully set certificate verify locations:
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: *  CAfile: /etc/ssl/certs/ca-certificates.crt
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: *  CApath: /etc/ssl/certs
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: } [5 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * TLSv1.3 (OUT), TLS handshake, Client hello (1):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: } [512 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: { [122 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: { [6 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: { [698 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: } [2 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * SSL certificate problem: self signed certificate
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4021]: * Closing connection 0
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: { [122 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: { [6 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: { [698 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: } [2 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * SSL certificate problem: self signed certificate
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4022]: * Closing connection 0
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * TLSv1.3 (IN), TLS handshake, Server hello (2):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: { [122 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: { [6 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * TLSv1.3 (IN), TLS handshake, Certificate (11):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: { [698 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * TLSv1.3 (OUT), TLS alert, unknown CA (560):
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: } [2 bytes data]
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * SSL certificate problem: self signed certificate
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[4020]: * Closing connection 0
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[29566]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №2"' failed with exit status 60
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[29566]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №1"' failed with exit status 60
Oct 03 18:50:02 wirenboard-ABC123 wb-rules[29566]: ERROR: command '/bin/sh -c LANG=C.UTF-8 curl -s -v -X POST https://api.telegram.org/bot123:ABC/sendMessage --data-urlencode chat_id=-456 --data-urlencode text="Тестовое сообщение №3"' failed with exit status 60

Кажется, ничего не поменялось.

Каким образом был экранирован передаваемый json?

У нас wb-rules не поддерживает работу через прокси.

Простите, не совсем понял вопрос. Сообщение передавалось через Notify.sendTelegramMessage("token", "chatId", "text") и в этой команде json, вроде, не передаётся.

Это значит, что перспектив наладить связь нет?

Для примера:

var token = '6************6:A**************************M'
var chatId = "4**********3"

Notify.sendTelegramMessage(token, chatId, 'text for test')

отрабатывает.

Ну почему ж. Вот тут почти все верно, но зачем-то --data-urlencode лишний раз.
Я бы взял за основу отличное решение GitHub - aadegtyarev/telegram2wb: Телеграм-бот на wb-rules и дописал туда прокси.

Да, согласен, бот отличный, но подскажите, пожалуйста, куда дописывать прокси?

Во все вызовы curl.