Chat
Chat Bot
Wrapper for the Chat Bot / LLM API
- class integreat_cms.api.v3.chat.chat_bot.ChatBot(hostname: str = 'igchat-inference.tuerantuer.org')[source]
Bases:
object
API Wrapper for the LLM / Chat Bot
- Parameters:
hostname (str)
- automatic_answer(message: str, region: Region, language_slug: str) str [source]
Get automatic answer to question
User Chat
This module provides the API endpoints for the Integreat Chat API
- integreat_cms.api.v3.chat.user_chat.chat(request: HttpRequest, region_slug: str, language_slug: str, device_id: str, attachment_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_attachment(client: ZammadChatAPI, user_chat: UserChat | None, attachment_id: str) JsonResponse | HttpResponse [source]
Function to retrieve an attachment given the correct attachment_id
- Parameters:
client (ZammadChatAPI) – the Zammad API client to use
user_chat (UserChat | None) – the device_id’s current chat (if one exists)
attachment_id (str) – ID of the requested attachment
- Returns:
JSON object according to APIv3 offers endpoint definition
- Return type:
JsonResponse | HttpResponse
- integreat_cms.api.v3.chat.user_chat.get_messages(request: HttpRequest, client: ZammadChatAPI, user_chat: UserChat | None, device_id: str) JsonResponse [source]
Function to retrieve all messages of the most recent chat for a given device_id
- Parameters:
request (HttpRequest) – Django request
client (ZammadChatAPI) – the Zammad API client to use
user_chat (UserChat | None) – the device_id’s current chat
device_id (str) – ID of the user requesting the messages
- Returns:
JSON object according to APIv3 offers endpoint definition
- Return type:
JsonResponse
- 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.response_or_error(result: dict) JsonResponse [source]
Helper function to extract the status code from the API response
- Parameters:
result (dict) – an API call’s result
- Returns:
json response with appropriate status code
- Return type:
JsonResponse
- integreat_cms.api.v3.chat.user_chat.send_message(request: HttpRequest, language_slug: str, client: ZammadChatAPI, user_chat: UserChat | None, device_id: str) JsonResponse [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:
request (HttpRequest) – Django request
language_slug (str) – language slug
client (ZammadChatAPI) – the Zammad API client to use
user_chat (UserChat | None) – the device_id’s current chat (if one exists)
device_id (str) – ID of the user requesting the messages
- Returns:
JSON object according to APIv3 offers endpoint definition
- Return type:
JsonResponse
- integreat_cms.api.v3.chat.user_chat.zammad_webhook(request: HttpRequest) JsonResponse [source]
Receive webhooks from Zammad to update the latest article translation
- Parameters:
request (HttpRequest)
- Return type:
JsonResponse
Zammad API
- class integreat_cms.api.v3.chat.zammad_api.ZammadChatAPI(region: Region)[source]
Bases:
object
Class providing an API for Zammad used in the context of user chats.
- Parameters:
url – The region’s Zammad URL
http_token – The region’s client secret
region (Region)
- create_ticket(device_id: str, language_slug: str) dict [source]
Create a new ticket (i.e. initialize a new chat conversation)
- get_attachment(attachment_map: AttachmentMap) bytes | dict [source]
Get the (binary) attachment file from Zammad.
- Parameters:
attachment_map (AttachmentMap) – the object containing the IDs Zammad requires to identify attachments
- Returns:
the binary object file or a dict containing an error message
- Return type: