Skip to content

Commit 9e30d0b

Browse files
committed
process auto_answers attribute from chat backend
1 parent 4930cbb commit 9e30d0b

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

integreat_cms/api/v3/chat/user_chat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def zammad_webhook(request: HttpRequest) -> JsonResponse:
251251
)
252252
if is_app_user_message(webhook_message) and not webhook_message["ticket"]["automatic_answers"]:
253253
actions.append("question translation queued")
254-
process_answer.apply_async(
254+
process_translate_question.apply_async(
255255
args=[message_text, region.slug, webhook_message["ticket"]["id"]]
256256
)
257257
elif is_app_user_message(webhook_message):
@@ -261,7 +261,7 @@ def zammad_webhook(request: HttpRequest) -> JsonResponse:
261261
)
262262
else:
263263
actions.append("answer translation queued")
264-
process_answer.apply_async(
264+
process_translate_answer.apply_async(
265265
args=[message_text, region.slug, webhook_message["ticket"]["id"]]
266266
)
267267
return JsonResponse(

integreat_cms/api/v3/chat/utils/chat_bot.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,16 @@ def process_user_message(
9797
client.send_message(
9898
zammad_chat.zammad_id,
9999
translation["translation"],
100-
True,
101-
True,
100+
internal = True,
101+
automatic_message = True,
102102
)
103103
if answer:
104104
client.send_message(
105105
zammad_chat.zammad_id,
106106
answer["answer"],
107-
False,
108-
True,
107+
internal = False,
108+
automatic_message = True,
109+
automatic_answers = answer["automatic_answers"],
109110
)
110111

111112

@@ -139,8 +140,8 @@ def process_translate_answer(message_text: str, region_slug: str, zammad_ticket_
139140
client.send_message(
140141
zammad_chat.zammad_id,
141142
translation["translation"],
142-
False,
143-
True,
143+
internal = False,
144+
automatic_message = True,
144145
)
145146

146147

@@ -160,6 +161,6 @@ def process_translate_question(message_text: str, region_slug: str, zammad_ticke
160161
client.send_message(
161162
zammad_chat.zammad_id,
162163
translation["translation"],
163-
True,
164-
True,
164+
internal = True,
165+
automatic_message = True,
165166
)

integreat_cms/api/v3/chat/utils/zammad_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def send_message(
174174
message: str,
175175
internal: bool = False,
176176
automatic_message: bool = False,
177+
automatic_answers: bool = True,
177178
) -> dict:
178179
# pylint: disable=method-hidden
179180
"""
@@ -183,6 +184,7 @@ def send_message(
183184
param message: The message body
184185
param internal: keep the message internal in Zammad (do not show to user)
185186
param automatic_message: sets title to "automatically generated message"
187+
param automatic_answers: sets the attribute
186188
return: dict with Zammad article data
187189
"""
188190
params = {
@@ -197,6 +199,7 @@ def send_message(
197199
else "app user message"
198200
),
199201
"sender": "Customer" if not automatic_message else "Agent",
202+
"automatic_answers": automatic_answers,
200203
}
201204
return self._parse_response( # type: ignore[return-value]
202205
self._attempt_call(self.client.ticket_article.create, params=params)

0 commit comments

Comments
 (0)