Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Lines of code | 86 |
Technical Name |
google_chat |
License | AGPL-3 |
Website | https://mhdsyarif.com |
Versions | 15.0 16.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Lines of code | 86 |
Technical Name |
google_chat |
License | AGPL-3 |
Website | https://mhdsyarif.com |
Versions | 15.0 16.0 |
Google Chat Incoming Webhooks
Send Messages Using Incoming Webhooks
Documentation
Refer to the official documentation: https://developers.google.com/chat/how-tos/webhooks.
Setup & Usage
1. Assign Role Access
Role Access → Google Chat
2. Configure Google Chat Settings
Navigate to:
Settings → Google Chat
Example Configuration
- Name: Order Notifications
- Space Code:
AAAAXXXX
- Environment:
STAGING
/PRODUCTION
- Space Key:
AIzaSyZtE6vySjXXXXXXX
- Space Token:
BQvpPC3M5qppMyDcsiXXXXXX
- Mention Users:
<users/123456789012345678901>
Example API Call (cURL)
curl -H 'Content-Type: application/json' -X POST \
"https://chat.googleapis.com/v1/spaces/AAAAXXXX/messages?key=AIzaSyZtE6vySjXXXXXXX&token=UBQJ-BQvpPC3M5qppMyDcsiXXXXXX" \
--data '{"text": "hi there"}'
Odoo Integration Example
"""
Example: Sending a webhook message to Google Chat when a sales order is confirmed.
"""
import logging
from odoo import models, _
_logger = logging.getLogger(__name__)
class SalesOrder(models.Model):
_inherit = "sale.order"
def action_confirm(self):
result = super(SalesOrder, self).action_confirm()
try:
google_chat = self.env["google.chat"].search([( "name", "=", "Order Notifications")], limit=1)
if google_chat:
message = f"Sale Order {self.name} has been confirmed."
google_chat.send_message(message)
else:
_logger.warning(_("Google Chat configuration not found."))
except Exception as e:
_logger.warning(_("Failed to send message to Google Chat: %s"), str(e))
return result
Issue
https://github.com/mhdsyarif/odoo-addons/issues
Please log in to comment on this module