Announcement

Collapse
No announcement yet.

Telegram notifications

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Telegram notifications

    I want to duplicate Notifications
    (In-app and email notification settings) in telegrams to users.
    The logic is simple, after the system sends an alert, Workflows forwards the message to a telegram.

    The user has a Varchar type field "telegramGroupChatId" which I want to extract using a formula and substitute it into Payload​

    $chatId = assignedUser.telegramGroupChatId;

    Code:
    {
        "chat_id": "$$chatId",
        "text": "*{$subject}*\nDate: {$dateSent}\nTest: {$body}",
        "parse_mode": "HTML", "disable_web_page_preview": "True"
    }​
    the problem is that I can't get the "telegramGroupChatId" value from the user, assigned User is not filled by the system but added to assigned Users

  • #2
    Can you please try to use this variable instead:

    {$$chatId​}

    Comment


    • alexisc
      alexisc commented
      Editing a comment
      Code:
      {
          "chat_id": "{$assignedUser.telegramGroupChatId}",
          "text": "*{$subject}*\nDate: {$dateSent}\nTest: {$$bbody}", 
          "parse_mode": "markdown", "disable_web_page_preview": "True" 
      }
      this won't work, "assignedUser" is empty and the user is listed in the Multiple Assigned Users field

  • #3
    I also tried to extract the value using a formula, but it didn’t work:

    $chatId = record\findRelatedOne('User', assignedUsersIds, 'telegramGroupChatId');

    Comment


    • #4
      That's not what I said.

      You can do it in this way

      $chatId = assignedUser.telegramGroupChatId;

      Code:
      {
      "chat_id": "{$$chatId}*,
      "text": "*{$subject}*\nDate: {$dateSent}\nTest: {$body}",
      "parse_mode": "HTML", "disable_web_page_preview": "True"
      }​
      Edit:
      Are you using a multiple assigned users field?
      The problem is that as far as I know there is no way to make a bot to sendMessage to multiple chat id at the same time, since you are using an assignedUsers field you would retrieve more than 1 chat id, as such you would need to create a custom endpoint to do so (a simple php script would do just fine)

      In alternative you can extract the first result in the array and send the notification to just the first assigned user.
      Last edited by Kharg; 07-09-2024, 09:57 AM.

      Comment


      • #5
        Originally posted by Kharg View Post

        $chatId = assignedUser.telegramGroupChatId;

        it works if there is a "assignedUser"
        but in the email generated by the system, field, the “assignedUser” field is empty
        user is in the “assignedUsers”

        Comment

        Working...
        X