ChatBotRequests Model
- class smarter.apps.chatbot.models.ChatBotRequests(*args, **kwargs)[source]
Bases:
TimestampedModelStores the request history for a ChatBot instance within the Smarter platform.
This model is designed to record and manage all incoming requests made to a chatbot, providing a persistent audit trail of interactions for analysis, debugging, and reporting. Each record in this model captures the details of a single request, including the associated chatbot, the request payload, session information, and aggregation status.
Purpose and Usage
The ChatBotRequests model enables comprehensive tracking of chatbot usage and user interactions. By storing each request, the platform can support features such as:
Request analytics and reporting for chatbot performance and user engagement.
Debugging and trouble shooting of chatbot behavior by reviewing historical requests.
Session management, allowing grouping and correlation of requests within a user session.
Aggregation of requests for batch processing or summarization.
Model Relationships
Each ChatBotRequests entry is linked to one
ChatBotinstance, establishing a direct association between the request and the chatbot that handled it.
Notes
This model is intended for internal use to support auditing, analytics, and operational monitoring of chatbot activity.
The request data is stored in JSON format to accommodate flexible and extensible payload structures.
Aggregation support allows for efficient handling of bulk or grouped requests, which may be relevant for advanced chatbot workflows.
Example Usage
# Record a new request for a chatbot ChatBotRequests.objects.create( chatbot=my_chatbot, request={"message": "Hello, chatbot!"}, session_key="abc123", is_aggregation=False, ) # Retrieve all requests for a specific chatbot requests = ChatBotRequests.objects.filter(chatbot=my_chatbot)
See Also:
- Parameters:
id (BigAutoField) – Primary key: ID
created_at (DateTimeField) – Created at
updated_at (DateTimeField) – Updated at
request (JSONField) – Request
session_key (CharField) – Session key
is_aggregation (BooleanField) – Is aggregation
Relationship fields:
- Parameters:
chatbot (
ForeignKeytoChatBot) –Chatbot (related name:
chatbotrequests)The ChatBot instance associated with this function. Example: ChatBot(id=1, name=”my-chatbot”)
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- chatbot
-
Chatbot (related name:
chatbotrequests)- Type:
Type
- created_at
-
Created at
Timestamp indicating when the model instance was created. This field is automatically set to the current date and time when the instance is first created. It is indexed in the database for efficient querying.
- Type:
Type
- id
-
Primary key: ID
- Type:
Type
- is_aggregation
-
Is aggregation
- Type:
Type
- objects = <django.db.models.Manager object>
- updated_at
-
Updated at
Timestamp indicating when the model instance was last updated. This field is automatically updated to the current date and time whenever the instance is saved. It is indexed in the database for efficient querying.
- Type:
Type