Maintainers
+Maintainers
This module is maintained by the OCA.
@@ -446,6 +444,5 @@ diff --git a/ai_oca_bridge_chatter/README.rst b/ai_oca_bridge_chatter/README.rst index 0759f7fb..e956d462 100644 --- a/ai_oca_bridge_chatter/README.rst +++ b/ai_oca_bridge_chatter/README.rst @@ -1,7 +1,3 @@ -.. image:: https://odoo-community.org/readme-banner-image - :target: https://odoo-community.org/get-involved?utm_source=readme - :alt: Odoo Community Association - ===================== Ai Oca Bridge Chatter ===================== @@ -17,7 +13,7 @@ Ai Oca Bridge Chatter .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fai-lightgray.png?logo=github @@ -37,6 +33,10 @@ This module allows usage of LLM chatbots inside Odoo. The logic of the chatbot should be defined in an external system like n8n. +When a user replies to a Discuss message and mentions a bot, the chatter +payload includes the quoted parent message so the agent can evaluate it +without receiving the rest of the channel history. + **Table of contents** .. contents:: diff --git a/ai_oca_bridge_chatter/models/ai_bridge.py b/ai_oca_bridge_chatter/models/ai_bridge.py index e55785b6..d24b186c 100644 --- a/ai_oca_bridge_chatter/models/ai_bridge.py +++ b/ai_oca_bridge_chatter/models/ai_bridge.py @@ -19,6 +19,7 @@ def _prepare_payload_chatter(self, record=None, **kwargs): record = self.env["mail.message"].search([], limit=1) if record._name != "mail.message": raise ValueError(_("The record must be a mail.message instance.")) + parent = record.parent_id return { "message": { "res_id": record.res_id, @@ -29,6 +30,19 @@ def _prepare_payload_chatter(self, record=None, **kwargs): "date": record.date.isoformat(), "author_name": record.author_id.name, "attachment_ids": record.attachment_ids.ids, - "parent_id": record.parent_id.id if record.parent_id else False, + "parent_id": parent.id if parent else False, + "parent": self._prepare_payload_chatter_parent(parent), } } + + def _prepare_payload_chatter_parent(self, parent): + """Serialize the replied-to message, if any, for the external agent.""" + if not parent: + return False + return { + "id": parent.id, + "body": parent.body, + "author_id": parent.author_id.id, + "author_name": parent.author_id.name, + "date": parent.date.isoformat() if parent.date else False, + } diff --git a/ai_oca_bridge_chatter/readme/DESCRIPTION.md b/ai_oca_bridge_chatter/readme/DESCRIPTION.md index a2c79fa6..f435b31f 100644 --- a/ai_oca_bridge_chatter/readme/DESCRIPTION.md +++ b/ai_oca_bridge_chatter/readme/DESCRIPTION.md @@ -1,3 +1,7 @@ This module allows usage of LLM chatbots inside Odoo. The logic of the chatbot should be defined in an external system like n8n. + +When a user replies to a Discuss message and mentions a bot, the chatter +payload includes the quoted parent message so the agent can evaluate it +without receiving the rest of the channel history. diff --git a/ai_oca_bridge_chatter/static/description/index.html b/ai_oca_bridge_chatter/static/description/index.html index 1ca42e55..7bdda427 100644 --- a/ai_oca_bridge_chatter/static/description/index.html +++ b/ai_oca_bridge_chatter/static/description/index.html @@ -3,7 +3,7 @@
-This module allows usage of LLM chatbots inside Odoo.
The logic of the chatbot should be defined in an external system like n8n.
+When a user replies to a Discuss message and mentions a bot, the chatter +payload includes the quoted parent message so the agent can evaluate it +without receiving the rest of the channel history.
Table of contents
On your external AI system create a workflow that will receive messages and will return the call directly.
Here you can see an example of @@ -404,7 +402,7 @@
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed @@ -412,15 +410,15 @@
Do not contact contributors directly about support or help with technical issues.