mr-karan / calert

🔔 Send alert notifications to Google Chat via Prometheus Alertmanager
MIT License
158 stars 58 forks source link

add messageReplyOption to endpoint to support threaded replies #73

Closed alexandermarston closed 9 months ago

mr-karan commented 9 months ago

This looks useful. Thanks!

alexandermarston commented 9 months ago

Thanks @mr-karan - would you mind cutting a release with this?

mr-karan commented 9 months ago

https://github.com/mr-karan/calert/releases/tag/v2.1.0

jonathan-correa-paiva commented 8 months ago

Threaded replays needs to have a threadKey to send the same alert to the same "conversation", Maybe you could use the fingerprint to manage threadKeys, because, in a Room cnveted to conversarions, generates a new Thread every in every notification.

image

Instead of sending the thread name, it's needs to send a threadKey in the thread object.

Maybe I need to do another config or something, but I've implemented the same in jenkins and I needed to change the object of thread to threadKey: "newKey" in this case we could use the fingerprint.

image

In Jenkins I've made a random string for a job to have all the messages in the same conversation.

I hope I explained it correctly.

When using REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD and threadKey the response changes.

$ curl -X POST -H "Content-Type: application/json" "https://chat.googleapis.com/v1/spaces/AAAAVRbTs0I/messages?key=ofuscatedI&token=ofuscated&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD" -d '{"text": "One\nTwo\nThree", "thread": {"threadKey": "7EWOnlFbT"}}'

///// Response

{
  "name": "spaces/ofuscated/messages/ofuscated.ofuscated",
  "sender": {
    "name": "users/ofuscated",
    "displayName": "Prueab",
    "type": "BOT"
  },
  "createTime": "2024-03-05T02:40:47.890255Z",
  "text": "One\nTwo\nThree",
  "thread": {
    "name": "spaces/ofuscated/threads/ofuscated",
    "retentionSettings": {
      "state": "PERMANENT"
    },
    "threadKey": "7EWOnlFbT" //// The same to use the same conversation.
  },
  "space": {
    "name": "spaces/ofuscated",
    "type": "ROOM",
    "displayName": "Clipboard",
    "spaceThreadingState": "THREADED_MESSAGES",
    "spaceType": "SPACE",
    "spaceHistoryState": "HISTORY_ON",
    "createTime": "2020-05-04T18:50:46.017816Z"
  },
  "argumentText": "One\nTwo\nThree",
  "threadReply": true,
  "retentionSettings": {
    "state": "PERMANENT"
  },
  "formattedText": "One\nTwo\nThree"
}

image