Data Models
Data models for Apala API client.
All models use Pydantic for type safety and validation.
- class apala_client.models.AuthResponse(**data)[source]
Bases:
BaseModelAuthentication response from the server.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.RefreshResponse(**data)[source]
Bases:
BaseModelToken refresh response from the server.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.CandidateMessageResponse(**data)[source]
Bases:
BaseModelCandidate message in processing response.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.MessageProcessingResponse(**data)[source]
Bases:
BaseModelMessage processing response from the server.
- Parameters:
data (
Any)
-
candidate_message:
CandidateMessageResponse
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.MessageOptimizationResponse(**data)[source]
Bases:
BaseModelMessage optimization response from the server.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.FeedbackResponse(**data)[source]
Bases:
BaseModelFeedback submission response from the server.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.FeedbackItemResponse(**data)[source]
Bases:
BaseModelIndividual feedback item in bulk response.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.BulkFeedbackResponse(**data)[source]
Bases:
BaseModelBulk feedback submission response from the server.
- Parameters:
data (
Any)
-
feedback:
List[FeedbackItemResponse]
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.Message(**data)[source]
Bases:
BaseModelRepresents a customer message.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.MessageFeedback(**data)[source]
Bases:
BaseModelRepresents feedback for a processed message.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class apala_client.models.MessageHistory(**data)[source]
Bases:
BaseModelRepresents a collection of customer messages and a candidate response.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
The data models provide type-safe interfaces for working with messages and feedback.
Message Model
- class apala_client.models.Message(**data)[source]
Represents a customer message.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
The Message class represents both customer messages and candidate responses.
Fields:
content(str): The message text contentchannel(str): Communication channel - “SMS”, “EMAIL”, or “OTHER”message_id(Optional[str]): Unique message identifier (auto-generated if None)send_timestamp(Optional[str]): ISO timestamp (auto-generated if None)reply_or_not(bool): Whether this message is a reply (default: False)
Example:
from apala_client import Message
# Customer message
customer_msg = Message(
content="I'm interested in a home loan",
channel="EMAIL",
reply_or_not=False
)
# Candidate response
response_msg = Message(
content="Great! Let me help you with loan options.",
channel="EMAIL"
)
# Convert to dict for API calls
data = customer_msg.to_dict()
MessageFeedback Model
- class apala_client.models.MessageFeedback(**data)[source]
Represents feedback for a processed message.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
The MessageFeedback class tracks performance metrics for processed messages.
Fields:
original_message_id(str): ID from message processing responsesent_message_content(str): Actual message content sent to customercustomer_responded(bool): Whether the customer respondedquality_score(int): Quality rating from 0-100time_to_respond_ms(Optional[int]): Customer response time in milliseconds
Example:
from apala_client import MessageFeedback
feedback = MessageFeedback(
original_message_id="msg_12345",
sent_message_content="Thank you for your inquiry!",
customer_responded=True,
quality_score=85,
time_to_respond_ms=1800000 # 30 minutes
)
# Convert to dict for API submission
data = feedback.to_dict()
MessageHistory Model
- class apala_client.models.MessageHistory(**data)[source]
Represents a collection of customer messages and a candidate response.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
The MessageHistory class bundles together all data needed for message processing.
Fields:
messages(List[Message]): List of customer messagescandidate_message(Message): Your candidate responsecustomer_id(str): Customer UUIDzip_code(str): Customer’s 5-digit zip codecompany_guid(str): Company UUID
Validation:
The __post_init__ method automatically validates:
UUIDs are properly formatted
Zip code is exactly 5 digits
All message channels are valid (“SMS”, “EMAIL”, “OTHER”)
Example:
from apala_client import Message, MessageHistory
history = MessageHistory(
messages=[
Message(content="Hello", channel="EMAIL"),
Message(content="Need help", channel="SMS")
],
candidate_message=Message(
content="How can I assist you?",
channel="EMAIL"
),
customer_id="550e8400-e29b-41d4-a716-446655440000",
zip_code="90210",
company_guid="550e8400-e29b-41d4-a716-446655440001"
)
# Convert for processing API
processing_data = history.to_processing_dict()
# Convert for optimization API
optimization_data = history.to_optimization_dict()
Model Validation
All models include automatic validation:
- UUID Validation
Customer IDs and company GUIDs must be valid UUID format
- Zip Code Validation
Must be exactly 5 digits
- Channel Validation
Must be one of: “SMS”, “EMAIL”, “OTHER”
- Content Validation
Message content cannot be empty
Example of Validation Errors:
# This will raise ValueError
try:
invalid_history = MessageHistory(
messages=[],
candidate_message=candidate,
customer_id="not-a-uuid", # Invalid UUID
zip_code="123", # Too short
company_guid="also-invalid"
)
except ValueError as e:
print(f"Validation error: {e}")
Best Practices
- Message Creation
Always specify the channel explicitly
Let message_id and send_timestamp auto-generate for new messages
Use descriptive content that clearly represents the customer’s intent
- Feedback Tracking
Submit feedback for every message you send to customers
Use realistic quality scores (0-100)
Include response time when available for better analytics
- Data Validation
Use proper UUID format for customer and company IDs
Ensure zip codes are exactly 5 digits
Validate message content before processing