Skip to content

Commit b4f3aa2

Browse files
thienvh332hailangvn
authored andcommitted
[IMP] ai_oca_bridge: add examples data for AI bridge configuration with server_action
1 parent fcc9c24 commit b4f3aa2

2 files changed

Lines changed: 189 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="tag_helpdesk_spam" model="helpdesk.ticket.tag">
4+
<field name="name">Spam</field>
5+
<field name="color">1</field>
6+
</record>
7+
8+
<record id="action_mark_ticket_as_spam" model="ir.actions.server">
9+
<field name="name">AI Action: Mark Ticket as Spam</field>
10+
<field name="model_id" ref="helpdesk_mgmt.model_helpdesk_ticket" />
11+
<field name="state">code</field>
12+
<field name="code">
13+
ai_data = env.context.get('ai_response', {})
14+
15+
reason = ai_data.get('reason', 'AI System Flagged')
16+
confidence = ai_data.get('confidence', 'N/A')
17+
18+
spam_tag = env.ref('ai_oca_bridge.tag_helpdesk_spam', raise_if_not_found=False)
19+
20+
if spam_tag:
21+
for ticket in records:
22+
if spam_tag.id not in ticket.tag_ids.ids:
23+
ticket.write({'tag_ids': [(4, spam_tag.id)]})
24+
25+
msg_body = f"🤖 &lt;b&gt;SPAM DETECTED&lt;/b&gt;&lt;br/&gt;Reason: {reason} (Confidence: {confidence})"
26+
ticket.message_post(body=msg_body)
27+
</field>
28+
</record>
29+
30+
<record id="ai_bridge_helpdesk_ticket_spam_identify" model="ai.bridge">
31+
<field name="name">Helpdesk Ticket Spam Identification</field>
32+
<field name="model_id" ref="helpdesk_mgmt.model_helpdesk_ticket" />
33+
<field name="usage">ai_thread_create</field>
34+
<field name="result_kind">async</field>
35+
<field name="result_type">server_action</field>
36+
<field name="server_action_id" ref="ai_oca_bridge.action_mark_ticket_as_spam" />
37+
<field
38+
name="field_ids"
39+
eval="[(6, 0, [ref('helpdesk_mgmt.field_helpdesk_ticket__id'), ref('helpdesk_mgmt.field_helpdesk_ticket__display_name'), ref('helpdesk_mgmt.field_helpdesk_ticket__description')])]"
40+
/>
41+
</record>
42+
</odoo>
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"name": "Spam Ticket Identification Flow",
3+
"nodes": [
4+
{
5+
"parameters": {
6+
"httpMethod": "POST",
7+
"path": "helpdesk/check-spam/",
8+
"options": {
9+
"rawBody": true
10+
}
11+
},
12+
"type": "n8n-nodes-base.webhook",
13+
"typeVersion": 2,
14+
"position": [-1264, 80],
15+
"id": "960d09d1-c2a3-4710-9c9a-07aa0cd3f795",
16+
"name": "Webhook",
17+
"webhookId": "da674dc0-4dc8-4ed6-a51d-59afff4272e2"
18+
},
19+
{
20+
"parameters": {
21+
"conditions": {
22+
"options": {
23+
"caseSensitive": true,
24+
"leftValue": "",
25+
"typeValidation": "strict",
26+
"version": 2
27+
},
28+
"conditions": [
29+
{
30+
"id": "99e8601c-e16b-4df6-9df9-f445ec130db8",
31+
"leftValue": "={{ JSON.parse($json.message.content).is_spam }}",
32+
"rightValue": "",
33+
"operator": {
34+
"type": "boolean",
35+
"operation": "true",
36+
"singleValue": true
37+
}
38+
}
39+
],
40+
"combinator": "and"
41+
},
42+
"options": {}
43+
},
44+
"type": "n8n-nodes-base.if",
45+
"typeVersion": 2.2,
46+
"position": [-688, 80],
47+
"id": "982df316-3690-434c-85fa-c0c1da46dfdb",
48+
"name": "If"
49+
},
50+
{
51+
"parameters": {
52+
"modelId": {
53+
"__rl": true,
54+
"value": "gpt-4o-mini",
55+
"mode": "list",
56+
"cachedResultName": "GPT-4O-MINI"
57+
},
58+
"messages": {
59+
"values": [
60+
{
61+
"content": "You are a strict Spam Detection Officer for an Odoo/IT Helpdesk.\n Your task is to analyze the incoming ticket description and determine whether it is spam.\nCRITERIA FOR SPAM — Return true when ANY of these is detected:\n1. SEO, marketing, backlink, or website ranking service offers.\n2. Unrelated service promotions (web design, mobile apps, logo design, copywriting, outsourcing not related to our project).\n3. Suspicious links, shortened URLs without context, or phishing-like messages.\n4. Bulk-generated outreach messages (generic, not referencing Odoo/IT context).\n5. Nonsense text, random characters, or obviously AI-generated gibberish.\n6. Messages unrelated to IT, Odoo, ERP, or our provided services.\nCRITERIA FOR HAM — Return false:\n1. Issues or questions related to Odoo, modules, customization, bugs, deployments, or integration.\n2. Questions about invoices, access, accounts, or contract-related matters.\n3. Complaints, feedback, or feature requests.\n4. Any message that resembles a genuine support request from a human.\nOUTPUT FORMAT:\nStrictly return a JSON object with this structure:\n{\n \"is_spam\": boolean,\n \"reason\": \"Short explanation why this is spam (max 1 sentence)\",\n \"confidence\": \"Estimation from 0% to 100% (e.g. '98%')\"\n}\nExample: {\"is_spam\": true, \"reason\": \"Mentions prohibited drugs (Viagra).\", \"confidence\": \"99%\"}",
62+
"role": "system"
63+
},
64+
{
65+
"content": "={{ $json.body.record.display_name}} - {{ $json.body.record.description }}"
66+
}
67+
]
68+
},
69+
"options": {}
70+
},
71+
"type": "@n8n/n8n-nodes-langchain.openAi",
72+
"typeVersion": 1.8,
73+
"position": [-1056, 80],
74+
"id": "e431b723-d2a4-4d3c-a8ae-420584da691c",
75+
"name": "Message a model",
76+
"credentials": {
77+
"openAiApi": {
78+
"id": "t7lm95Kw7wmoj4xt",
79+
"name": "OpenAi account 2"
80+
}
81+
}
82+
},
83+
{
84+
"parameters": {
85+
"method": "POST",
86+
"url": "={{$('Webhook').item.json.body._response_url}}",
87+
"sendBody": true,
88+
"specifyBody": "json",
89+
"jsonBody": "={{$json.message.content}}",
90+
"options": {}
91+
},
92+
"type": "n8n-nodes-base.httpRequest",
93+
"typeVersion": 4.2,
94+
"position": [-432, -32],
95+
"id": "a9e87afa-4907-436e-a241-f63c964af12b",
96+
"name": "HTTP Request",
97+
"alwaysOutputData": false
98+
}
99+
],
100+
"pinData": {},
101+
"connections": {
102+
"Webhook": {
103+
"main": [
104+
[
105+
{
106+
"node": "Message a model",
107+
"type": "main",
108+
"index": 0
109+
}
110+
]
111+
]
112+
},
113+
"Message a model": {
114+
"main": [
115+
[
116+
{
117+
"node": "If",
118+
"type": "main",
119+
"index": 0
120+
}
121+
]
122+
]
123+
},
124+
"If": {
125+
"main": [
126+
[
127+
{
128+
"node": "HTTP Request",
129+
"type": "main",
130+
"index": 0
131+
}
132+
]
133+
]
134+
}
135+
},
136+
"active": false,
137+
"settings": {
138+
"executionOrder": "v1"
139+
},
140+
"versionId": "d7f051a5-c962-44b6-87b1-54441763efef",
141+
"meta": {
142+
"templateCredsSetupCompleted": true,
143+
"instanceId": "95483db1596026047067fce31863479f616aaf310d370d2a94b0e438c3495911"
144+
},
145+
"id": "fWYne7mmDfzimDWd",
146+
"tags": []
147+
}

0 commit comments

Comments
 (0)