Let Jira message Google Chat. https://www.redradishtech.com/display/KB/A+Jira+bot+for+Google+Chat
Remove hardcoding of my test room
Docs and cleanups


browse log



#Jira / Google Chat Integration

This ScriptRunner for Jira script lets your Jira send event updates to a Google Chat (https://chat.google.com) room.

The chat room is notified by webhook. In this implementation the webhook is stored per-issue in a custom field. This means that chat notification needs to be explicitly configured per-issue. Feel free to modify the code (getWebhookUrl) to just return a static webhook URL for all issues.


Assuming you have ScriptRunner for Jira installed:

  1. Save the script to $JIRAHOME/scripts/googlechat.groovy
  2. In Jira, create a custom field called Chat Webhook, of type Text Field (single line), scoped appropriately for projects you may want Chat notifications for. Note the ID of this new custom field.
  3. Edit googlechat.groovy and set the WEBHOOK_CHAT_CUSTOMFIELD_ID value to the ID of your field.
  4. In ScriptRunner, click 'Create Listener' -> Custom Listener. Pick the project(s) and issue event(s) you want notifications for (non-issue events won't work). Set 'Script file' to 'googlechat.groovy' (or wherever you put it, relative to $JIRAHOME/scripts/).
  5. In a https://chat.google.com chatroom, click the top menu beneath the room name, then 'Configure Webooks'. Create a new webhook. As Avatar URL, enter https://jira.atlassian.com/images/64jira.png
  6. In a Jira issue, set the Chat Webhook field value to the webhook URL.
  7. Comment or update the issue. You should see a corresponding message in your chat room.


If it doesn't work, check the ScriptRunner listener history, where you can see any failures in the logs, or HTTP failure messages returned from Google.

#Development notes

I initially was posting GChat messages using the card format, which seems (at first) ideal for key-value pairs. However in practice the card format doesn't work: horizontal width is clipped to about 5cm, and there is no way to format blockquoted text. So I switched to the basic format, and have converted Jira wiki markup to GChat markup as far as possible.

As for future work, it would be nice if we could @mention people like the assignee. That would require looking up GChat user IDs via an authenticated REST call, then persisting the username -> GChatUserID mappings, perhaps using ActiveObjects, so that it is cached across events.

Another nice enhancement would be to set the webhook per project, rather than per issue. This would allow the 'Issue Created' events to be reported. This could be implemented using the Enhanced Project Properties plugin (see groovy code example).