Chat
User Chat
This module provides the API endpoints for the public chat API
- integreat_cms.api.v3.chat.user_chat.chat(request: HttpRequest, region_slug: str, language_slug: str, device_id: str) JsonResponse | HttpResponse[source]
Function to send a new message in the current chat of a specified device_id, or to create one if no chat exists or the user requested a new one.
- Parameters:
- Returns:
JSON object according to APIv3 chat endpoint definition
- Return type:
JsonResponse | HttpResponse
- integreat_cms.api.v3.chat.user_chat.get_or_create_user_chat(request: HttpRequest, device_id: str, language: Language) UserChat | None[source]
Get existing UserChat or create a new one if the HTTP method is POST.
- integreat_cms.api.v3.chat.user_chat.is_app_user_message(webhook_message: dict) bool[source]
Check if message originates from app user
param webhook_message: Zammad webhook ticket dict
- integreat_cms.api.v3.chat.user_chat.is_chat_enabled_for_user(request: HttpRequest, region_slug: str, device_id: str) JsonResponse[source]
Function to check if the chat feature is enabled for the given region and the given user.
- integreat_cms.api.v3.chat.user_chat.process_chat_payload(request: HttpRequest, device_id: str, language_slug: str) JsonResponse[source]
Create or get UserChat object and return list of messages. Save new message or updated Zammad ticket attributes.
- integreat_cms.api.v3.chat.user_chat.zammad_webhook(request: HttpRequest) JsonResponse[source]
Receive webhooks from Zammad to update the latest article translation.
Optional feature: if a Zammad has an object attribute “device_id” for tickets, we can use this to directly fetch the corresponding chat from our database. This allows multiple regions to use the same Zammad server. As not all Zammad servers have this configured, we still need to support the old method were we fetch the UserChat object identified by the region token and Zammad ticket id.
- Parameters:
request (HttpRequest)
- Return type:
JsonResponse