Greg Reed
Greg Reed

Reputation: 11

Update message in google chat from Jira

I am trying to create a notification in google chat whenever the status of a jira ticket changes. I have managed to sort the automation so that a message is sent to google chat every time the status changes but it creates a new thread each time. I would like to either update the original message with the new status or add a new message to the same thread.

I have the Automation configured to Send web request as follows has anyone managed to do this?

Webhook URL : https://chat.googleapis.com/v1/spaces/xxxx/messages?key=xxxx&token=xxxx Header : Content-Type - application/json; charset=UTF-8

HTTP method : POST Webhook body : Custom data

Custom data

"cards": [
 {
   "header": {
     "title": "{{issue.key}}",
     "subtitle": "{{issue.summary}}"
   },
   "sections": [
     {
       "widgets": [
           {
             "keyValue": {
               "topLabel": "Reported by",
               "content": "{{issue.reporter.displayName}}"
               }
           },
           {
             "keyValue": {
               "topLabel": "Status",
               "content": "{{issue.status.name}}"
             }
           }
       ]
     },
     {
       "widgets": [
           {
               "buttons": [
                 {
                   "textButton": {
                     "text": "View Ticket",
                     "onClick": {
                       "openLink": {
                         "url": "{{issue.url.customer}}"
                       }
                     }
                   }
                 }
               ]
           }
       ]
     }
   ]
 }
]
}

Example of what is happening

Upvotes: 1

Views: 1392

Answers (1)

ziganotschka
ziganotschka

Reputation: 26836

To create a new message under the same thread, you need to provide the thread as part of the message body

  • When you send the first message, the response contains a message resource that contains a thread resource
  • Include the thread name you obtain after sending the first message into the message body of the subsequent messages - this will enforce threading

To update an existing card, you need to follow the documentation:

  • Use the actionResponse.type UPDATE_MESSAGE instead of NEW_MESSAGE
  • I am not sure how you trigger an action response in your situation, but if you have a functionality that is able to trigger a new message, you can just as well trigger UPDATE_MESSAGE instead

Upvotes: 0

Related Questions