JSScripting send telegram message to only one chatId

I’m about to migrate all my rules DSL rules to JS Scripting and there is one thing I just could not find out in any of the documentation: how to send a telegram message with JS to only one chat ID.
In rules DSL I used this:

val telegramAction = getActions("telegram","telegram:telegramBot:xxx")
    telegramAction.sendTelegram(1234L, message)
    telegramAction.sendTelegram(2345L, message)

But in JSScripting there is only this method available:

var telegramAction = actions.get("telegram", "telegram:telegramBot:xxx")

I tried to create separate bots for each chatID, but then I get thousands of warnings “Telegram exception: GetUpdates failed with error_code 409 Conflict: terminated by other getUpdates request; make sure that only one bot instance is running” (which is quite obvious, but at least it is sending correctly).

Is there a way to configure only one bot with several chatIDs and use it in JS like in rules DSL?


What makes you say that? It’s the same thing you are executing in either case. That ‘getActions’ in Rules DSL is exactly the same as the actions.get in JSScripting.

In both cases they return a Java Object and the sendTelegram method being called is exactly the same in both cases.

So if it didn’t work, something else is wrong.

1 Like

OK thanks for the feedback. I tried again and I think I found the issue: I have to delete the “L” in the numeric literal. When I first tried I got an error “SyntaxError: :5:37 Missing space after numeric literal” and I misinterpreted it. I surrounded the number with quotes so it was taken as message instead of chatId.